Merge pull request #329 from appelemac/dev

.leave command
This commit is contained in:
Master Kwoth 2016-06-09 19:48:02 +02:00
commit c14ed6d2d8
5 changed files with 51 additions and 2 deletions

View File

@ -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 =>
{

View File

@ -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);
});
}
}
}

View File

@ -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)

View File

@ -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);

View File

@ -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" />