Owner only -> Bot owner only, Cleanup, removed requests,

This commit is contained in:
Master Kwoth 2016-06-15 22:53:43 +02:00
parent 3633c83e53
commit 831d802c12
10 changed files with 41 additions and 181 deletions

View File

@ -630,7 +630,7 @@ namespace NadekoBot.Modules.Administration
}); });
cgb.CreateCommand(Prefix + "heap") cgb.CreateCommand(Prefix + "heap")
.Description("Shows allocated memory - **Owner Only!**") .Description("Shows allocated memory - **Bot Owner Only!**")
.AddCheck(SimpleCheckers.OwnerOnly()) .AddCheck(SimpleCheckers.OwnerOnly())
.Do(async e => .Do(async e =>
{ {
@ -710,7 +710,7 @@ namespace NadekoBot.Modules.Administration
cgb.CreateCommand(Prefix + "die") cgb.CreateCommand(Prefix + "die")
.Alias(Prefix + "graceful") .Alias(Prefix + "graceful")
.Description("Shuts the bot down and notifies users about the restart. **Owner Only!**") .Description("Shuts the bot down and notifies users about the restart. **Bot Owner Only!**")
.AddCheck(SimpleCheckers.OwnerOnly()) .AddCheck(SimpleCheckers.OwnerOnly())
.Do(async e => .Do(async e =>
{ {
@ -721,7 +721,7 @@ namespace NadekoBot.Modules.Administration
cgb.CreateCommand(Prefix + "newname") cgb.CreateCommand(Prefix + "newname")
.Alias(Prefix + "setname") .Alias(Prefix + "setname")
.Description("Give the bot a new name. **Owner Only!**") .Description("Give the bot a new name. **Bot Owner Only!**")
.Parameter("new_name", ParameterType.Unparsed) .Parameter("new_name", ParameterType.Unparsed)
.AddCheck(SimpleCheckers.OwnerOnly()) .AddCheck(SimpleCheckers.OwnerOnly())
.Do(async e => .Do(async e =>
@ -733,7 +733,7 @@ namespace NadekoBot.Modules.Administration
cgb.CreateCommand(Prefix + "newavatar") cgb.CreateCommand(Prefix + "newavatar")
.Alias(Prefix + "setavatar") .Alias(Prefix + "setavatar")
.Description("Sets a new avatar image for the NadekoBot. **Owner Only!**") .Description("Sets a new avatar image for the NadekoBot. **Bot Owner Only!**")
.Parameter("img", ParameterType.Unparsed) .Parameter("img", ParameterType.Unparsed)
.AddCheck(SimpleCheckers.OwnerOnly()) .AddCheck(SimpleCheckers.OwnerOnly())
.Do(async e => .Do(async e =>
@ -754,7 +754,7 @@ namespace NadekoBot.Modules.Administration
}); });
cgb.CreateCommand(Prefix + "setgame") cgb.CreateCommand(Prefix + "setgame")
.Description("Sets the bots game. **Owner Only!**") .Description("Sets the bots game. **Bot Owner Only!**")
.Parameter("set_game", ParameterType.Unparsed) .Parameter("set_game", ParameterType.Unparsed)
.Do(e => .Do(e =>
{ {
@ -781,7 +781,7 @@ namespace NadekoBot.Modules.Administration
Channel commsChannel = null; Channel commsChannel = null;
cgb.CreateCommand(Prefix + "commsuser") cgb.CreateCommand(Prefix + "commsuser")
.Description("Sets a user for through-bot communication. Only works if server is set. Resets commschannel. **Owner Only!**") .Description("Sets a user for through-bot communication. Only works if server is set. Resets commschannel. **Bot Owner Only!**")
.Parameter("name", ParameterType.Unparsed) .Parameter("name", ParameterType.Unparsed)
.AddCheck(SimpleCheckers.OwnerOnly()) .AddCheck(SimpleCheckers.OwnerOnly())
.Do(async e => .Do(async e =>
@ -797,7 +797,7 @@ namespace NadekoBot.Modules.Administration
}); });
cgb.CreateCommand(Prefix + "commsserver") cgb.CreateCommand(Prefix + "commsserver")
.Description("Sets a server for through-bot communication. **Owner Only!**") .Description("Sets a server for through-bot communication. **Bot Owner Only!**")
.Parameter("server", ParameterType.Unparsed) .Parameter("server", ParameterType.Unparsed)
.AddCheck(SimpleCheckers.OwnerOnly()) .AddCheck(SimpleCheckers.OwnerOnly())
.Do(async e => .Do(async e =>
@ -810,7 +810,7 @@ namespace NadekoBot.Modules.Administration
}); });
cgb.CreateCommand(Prefix + "commschannel") cgb.CreateCommand(Prefix + "commschannel")
.Description("Sets a channel for through-bot communication. Only works if server is set. Resets commsuser. **Owner Only!**") .Description("Sets a channel for through-bot communication. Only works if server is set. Resets commsuser. **Bot Owner Only!**")
.Parameter("ch", ParameterType.Unparsed) .Parameter("ch", ParameterType.Unparsed)
.AddCheck(SimpleCheckers.OwnerOnly()) .AddCheck(SimpleCheckers.OwnerOnly())
.Do(async e => .Do(async e =>
@ -826,7 +826,7 @@ namespace NadekoBot.Modules.Administration
}); });
cgb.CreateCommand(Prefix + "send") cgb.CreateCommand(Prefix + "send")
.Description("Send a message to someone on a different server through the bot. **Owner Only!**\n**Usage**: .send Message text multi word!") .Description("Send a message to someone on a different server through the bot. **Bot Owner Only!**\n**Usage**: .send Message text multi word!")
.Parameter("msg", ParameterType.Unparsed) .Parameter("msg", ParameterType.Unparsed)
.AddCheck(SimpleCheckers.OwnerOnly()) .AddCheck(SimpleCheckers.OwnerOnly())
.Do(async e => .Do(async e =>
@ -903,7 +903,7 @@ namespace NadekoBot.Modules.Administration
}); });
cgb.CreateCommand(Prefix + "unstuck") cgb.CreateCommand(Prefix + "unstuck")
.Description("Clears the message queue. **Owner Only!**") .Description("Clears the message queue. **Bot Owner Only!**")
.AddCheck(SimpleCheckers.OwnerOnly()) .AddCheck(SimpleCheckers.OwnerOnly())
.Do(e => .Do(e =>
{ {
@ -974,7 +974,7 @@ namespace NadekoBot.Modules.Administration
}); });
cgb.CreateCommand(Prefix + "announce") cgb.CreateCommand(Prefix + "announce")
.Description($"Sends a message to all servers' general channel bot is connected to.**Owner Only!**\n**Usage**: {Prefix}announce Useless spam") .Description($"Sends a message to all servers' general channel bot is connected to.**Bot Owner Only!**\n**Usage**: {Prefix}announce Useless spam")
.Parameter("msg", ParameterType.Unparsed) .Parameter("msg", ParameterType.Unparsed)
.AddCheck(SimpleCheckers.OwnerOnly()) .AddCheck(SimpleCheckers.OwnerOnly())
.Do(async e => .Do(async e =>

View File

@ -21,7 +21,7 @@ namespace NadekoBot.Modules.Administration.Commands
cgb.CreateCommand(Prefix + "addcustomreaction") cgb.CreateCommand(Prefix + "addcustomreaction")
.Alias(Prefix + "acr") .Alias(Prefix + "acr")
.Description($"Add a custom reaction. Guide here: <https://github.com/Kwoth/NadekoBot/wiki/Custom-Reactions> **Owner Only!** \n**Usage**: {Prefix}acr \"hello\" I love saying hello to %user%") .Description($"Add a custom reaction. Guide here: <https://github.com/Kwoth/NadekoBot/wiki/Custom-Reactions> **Bot Owner Only!** \n**Usage**: {Prefix}acr \"hello\" I love saying hello to %user%")
.AddCheck(SimpleCheckers.OwnerOnly()) .AddCheck(SimpleCheckers.OwnerOnly())
.Parameter("name", ParameterType.Required) .Parameter("name", ParameterType.Required)
.Parameter("message", ParameterType.Unparsed) .Parameter("message", ParameterType.Unparsed)

View File

@ -328,14 +328,13 @@ $@"🕔`{prettyCurrentTime}` **Message** 📝 `#{e.Channel.Name}`
}); });
cgb.CreateCommand(Module.Prefix + "logserver") cgb.CreateCommand(Module.Prefix + "logserver")
.Description("Toggles logging in this channel. Logs every message sent/deleted/edited on the server. **Owner Only!**") .Description("Toggles logging in this channel. Logs every message sent/deleted/edited on the server. **Bot Owner Only!**")
.AddCheck(SimpleCheckers.OwnerOnly()) .AddCheck(SimpleCheckers.OwnerOnly())
.AddCheck(SimpleCheckers.ManageServer()) .AddCheck(SimpleCheckers.ManageServer())
.Do(DoFunc()); .Do(DoFunc());
cgb.CreateCommand(Module.Prefix + "userpresence") cgb.CreateCommand(Module.Prefix + "userpresence")
.Description("Starts logging to this channel when someone from the server goes online/offline/idle. **Owner Only!**") .Description("Starts logging to this channel when someone from the server goes online/offline/idle.")
.AddCheck(SimpleCheckers.OwnerOnly())
.AddCheck(SimpleCheckers.ManageServer()) .AddCheck(SimpleCheckers.ManageServer())
.Do(async e => .Do(async e =>
{ {
@ -351,9 +350,8 @@ $@"🕔`{prettyCurrentTime}` **Message** 📝 `#{e.Channel.Name}`
}); });
cgb.CreateCommand(Module.Prefix + "voicepresence") cgb.CreateCommand(Module.Prefix + "voicepresence")
.Description("Toggles logging to this channel whenever someone joins or leaves a voice channel you are in right now. **Owner Only!**") .Description("Toggles logging to this channel whenever someone joins or leaves a voice channel you are in right now.")
.Parameter("all", ParameterType.Optional) .Parameter("all", ParameterType.Optional)
.AddCheck(SimpleCheckers.OwnerOnly())
.AddCheck(SimpleCheckers.ManageServer()) .AddCheck(SimpleCheckers.ManageServer())
.Do(async e => .Do(async e =>
{ {

View File

@ -180,7 +180,7 @@ namespace NadekoBot.Modules.Administration.Commands
cgb.CreateCommand(Module.Prefix + "remindmsg") cgb.CreateCommand(Module.Prefix + "remindmsg")
.Description("Sets message for when the remind is triggered. " + .Description("Sets message for when the remind is triggered. " +
" Available placeholders are %user% - user who ran the command, %message% -" + " Available placeholders are %user% - user who ran the command, %message% -" +
" Message specified in the remind, %target% - target channel of the remind. **Owner only!**") " Message specified in the remind, %target% - target channel of the remind. **Bot Owner Only!**")
.Parameter("msg", ParameterType.Unparsed) .Parameter("msg", ParameterType.Unparsed)
.AddCheck(SimpleCheckers.OwnerOnly()) .AddCheck(SimpleCheckers.OwnerOnly())
.Do(async e => .Do(async e =>

View File

@ -1,11 +1,7 @@
using NadekoBot.Classes; using Discord.Commands;
using System; using NadekoBot.Classes;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Discord.Commands;
using NadekoBot.Modules.Permissions.Classes; using NadekoBot.Modules.Permissions.Classes;
using System.Linq;
namespace NadekoBot.Modules.Administration.Commands namespace NadekoBot.Modules.Administration.Commands
{ {
@ -18,14 +14,14 @@ namespace NadekoBot.Modules.Administration.Commands
internal override void Init(CommandGroupBuilder cgb) internal override void Init(CommandGroupBuilder cgb)
{ {
cgb.CreateCommand(Module.Prefix + "leave") cgb.CreateCommand(Module.Prefix + "leave")
.Description("Makes Nadeko leave the server. Either name or id required.\n**Usage**:.leave NSFW") .Description("Makes Nadeko leave the server. Either name or id required.\n**Usage**: `.leave 123123123331`")
.Parameter("arg", ParameterType.Required) .Parameter("arg", ParameterType.Required)
.AddCheck(SimpleCheckers.OwnerOnly()) .AddCheck(SimpleCheckers.OwnerOnly())
.Do(async e => .Do(async e =>
{ {
var arg = e.GetArg("arg")?.Trim(); var arg = e.GetArg("arg").Trim();
var server = NadekoBot.Client.Servers.FirstOrDefault(s => s.Id.ToString() == arg) ?? var server = NadekoBot.Client.Servers.FirstOrDefault(s => s.Id.ToString() == arg) ??
NadekoBot.Client.FindServers(arg.Trim()).FirstOrDefault(); NadekoBot.Client.FindServers(arg).FirstOrDefault();
if (server == null) if (server == null)
{ {
await e.Channel.SendMessage("Cannot find that server").ConfigureAwait(false); await e.Channel.SendMessage("Cannot find that server").ConfigureAwait(false);

View File

@ -1,133 +0,0 @@
using Discord.Commands;
using NadekoBot.Extensions;
using NadekoBot.Modules;
using NadekoBot.Modules.Permissions.Classes;
using System;
using System.Threading.Tasks;
namespace NadekoBot.Classes.Conversations.Commands
{
internal class RequestsCommand : DiscordCommand
{
public void SaveRequest(CommandEventArgs e, string text)
{
DbHandler.Instance.InsertData(new DataModels.Request
{
RequestText = text,
UserName = e.User.Name,
UserId = (long)e.User.Id,
ServerId = (long)e.Server.Id,
ServerName = e.Server.Name,
DateAdded = DateTime.Now
});
}
// todo what if it's too long?
public string GetRequests()
{
var task = DbHandler.Instance.GetAllRows<DataModels.Request>();
var str = "Here are all current requests for NadekoBot:\n\n";
foreach (var reqObj in task)
{
str += $"{reqObj.Id}. by **{reqObj.UserName}** from **{reqObj.ServerName}** at {reqObj.DateAdded.ToLocalTime()}\n" +
$"**{reqObj.RequestText}**\n----------\n";
}
return str + "\n__Type [@NadekoBot clr] to clear all of my messages.__";
}
public bool DeleteRequest(int requestNumber) =>
DbHandler.Instance.Delete<DataModels.Request>(requestNumber) != null;
/// <summary>
/// Delete a request with a number and returns that request object.
/// </summary>
/// <returns>RequestObject of the request. Null if none</returns>
public DataModels.Request ResolveRequest(int requestNumber) =>
DbHandler.Instance.Delete<DataModels.Request>(requestNumber);
internal override void Init(CommandGroupBuilder cgb)
{
cgb.CreateCommand("req")
.Alias("request")
.Description("Requests a feature for nadeko.\n**Usage**: @NadekoBot req new_feature")
.Parameter("all", ParameterType.Unparsed)
.Do(async e =>
{
var str = e.Args[0];
try
{
SaveRequest(e, str);
}
catch
{
await e.Channel.SendMessage("Something went wrong.").ConfigureAwait(false);
return;
}
await e.Channel.SendMessage("Thank you for your request.").ConfigureAwait(false);
});
cgb.CreateCommand("lr")
.Description("PMs the user all current nadeko requests.")
.Do(async e =>
{
var str = await Task.Run(() => GetRequests()).ConfigureAwait(false);
if (str.Trim().Length > 110)
await e.User.Send(str).ConfigureAwait(false);
else
await e.User.Send("No requests atm.").ConfigureAwait(false);
});
cgb.CreateCommand("dr")
.Description("Deletes a request. **Owner Only!**")
.Parameter("reqNumber", ParameterType.Required)
.AddCheck(SimpleCheckers.OwnerOnly())
.Do(async e =>
{
try
{
if (DeleteRequest(int.Parse(e.Args[0])))
{
await e.Channel.SendMessage(e.User.Mention + " Request deleted.").ConfigureAwait(false);
}
else
{
await e.Channel.SendMessage("No request on that number.").ConfigureAwait(false);
}
}
catch
{
await e.Channel.SendMessage("Error deleting request, probably NaN error.").ConfigureAwait(false);
}
});
cgb.CreateCommand("rr")
.Description("Resolves a request. **Owner Only!**")
.Parameter("reqNumber", ParameterType.Required)
.AddCheck(SimpleCheckers.OwnerOnly())
.Do(async e =>
{
try
{
var sc = ResolveRequest(int.Parse(e.Args[0]));
if (sc != null)
{
await e.Channel.SendMessage(e.User.Mention + " Request resolved, notice sent.").ConfigureAwait(false);
await NadekoBot.Client.GetServer((ulong)sc.ServerId).GetUser((ulong)sc.UserId).Send("**This request of yours has been resolved:**\n" + sc.RequestText).ConfigureAwait(false);
}
else
{
await e.Channel.SendMessage("No request on that number.").ConfigureAwait(false);
}
}
catch
{
await e.Channel.SendMessage("Error resolving request, probably NaN error.").ConfigureAwait(false);
}
});
}
public RequestsCommand(DiscordModule module) : base(module) { }
}
}

View File

@ -20,7 +20,6 @@ namespace NadekoBot.Modules.Conversations
public Conversations() public Conversations()
{ {
commands.Add(new CopyCommand(this)); commands.Add(new CopyCommand(this));
commands.Add(new RequestsCommand(this));
commands.Add(new RipCommand(this)); commands.Add(new RipCommand(this));
} }

View File

@ -94,7 +94,7 @@ namespace NadekoBot.Modules.Gambling
}); });
cgb.CreateCommand(Prefix + "award") cgb.CreateCommand(Prefix + "award")
.Description("Gives someone a certain amount of flowers. **Owner only!**\n**Usage**: `$award 100 @person`") .Description("Gives someone a certain amount of flowers. **Bot Owner Only!**\n**Usage**: `$award 100 @person`")
.AddCheck(SimpleCheckers.OwnerOnly()) .AddCheck(SimpleCheckers.OwnerOnly())
.Parameter("amount", ParameterType.Required) .Parameter("amount", ParameterType.Required)
.Parameter("receiver", ParameterType.Unparsed) .Parameter("receiver", ParameterType.Unparsed)
@ -116,7 +116,7 @@ namespace NadekoBot.Modules.Gambling
}); });
cgb.CreateCommand(Prefix + "take") cgb.CreateCommand(Prefix + "take")
.Description("Takes a certain amount of flowers from someone. **Owner only!**") .Description("Takes a certain amount of flowers from someone. **Bot Owner Only!**")
.AddCheck(SimpleCheckers.OwnerOnly()) .AddCheck(SimpleCheckers.OwnerOnly())
.Parameter("amount", ParameterType.Required) .Parameter("amount", ParameterType.Required)
.Parameter("rektperson", ParameterType.Unparsed) .Parameter("rektperson", ParameterType.Unparsed)

View File

@ -78,7 +78,7 @@ Version: `{NadekoStats.Instance.BotVersion}`";
.Parameter("command", ParameterType.Unparsed) .Parameter("command", ParameterType.Unparsed)
.Do(HelpFunc()); .Do(HelpFunc());
cgb.CreateCommand(Module.Prefix + "hgit") cgb.CreateCommand(Module.Prefix + "hgit")
.Description("Generates the commandlist.md file. **Owner Only!**") .Description("Generates the commandlist.md file. **Bot Owner Only!**")
.AddCheck(SimpleCheckers.OwnerOnly()) .AddCheck(SimpleCheckers.OwnerOnly())
.Do(DoGitFunc()); .Do(DoGitFunc());
cgb.CreateCommand(Module.Prefix + "readme") cgb.CreateCommand(Module.Prefix + "readme")

View File

@ -299,7 +299,7 @@ namespace NadekoBot.Modules.Music
}); });
cgb.CreateCommand("lopl") cgb.CreateCommand("lopl")
.Description("Queues all songs from a directory. **Owner Only!**\n**Usage**: `!m lopl C:/music/classical`") .Description("Queues all songs from a directory. **Bot Owner Only!**\n**Usage**: `!m lopl C:/music/classical`")
.Parameter("directory", ParameterType.Unparsed) .Parameter("directory", ParameterType.Unparsed)
.AddCheck(SimpleCheckers.OwnerOnly()) .AddCheck(SimpleCheckers.OwnerOnly())
.Do(async e => .Do(async e =>
@ -339,7 +339,7 @@ namespace NadekoBot.Modules.Music
}); });
cgb.CreateCommand("lo") cgb.CreateCommand("lo")
.Description("Queues a local file by specifying a full path. **Owner Only!**\n**Usage**: `!m lo C:/music/mysong.mp3`") .Description("Queues a local file by specifying a full path. **Bot Owner Only!**\n**Usage**: `!m lo C:/music/mysong.mp3`")
.Parameter("path", ParameterType.Unparsed) .Parameter("path", ParameterType.Unparsed)
.AddCheck(SimpleCheckers.OwnerOnly()) .AddCheck(SimpleCheckers.OwnerOnly())
.Do(async e => .Do(async e =>
@ -393,7 +393,7 @@ namespace NadekoBot.Modules.Music
}); });
cgb.CreateCommand("cleanup") cgb.CreateCommand("cleanup")
.Description("Cleans up hanging voice connections. **Owner Only!**\n**Usage**: `!m cleanup`") .Description("Cleans up hanging voice connections. **Bot Owner Only!**\n**Usage**: `!m cleanup`")
.AddCheck(SimpleCheckers.OwnerOnly()) .AddCheck(SimpleCheckers.OwnerOnly())
.Do(e => .Do(e =>
{ {