added owner-only .massping for emergencies
This commit is contained in:
parent
b1d28296f0
commit
97fe14cf5a
3 changed files with 49 additions and 1 deletions
src/EllieBot
|
@ -11,4 +11,42 @@ public class Owner(VoteRewardService vrs) : EllieModule
|
|||
vrs.SetVoiceChannel(ctx.Channel);
|
||||
await ctx.OkAsync();
|
||||
}
|
||||
|
||||
private static CancellationTokenSource _cts = null;
|
||||
|
||||
[Cmd]
|
||||
public async Task MassPing()
|
||||
{
|
||||
if (_cts is { } t)
|
||||
{
|
||||
await t.CancelAsync();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var users = await ctx.Guild.GetUsersAsync().Fmap(u => u.Where(x => !x.IsBot).ToArray());
|
||||
|
||||
var currentIndex = 0;
|
||||
while (!_cts.IsCancellationRequested)
|
||||
{
|
||||
try
|
||||
{
|
||||
var batch = users[currentIndex..(currentIndex += 50)];
|
||||
|
||||
var mentions = batch.Select(x => x.Mention).Join(" ");
|
||||
await ctx.Channel.SendMessageAsync(mentions, allowedMentions: AllowedMentions.All);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
await Task.Delay(2500);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_cts = null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1656,4 +1656,6 @@ linkfixlist:
|
|||
votefeed:
|
||||
- votefeed
|
||||
vote:
|
||||
- vote
|
||||
- vote
|
||||
massping:
|
||||
- massping
|
|
@ -5198,5 +5198,13 @@ vote:
|
|||
Will redirect user to timely if voting is not enabled.
|
||||
ex:
|
||||
- ''
|
||||
params:
|
||||
- { }
|
||||
massping:
|
||||
desc: |-
|
||||
Mass pings all users in the server.
|
||||
Run again to cancel.
|
||||
ex:
|
||||
- ''
|
||||
params:
|
||||
- { }
|
Loading…
Add table
Reference in a new issue