added owner-only .massping for emergencies

This commit is contained in:
Toastie 2025-03-26 12:17:53 +13:00
parent b1d28296f0
commit 97fe14cf5a
Signed by: toastie_t0ast
GPG key ID: 0861BE54AD481DC7
3 changed files with 49 additions and 1 deletions
src/EllieBot

View file

@ -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;
}
}
}

View file

@ -1656,4 +1656,6 @@ linkfixlist:
votefeed:
- votefeed
vote:
- vote
- vote
massping:
- massping

View file

@ -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:
- { }