This commit is contained in:
@@ -3,6 +3,7 @@ using Discord.WebSocket;
|
||||
|
||||
using PluginManager.Loaders;
|
||||
using PluginManager.Interfaces;
|
||||
using PluginManager.Others.Permissions;
|
||||
|
||||
namespace PluginManager.Commands
|
||||
{
|
||||
@@ -17,21 +18,47 @@ namespace PluginManager.Commands
|
||||
public bool canUseDM => true;
|
||||
public bool canUseServer => true;
|
||||
|
||||
public bool requireAdmin => false;
|
||||
|
||||
public void Execute(SocketCommandContext context, SocketMessage message, DiscordSocketClient client, bool isDM)
|
||||
{
|
||||
if (isDM)
|
||||
bool isAdmin = ((SocketGuildUser)message.Author).isAdmin();
|
||||
if (isAdmin)
|
||||
{
|
||||
foreach (DBCommand p in PluginLoader.Plugins!)
|
||||
if (p.canUseDM)
|
||||
context.Channel.SendMessageAsync(p.Usage + "\t" + p.Description);
|
||||
if (isDM)
|
||||
{
|
||||
foreach (DBCommand p in PluginLoader.Plugins!)
|
||||
if (p.canUseDM)
|
||||
if (p.requireAdmin)
|
||||
context.Channel.SendMessageAsync("[ADMIN] " + p.Usage + "\t" + p.Description);
|
||||
else context.Channel.SendMessageAsync(p.Usage + "\t" + p.Description);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (DBCommand p in PluginLoader.Plugins!)
|
||||
if (p.canUseServer)
|
||||
if (p.requireAdmin)
|
||||
context.Channel.SendMessageAsync("[ADMIN] " + p.Usage + "\t" + p.Description);
|
||||
else context.Channel.SendMessageAsync(p.Usage + "\t" + p.Description);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (DBCommand p in PluginLoader.Plugins!)
|
||||
if (p.canUseServer)
|
||||
context.Channel.SendMessageAsync(p.Usage + "\t" + p.Description);
|
||||
if (isDM)
|
||||
{
|
||||
foreach (DBCommand p in PluginLoader.Plugins!)
|
||||
if (p.canUseDM && !p.requireAdmin)
|
||||
context.Channel.SendMessageAsync(p.Usage + "\t" + p.Description);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (DBCommand p in PluginLoader.Plugins!)
|
||||
if (p.canUseServer && !p.requireAdmin)
|
||||
context.Channel.SendMessageAsync(p.Usage + "\t" + p.Description);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
78
DiscordBot/Discord/Commands/Settings.cs
Normal file
78
DiscordBot/Discord/Commands/Settings.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
|
||||
using PluginManager.Core;
|
||||
using PluginManager.Interfaces;
|
||||
using PluginManager.Others;
|
||||
using PluginManager.Others.Permissions;
|
||||
|
||||
namespace DiscordBot.Discord.Commands
|
||||
{
|
||||
class Settings : DBCommand
|
||||
{
|
||||
public string Command => "set";
|
||||
|
||||
public string Description => "This command allows you change all settings. Use \"set help\" to show details";
|
||||
|
||||
public string Usage => "set [keyword] [new Value]";
|
||||
|
||||
public bool canUseDM => true;
|
||||
public bool canUseServer => true;
|
||||
public bool requireAdmin => true;
|
||||
|
||||
public async void Execute(SocketCommandContext context, SocketMessage message, DiscordSocketClient client, bool isDM)
|
||||
{
|
||||
var channel = message.Channel;
|
||||
try
|
||||
{
|
||||
|
||||
string content = message.Content;
|
||||
string[] data = content.Split(' ');
|
||||
string keyword = data[1];
|
||||
if (keyword.ToLower() == "help")
|
||||
{
|
||||
await channel.SendMessageAsync("set token [new value] -- set the value of the new token (require restart)");
|
||||
await channel.SendMessageAsync("set prefix [new value] -- set the value of the new preifx (require restart)");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
switch (keyword.ToLower())
|
||||
{
|
||||
case "token":
|
||||
if (data.Length != 3)
|
||||
{
|
||||
await channel.SendMessageAsync("Invalid token !");
|
||||
return;
|
||||
}
|
||||
Functions.WriteToSettings("./Data/Resources/DiscordBotCore.data", "BOT_TOKEN", data[2], '\t');
|
||||
break;
|
||||
case "prefix":
|
||||
if (data.Length != 3)
|
||||
{
|
||||
await channel.SendMessageAsync("Invalid token !");
|
||||
return;
|
||||
}
|
||||
Functions.WriteToSettings("./Data/Resources/DiscordBotCore.data", "BOT_PREFIX", data[2], '\t');
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
await channel.SendMessageAsync("Restart required ...");
|
||||
}
|
||||
catch
|
||||
{
|
||||
await channel.SendMessageAsync("Unknown usage to this command !\nUsage: " + Usage);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user