A lot of administration stuff, adding more tomorrow

.r role-name [role-color(optional)] (creates a new role)
.b @User (bans a user)
.k @Users (kicks a user)
.vch channel_name (creates a new voice channel)
.ch channel_name (creates a new text channel)
This commit is contained in:
Master Kwoth 2015-12-07 21:20:18 +01:00
parent c62e3f6520
commit 8f9e4d7e11
2 changed files with 113 additions and 0 deletions

View File

@ -1,4 +1,5 @@
using Discord.Modules;
using System;
using System.Linq;
namespace NadekoBot.Modules
@ -17,6 +18,117 @@ namespace NadekoBot.Modules
commands.ForEach(cmd => cmd.Init(cgb));
cgb.CreateCommand(".r").Alias(".role")
.Description("Creates a role with a given name, and color.\n*Both the user and the bot must have the sufficient permissions.*")
.Parameter("role_name",Discord.Commands.ParameterType.Required)
.Parameter("role_color",Discord.Commands.ParameterType.Optional)
.Do(async e =>
{
var color = Discord.Color.Blue;
if (e.GetArg("role_color") != null)
{
try
{
if (e.GetArg("role_color") != null && e.GetArg("role_color").Trim().Length > 0)
color = (typeof(Discord.Color)).GetField(e.GetArg("role_color")).GetValue(null) as Discord.Color;
}
catch (Exception ex)
{
System.Console.WriteLine(ex.ToString());
await client.SendMessage(e.Channel, "Please supply a proper color.\n Example: DarkBlue, Orange, Teal");
return;
}
}
try
{
if (e.User.ServerPermissions.ManageRoles)
{
var r = await client.CreateRole(e.Server, e.GetArg("role_name"));
await client.EditRole(r, null,null, color);
}
}
catch (Exception)
{
await client.SendMessage(e.Channel, "No sufficient permissions.");
}
return;
});
cgb.CreateCommand(".b").Alias(".ban")
.Description("Kicks a mentioned user\n*Both the user and the bot must have the sufficient permissions.*")
.Do(async e =>
{
try
{
if (e.User.ServerPermissions.BanMembers && e.Message.MentionedUsers.Any())
{
var usr = e.Message.MentionedUsers.First();
await client.BanUser(e.Message.MentionedUsers.First());
await client.SendMessage(e.Channel, "Banned user " + usr.Name + " Id: " + usr.Id);
}
}
catch (Exception)
{
await client.SendMessage(e.Channel, "No sufficient permissions.");
}
});
cgb.CreateCommand(".k").Alias(".kick")
.Parameter("user")
.Description("Kicks a mentioned user.\n*Both the user and the bot must have the sufficient permissions.*")
.Do(async e =>
{
try
{
if (e.User.ServerPermissions.KickMembers && e.Message.MentionedUsers.Any())
{
var usr = e.Message.MentionedUsers.First();
await client.KickUser(e.Message.MentionedUsers.First());
await client.SendMessage(e.Channel,"Kicked user " + usr.Name+" Id: "+usr.Id);
}
}
catch (Exception)
{
await client.SendMessage(e.Channel, "No sufficient permissions.");
}
});
cgb.CreateCommand(".vch")
.Description("Creates a new voice channel with a given name.\n*Both the user and the bot must have the sufficient permissions.*")
.Parameter("channel_name", Discord.Commands.ParameterType.Required)
.Do(async e =>
{
try
{
if (e.User.ServerPermissions.ManageChannels)
{
await client.CreateChannel(e.Server, e.GetArg("channel_name"), Discord.ChannelType.Voice);
}
}
catch (Exception)
{
await client.SendMessage(e.Channel, "No sufficient permissions.");
}
});
cgb.CreateCommand(".ch")
.Alias(".tch")
.Description("Creates a new text channel with a given name.\n*Both the user and the bot must have the sufficient permissions.*")
.Parameter("channel_name", Discord.Commands.ParameterType.Required)
.Do(async e =>
{
try
{
if (e.User.ServerPermissions.ManageChannels)
{
await client.CreateChannel(e.Server, e.GetArg("channel_name"), Discord.ChannelType.Text);
}
}
catch (Exception) {
await client.SendMessage(e.Channel, "No sufficient permissions.");
}
});
cgb.CreateCommand(".uid")
.Description("Shows user id")
.Parameter("user",Discord.Commands.ParameterType.Required)

View File

@ -21,6 +21,7 @@ namespace NadekoBot
{
//load credentials from credentials.json
Credentials c;
try
{
c = JsonConvert.DeserializeObject<Credentials>(File.ReadAllText("credentials.json"));