mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
Added .deleteemptyservers command
This commit is contained in:
@@ -295,6 +295,36 @@ public partial class Administration
|
|||||||
public partial Task Leave([Leftover] string guildStr)
|
public partial Task Leave([Leftover] string guildStr)
|
||||||
=> _service.LeaveGuild(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]
|
[Cmd]
|
||||||
[OwnerOnly]
|
[OwnerOnly]
|
||||||
|
@@ -1260,4 +1260,6 @@ expredit:
|
|||||||
exprsimport:
|
exprsimport:
|
||||||
- eximport
|
- eximport
|
||||||
exprsexport:
|
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."
|
desc: "Prints the json equivalent of the embed of the message specified by its Id."
|
||||||
args:
|
args:
|
||||||
- "820022733172121600"
|
- "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",
|
"favorites": "Favorites",
|
||||||
"tags": "Tags",
|
"tags": "Tags",
|
||||||
"imageonly_enable": "This channel is now image-only.",
|
"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."
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user