mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2024-10-03 04:23:13 +00:00
Added .deleteemptyservers command
This commit is contained in:
parent
a402f33a4c
commit
02e59bd5a5
4 changed files with 40 additions and 3 deletions
|
@ -295,6 +295,36 @@ public partial class Administration
|
|||
public partial Task Leave([Leftover] string guildStr)
|
||||
=> _service.LeaveGuild(guildStr);
|
||||
|
||||
[Cmd]
|
||||
[OwnerOnly]
|
||||
public async partial Task DeleteEmptyServers()
|
||||
{
|
||||
await ctx.Channel.TriggerTypingAsync();
|
||||
|
||||
var toLeave = _client.Guilds
|
||||
.Where(s => s.MemberCount == 1 && s.Users.Count == 1)
|
||||
.ToList();
|
||||
|
||||
foreach (var server in toLeave)
|
||||
{
|
||||
try
|
||||
{
|
||||
await server.DeleteAsync();
|
||||
Log.Information("Deleted server {ServerName} [{ServerId}]",
|
||||
server.Name,
|
||||
server.Id);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Warning(ex,
|
||||
"Error leaving server {ServerName} [{ServerId}]",
|
||||
server.Name,
|
||||
server.Id);
|
||||
}
|
||||
}
|
||||
|
||||
await ReplyConfirmLocalizedAsync(strs.deleted_x_servers(toLeave.Count));
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[OwnerOnly]
|
||||
|
|
|
@ -1260,4 +1260,6 @@ expredit:
|
|||
exprsimport:
|
||||
- eximport
|
||||
exprsexport:
|
||||
- exexport
|
||||
- exexport
|
||||
deleteemptyservers:
|
||||
- deleteemptyservers
|
||||
|
|
|
@ -2140,4 +2140,8 @@ showembed:
|
|||
desc: "Prints the json equivalent of the embed of the message specified by its Id."
|
||||
args:
|
||||
- "820022733172121600"
|
||||
- "#some-channel 820022733172121600"
|
||||
- "#some-channel 820022733172121600"
|
||||
deleteemptyservers:
|
||||
desc: "Deletes all servers in which the bot is the only member."
|
||||
args:
|
||||
- ""
|
|
@ -966,5 +966,6 @@
|
|||
"favorites": "Favorites",
|
||||
"tags": "Tags",
|
||||
"imageonly_enable": "This channel is now image-only.",
|
||||
"imageonly_disable": "This channel is no longer image-only."
|
||||
"imageonly_disable": "This channel is no longer image-only.",
|
||||
"deleted_x_servers": "Deleted {0} servers."
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue