diff --git a/NadekoBot/Modules/Administration/AdministrationModule.cs b/NadekoBot/Modules/Administration/AdministrationModule.cs index fc907cac..57a68dc6 100644 --- a/NadekoBot/Modules/Administration/AdministrationModule.cs +++ b/NadekoBot/Modules/Administration/AdministrationModule.cs @@ -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 => { diff --git a/NadekoBot/Modules/Administration/Commands/SelfCommands.cs b/NadekoBot/Modules/Administration/Commands/SelfCommands.cs new file mode 100644 index 00000000..1530eee4 --- /dev/null +++ b/NadekoBot/Modules/Administration/Commands/SelfCommands.cs @@ -0,0 +1,46 @@ +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(); + 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; + } + if (!server.IsOwner) + { + await server.Leave(); + } + else + { + await server.Delete(); + } + await NadekoBot.SendMessageToOwner("Left server " + server.Name); + }); + } + } +} diff --git a/NadekoBot/Modules/Gambling/GamblingModule.cs b/NadekoBot/Modules/Gambling/GamblingModule.cs index ef49e6dc..5c0c8919 100644 --- a/NadekoBot/Modules/Gambling/GamblingModule.cs +++ b/NadekoBot/Modules/Gambling/GamblingModule.cs @@ -94,7 +94,7 @@ namespace NadekoBot.Modules.Gambling }); cgb.CreateCommand(Prefix + "award") - .Description("Gives someone a certain amount of flowers. **Owner only!**") + .Description("Gives someone a certain amount of flowers. **Owner only!**\n**Usage**: `$award 100 @person`") .AddCheck(SimpleCheckers.OwnerOnly()) .Parameter("amount", ParameterType.Required) .Parameter("receiver", ParameterType.Unparsed) diff --git a/NadekoBot/NadekoBot.cs b/NadekoBot/NadekoBot.cs index d6e0974d..1c9aea9d 100644 --- a/NadekoBot/NadekoBot.cs +++ b/NadekoBot/NadekoBot.cs @@ -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); diff --git a/NadekoBot/NadekoBot.csproj b/NadekoBot/NadekoBot.csproj index 8789a5db..df37a039 100644 --- a/NadekoBot/NadekoBot.csproj +++ b/NadekoBot/NadekoBot.csproj @@ -136,6 +136,7 @@ +