Leave command
This commit is contained in:
parent
88368be749
commit
db15d302b9
@ -30,12 +30,14 @@ namespace NadekoBot.Modules.Administration
|
||||
commands.Add(new InfoCommands(this));
|
||||
commands.Add(new CustomReactionsCommands(this));
|
||||
commands.Add(new AutoAssignRole(this));
|
||||
commands.Add(new SelfCommands(this));
|
||||
}
|
||||
|
||||
public override string Prefix { get; } = NadekoBot.Config.CommandPrefixes.Administration;
|
||||
|
||||
public override void Install(ModuleManager manager)
|
||||
{
|
||||
|
||||
manager.CreateCommands("", cgb =>
|
||||
{
|
||||
|
||||
|
49
NadekoBot/Modules/Administration/Commands/SelfCommands.cs
Normal file
49
NadekoBot/Modules/Administration/Commands/SelfCommands.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using NadekoBot.Classes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Modules.Permissions.Classes;
|
||||
|
||||
namespace NadekoBot.Modules.Administration.Commands
|
||||
{
|
||||
class SelfCommands : DiscordCommand
|
||||
{
|
||||
public SelfCommands(DiscordModule module) : base(module)
|
||||
{
|
||||
}
|
||||
|
||||
internal override void Init(CommandGroupBuilder cgb)
|
||||
{
|
||||
cgb.CreateCommand(Module.Prefix + "leave")
|
||||
.Description("Makes Nadeko leave the server. Either name or id required.\n**Usage**:.leave NSFW")
|
||||
.Parameter("arg", ParameterType.Required)
|
||||
.AddCheck(SimpleCheckers.OwnerOnly())
|
||||
.Do(async e =>
|
||||
{
|
||||
var arg = e.GetArg("arg")?.Trim();
|
||||
if (string.IsNullOrWhiteSpace(arg))
|
||||
return;
|
||||
var server = NadekoBot.Client.Servers.FirstOrDefault(s => s.Id.ToString() == arg) ??
|
||||
NadekoBot.Client.FindServers(arg.Trim()).FirstOrDefault();
|
||||
if (server == null)
|
||||
{
|
||||
await e.Channel.SendMessage("Cannot find that server").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
var serverId = server.Id;
|
||||
if (!server.IsOwner)
|
||||
{
|
||||
await server.Leave();
|
||||
}
|
||||
else
|
||||
{
|
||||
await server.Delete();
|
||||
}
|
||||
await NadekoBot.SendMessageToOwner("Left server " + server.Name);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -252,7 +252,7 @@ namespace NadekoBot
|
||||
|
||||
public static bool IsOwner(ulong id) => Creds.OwnerIds.Contains(id);
|
||||
|
||||
public async Task SendMessageToOwner(string message)
|
||||
public static async Task SendMessageToOwner(string message)
|
||||
{
|
||||
if (Config.ForwardMessages && OwnerPrivateChannel != null)
|
||||
await OwnerPrivateChannel.SendMessage(message).ConfigureAwait(false);
|
||||
|
@ -136,6 +136,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Modules\Administration\Commands\AutoAssignRole.cs" />
|
||||
<Compile Include="Modules\Administration\Commands\CustomReactionsCommands.cs" />
|
||||
<Compile Include="Modules\Administration\Commands\SelfCommands.cs" />
|
||||
<Compile Include="Modules\ClashOfClans\ClashOfClans.cs" />
|
||||
<Compile Include="Classes\DBHandler.cs" />
|
||||
<Compile Include="Classes\FlowersHandler.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user