mirror of
				https://gitlab.com/Kwoth/nadekobot.git
				synced 2025-11-03 16:24:27 -05: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]
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1261,3 +1261,5 @@ exprsimport:
 | 
				
			|||||||
  - eximport
 | 
					  - eximport
 | 
				
			||||||
exprsexport:
 | 
					exprsexport:
 | 
				
			||||||
  - exexport
 | 
					  - exexport
 | 
				
			||||||
 | 
					deleteemptyservers:
 | 
				
			||||||
 | 
					  - deleteemptyservers
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2141,3 +2141,7 @@ showembed:
 | 
				
			|||||||
  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