essential commit
This commit is contained in:
parent
d45bf6de55
commit
41d44d1c05
@ -11,7 +11,7 @@ namespace NadekoBot
|
||||
{
|
||||
public class NadekoStats
|
||||
{
|
||||
public string BotVersion = "0.8-beta9";
|
||||
public string BotVersion = "0.8-beta10";
|
||||
|
||||
private static readonly NadekoStats _instance = new NadekoStats();
|
||||
public static NadekoStats Instance => _instance;
|
||||
|
@ -35,7 +35,7 @@ namespace NadekoBot.Classes.Permissions {
|
||||
|
||||
var data = Newtonsoft.Json.JsonConvert.DeserializeObject<ServerPermissions>(File.ReadAllText(file));
|
||||
_permissionsDict.TryAdd(server, data);
|
||||
} catch (Exception ex){
|
||||
} catch (Exception ex) {
|
||||
Console.WriteLine($"Failed getting server with id: {file}\nReason: {ex.Message}");
|
||||
}
|
||||
}
|
||||
@ -72,7 +72,7 @@ namespace NadekoBot.Classes.Permissions {
|
||||
internal static Permissions GetServerPermissions(Server server) {
|
||||
if (!_permissionsDict.ContainsKey(server))
|
||||
return null;
|
||||
|
||||
|
||||
return _permissionsDict[server].Permissions;
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ namespace NadekoBot.Classes.Permissions {
|
||||
if (_permissionsDict[server].ChannelPermissions.TryGetValue(channel.Id, out perm) &&
|
||||
perm.commands.TryGetValue(command.Text, out val) && val == false)
|
||||
return PermissionBanType.ChannelBanCommand;
|
||||
|
||||
|
||||
//ROLE PART - TWO CASES
|
||||
// FIRST CASE:
|
||||
// IF EVERY ROLE USER HAS IS BANNED FROM THE MODULE,
|
||||
@ -194,7 +194,7 @@ namespace NadekoBot.Classes.Permissions {
|
||||
if (!_permissionsDict.ContainsKey(server)) {
|
||||
_permissionsDict.TryAdd(server, new ServerPermissions(server.Id, server.Name));
|
||||
}
|
||||
if(!_permissionsDict[server].ChannelPermissions.ContainsKey(channel.Id))
|
||||
if (!_permissionsDict[server].ChannelPermissions.ContainsKey(channel.Id))
|
||||
_permissionsDict[server].ChannelPermissions.Add(channel.Id, new Permissions(channel.Name));
|
||||
|
||||
var modules = _permissionsDict[server].ChannelPermissions[channel.Id].modules;
|
||||
|
@ -154,7 +154,7 @@ namespace NadekoBot.Modules {
|
||||
|
||||
cgb.CreateCommand(".commands")
|
||||
.Description("List all of the bot's commands from a certain module.")
|
||||
.Parameter("module",ParameterType.Unparsed)
|
||||
.Parameter("module", ParameterType.Unparsed)
|
||||
.Do(async e => {
|
||||
var commands = NadekoBot.client.Commands().AllCommands
|
||||
.Where(c => c.Category.ToLower() == e.GetArg("module").Trim().ToLower());
|
||||
@ -162,7 +162,7 @@ namespace NadekoBot.Modules {
|
||||
await e.Send("That module does not exist.");
|
||||
return;
|
||||
}
|
||||
await e.Send("`List of commands:` \n• " + string.Join("\n• ", commands.Select(c=>c.Text)));
|
||||
await e.Send("`List of commands:` \n• " + string.Join("\n• ", commands.Select(c => c.Text)));
|
||||
});
|
||||
|
||||
cgb.CreateCommand(".b").Alias(".ban")
|
||||
@ -387,7 +387,7 @@ namespace NadekoBot.Modules {
|
||||
if (e.User.Id == NadekoBot.OwnerID)
|
||||
NadekoBot.client.Servers.ForEach(async s => { if (s.Name == e.Server.Name) return; await s.Leave(); });
|
||||
});
|
||||
|
||||
|
||||
cgb.CreateCommand(".prune")
|
||||
.Parameter("num", ParameterType.Required)
|
||||
.Description("Prunes a number of messages from the current channel.\n**Usage**: .prune 5")
|
||||
@ -595,7 +595,7 @@ namespace NadekoBot.Modules {
|
||||
return;
|
||||
await Task.Run(() => NadekoBot.client.MessageQueue.Clear());
|
||||
});
|
||||
|
||||
|
||||
cgb.CreateCommand(".donators")
|
||||
.Description("List of lovely people who donated to keep this project alive.")
|
||||
.Do(async e => {
|
||||
|
@ -6,16 +6,13 @@ using NadekoBot.Classes;
|
||||
using PermsHandler = NadekoBot.Classes.Permissions.PermissionsHandler;
|
||||
|
||||
namespace NadekoBot.Modules {
|
||||
class PermissionModule : DiscordModule
|
||||
{
|
||||
class PermissionModule : DiscordModule {
|
||||
string prefix = "*";
|
||||
public PermissionModule() : base()
|
||||
{
|
||||
public PermissionModule() : base() {
|
||||
//Empty for now
|
||||
}
|
||||
|
||||
public override void Install(ModuleManager manager)
|
||||
{
|
||||
public override void Install(ModuleManager manager) {
|
||||
var client = NadekoBot.client;
|
||||
manager.CreateCommands("", cgb => {
|
||||
|
||||
@ -80,22 +77,16 @@ namespace NadekoBot.Modules {
|
||||
.Parameter("module", ParameterType.Required)
|
||||
.Parameter("bool", ParameterType.Required)
|
||||
.Description("Sets a module's permission at the server level.")
|
||||
.Do(async e =>
|
||||
{
|
||||
try
|
||||
{
|
||||
.Do(async e => {
|
||||
try {
|
||||
string module = PermissionHelper.ValidateModule(e.GetArg("module"));
|
||||
bool state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
||||
|
||||
PermsHandler.SetServerModulePermission(e.Server, module, state);
|
||||
await e.Send("I'm setting " + e.GetArg("module") + " to " + state);
|
||||
}
|
||||
catch (ArgumentException exArg)
|
||||
{
|
||||
} catch (ArgumentException exArg) {
|
||||
await e.Send(exArg.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
} catch (Exception ex) {
|
||||
await e.Send("Something went terribly wrong - " + ex.Message);
|
||||
}
|
||||
});
|
||||
@ -104,22 +95,16 @@ namespace NadekoBot.Modules {
|
||||
.Parameter("command", ParameterType.Required)
|
||||
.Parameter("bool", ParameterType.Required)
|
||||
.Description("Sets a command's permission at the server level.")
|
||||
.Do(async e =>
|
||||
{
|
||||
try
|
||||
{
|
||||
.Do(async e => {
|
||||
try {
|
||||
string command = PermissionHelper.ValidateCommand(e.GetArg("command"));
|
||||
bool state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
||||
|
||||
PermsHandler.SetServerCommandPermission(e.Server, command, state);
|
||||
await e.Send("I'm setting " + e.GetArg("command") + " to " + state);
|
||||
}
|
||||
catch (ArgumentException exArg)
|
||||
{
|
||||
} catch (ArgumentException exArg) {
|
||||
await e.Send(exArg.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
} catch (Exception ex) {
|
||||
await e.Send("Something went terribly wrong - " + ex.Message);
|
||||
}
|
||||
});
|
||||
@ -129,23 +114,17 @@ namespace NadekoBot.Modules {
|
||||
.Parameter("bool", ParameterType.Required)
|
||||
.Parameter("role", ParameterType.Unparsed)
|
||||
.Description("Sets a module's permission at the role level.")
|
||||
.Do(async e =>
|
||||
{
|
||||
try
|
||||
{
|
||||
.Do(async e => {
|
||||
try {
|
||||
string module = PermissionHelper.ValidateModule(e.GetArg("module"));
|
||||
bool state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
||||
Discord.Role role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role"));
|
||||
|
||||
PermsHandler.SetRoleModulePermission(role, module, state);
|
||||
await e.Send("I'm setting " + e.GetArg("module") + " to " + state);
|
||||
}
|
||||
catch (ArgumentException exArg)
|
||||
{
|
||||
} catch (ArgumentException exArg) {
|
||||
await e.Send(exArg.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
} catch (Exception ex) {
|
||||
await e.Send("Something went terribly wrong - " + ex.Message);
|
||||
}
|
||||
});
|
||||
@ -153,25 +132,19 @@ namespace NadekoBot.Modules {
|
||||
cgb.CreateCommand(prefix + "rc").Alias(prefix + "rolecommand")
|
||||
.Parameter("command", ParameterType.Required)
|
||||
.Parameter("bool", ParameterType.Required)
|
||||
.Parameter("role",ParameterType.Unparsed)
|
||||
.Parameter("role", ParameterType.Unparsed)
|
||||
.Description("Sets a command's permission at the role level.")
|
||||
.Do(async e =>
|
||||
{
|
||||
try
|
||||
{
|
||||
.Do(async e => {
|
||||
try {
|
||||
string command = PermissionHelper.ValidateCommand(e.GetArg("command"));
|
||||
bool state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
||||
Discord.Role role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role"));
|
||||
|
||||
PermsHandler.SetRoleCommandPermission(role, command, state);
|
||||
await e.Send("I'm setting " + e.GetArg("command") + " to " + state);
|
||||
}
|
||||
catch (ArgumentException exArg)
|
||||
{
|
||||
} catch (ArgumentException exArg) {
|
||||
await e.Send(exArg.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
} catch (Exception ex) {
|
||||
await e.Send("Something went terribly wrong - " + ex.Message);
|
||||
}
|
||||
});
|
||||
@ -181,23 +154,17 @@ namespace NadekoBot.Modules {
|
||||
.Parameter("bool", ParameterType.Required)
|
||||
.Parameter("channel", ParameterType.Unparsed)
|
||||
.Description("Sets a module's permission at the channel level.")
|
||||
.Do(async e =>
|
||||
{
|
||||
try
|
||||
{
|
||||
.Do(async e => {
|
||||
try {
|
||||
string module = PermissionHelper.ValidateModule(e.GetArg("module"));
|
||||
bool state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
||||
Discord.Channel channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel"));
|
||||
|
||||
PermsHandler.SetChannelModulePermission(channel, module, state);
|
||||
await e.Send("I'm setting " + e.GetArg("module") + " to " + state);
|
||||
}
|
||||
catch (ArgumentException exArg)
|
||||
{
|
||||
} catch (ArgumentException exArg) {
|
||||
await e.Send(exArg.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
} catch (Exception ex) {
|
||||
await e.Send("Something went terribly wrong - " + ex.Message);
|
||||
}
|
||||
});
|
||||
@ -207,23 +174,17 @@ namespace NadekoBot.Modules {
|
||||
.Parameter("bool", ParameterType.Required)
|
||||
.Parameter("channel", ParameterType.Unparsed)
|
||||
.Description("Sets a command's permission at the channel level.")
|
||||
.Do(async e =>
|
||||
{
|
||||
try
|
||||
{
|
||||
.Do(async e => {
|
||||
try {
|
||||
string command = PermissionHelper.ValidateCommand(e.GetArg("command"));
|
||||
bool state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
||||
Discord.Channel channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel"));
|
||||
|
||||
PermsHandler.SetChannelCommandPermission(channel, command, state);
|
||||
await e.Send("I'm setting " + e.GetArg("command") + " to " + state);
|
||||
}
|
||||
catch (ArgumentException exArg)
|
||||
{
|
||||
} catch (ArgumentException exArg) {
|
||||
await e.Send(exArg.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
} catch (Exception ex) {
|
||||
await e.Send("Something went terribly wrong - " + ex.Message);
|
||||
}
|
||||
});
|
||||
@ -233,23 +194,17 @@ namespace NadekoBot.Modules {
|
||||
.Parameter("bool", ParameterType.Required)
|
||||
.Parameter("user", ParameterType.Unparsed)
|
||||
.Description("Sets a module's permission at the user level.")
|
||||
.Do(async e =>
|
||||
{
|
||||
try
|
||||
{
|
||||
.Do(async e => {
|
||||
try {
|
||||
string module = PermissionHelper.ValidateModule(e.GetArg("module"));
|
||||
bool state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
||||
Discord.User user = PermissionHelper.ValidateUser(e.Server, e.GetArg("user"));
|
||||
|
||||
PermsHandler.SetUserModulePermission(user, module, state);
|
||||
await e.Send("I'm setting " + e.GetArg("module") + " to " + state);
|
||||
}
|
||||
catch (ArgumentException exArg)
|
||||
{
|
||||
} catch (ArgumentException exArg) {
|
||||
await e.Send(exArg.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
} catch (Exception ex) {
|
||||
await e.Send("Something went terribly wrong - " + ex.Message);
|
||||
}
|
||||
});
|
||||
@ -259,23 +214,17 @@ namespace NadekoBot.Modules {
|
||||
.Parameter("bool", ParameterType.Required)
|
||||
.Parameter("user", ParameterType.Unparsed)
|
||||
.Description("Sets a command's permission at the user level.")
|
||||
.Do(async e =>
|
||||
{
|
||||
try
|
||||
{
|
||||
.Do(async e => {
|
||||
try {
|
||||
string command = PermissionHelper.ValidateCommand(e.GetArg("command"));
|
||||
bool state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
||||
Discord.User user = PermissionHelper.ValidateUser(e.Server, e.GetArg("user"));
|
||||
|
||||
PermsHandler.SetUserCommandPermission(user, command, state);
|
||||
await e.Send("I'm setting " + e.GetArg("command") + " to " + state);
|
||||
}
|
||||
catch (ArgumentException exArg)
|
||||
{
|
||||
} catch (ArgumentException exArg) {
|
||||
await e.Send(exArg.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
} catch (Exception ex) {
|
||||
await e.Send("Something went terribly wrong - " + ex.Message);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user