New administration functions, fixes, improvements.
Added following commands: .rch channel_name (removes a channel) .rvch channel_name (removes a voice channel) .rr @User role_name (removes a role from a user) .sr @User role_name (adds a role to a user) Added more aliases to administration functions, improved some stuff.
This commit is contained in:
parent
93db5f319f
commit
8b366156dd
@ -43,7 +43,7 @@ namespace NadekoBot
|
|||||||
await client.SendMessage(e.Channel, "**Trivia game started!** It is bound to this channel. But only 1 game can run per server. \n First player to get to 10 points wins! You have 30 seconds per question.\nUse command [tq] if game was started by accident.");
|
await client.SendMessage(e.Channel, "**Trivia game started!** It is bound to this channel. But only 1 game can run per server. \n First player to get to 10 points wins! You have 30 seconds per question.\nUse command [tq] if game was started by accident.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
await client.SendMessage(e.Channel, "Trivia game is already running on this server. The question is:\n**"+GetCurrentQuestion(e.Server.Id).Question+"**\n[tq quits trivia]\n[@NadekoBot clr clears my messages]"); // TODO type x to be reminded of the question
|
await client.SendMessage(e.Channel, "Trivia game is already running on this server. The question is:\n**"+GetCurrentQuestion(e.Server.Id).Question+"**\n[tq quits trivia]\n[@NadekoBot clr clears my messages]");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ namespace NadekoBot
|
|||||||
await client.SendMessage(e.Channel, lb);
|
await client.SendMessage(e.Channel, lb);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
await client.SendMessage(e.Channel, "Trivia game is not running on this server."); // TODO type x to be reminded of the question
|
await client.SendMessage(e.Channel, "Trivia game is not running on this server.");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ namespace NadekoBot
|
|||||||
await client.SendMessage(e.Channel, lb);
|
await client.SendMessage(e.Channel, lb);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
await client.SendMessage(e.Channel, "Trivia game is not running on this server."); // TODO type x to be reminded of the question
|
await client.SendMessage(e.Channel, "Trivia game is not running on this server.");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,12 +18,81 @@ namespace NadekoBot.Modules
|
|||||||
|
|
||||||
commands.ForEach(cmd => cmd.Init(cgb));
|
commands.ForEach(cmd => cmd.Init(cgb));
|
||||||
|
|
||||||
cgb.CreateCommand(".r").Alias(".role")
|
cgb.CreateCommand(".sr").Alias(".setrole")
|
||||||
|
.Description("Sets a role for a given user.\nUsage: .sr @User Guest")
|
||||||
|
.Parameter("user_name", Discord.Commands.ParameterType.Required)
|
||||||
|
.Parameter("role_name", Discord.Commands.ParameterType.Required)
|
||||||
|
.Do(async e =>
|
||||||
|
{
|
||||||
|
if (!e.User.ServerPermissions.ManageRoles) return;
|
||||||
|
var usr = client.FindUsers(e.Server, e.GetArg("user_name")).FirstOrDefault();
|
||||||
|
if (usr == null) {
|
||||||
|
await client.SendMessage(e.Channel, "You failed to supply a valid username");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var role = client.FindRoles(e.Server, e.GetArg("role_name")).FirstOrDefault();
|
||||||
|
if (role == null) {
|
||||||
|
await client.SendMessage(e.Channel, "You failed to supply a valid role");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await client.EditUser(usr, null, null, new Discord.Role[] { role }, Discord.EditMode.Add);
|
||||||
|
await client.SendMessage(e.Channel, $"Successfully added role **{role.Name}** to user **{usr.Mention}**");
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException) { //fkin voltana and his shenanigans, fix role.Mention pl0x
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await client.SendMessage(e.Channel, "Failed to add roles. Most likely reason: Insufficient permissions.\n");
|
||||||
|
Console.WriteLine(ex.ToString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
cgb.CreateCommand(".rr").Alias(".removerole")
|
||||||
|
.Description("Removes a role from a given user.\nUsage: .rr @User Admin")
|
||||||
|
.Parameter("user_name", Discord.Commands.ParameterType.Required)
|
||||||
|
.Parameter("role_name", Discord.Commands.ParameterType.Required)
|
||||||
|
.Do(async e =>
|
||||||
|
{
|
||||||
|
if (!e.User.ServerPermissions.ManageRoles) return;
|
||||||
|
var usr = client.FindUsers(e.Server, e.GetArg("user_name")).FirstOrDefault();
|
||||||
|
if (usr == null)
|
||||||
|
{
|
||||||
|
await client.SendMessage(e.Channel, "You failed to supply a valid username");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var role = client.FindRoles(e.Server, e.GetArg("role_name")).FirstOrDefault();
|
||||||
|
if (role == null)
|
||||||
|
{
|
||||||
|
await client.SendMessage(e.Channel, "You failed to supply a valid role");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await client.EditUser(usr, null, null, new Discord.Role[]{ role }, Discord.EditMode.Remove);
|
||||||
|
await client.SendMessage(e.Channel, $"Successfully removed role **{role.Name}** from user **{usr.Mention}**");
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException) {
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
await client.SendMessage(e.Channel, "Failed to add roles. Most likely reason: Insufficient permissions.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
cgb.CreateCommand(".r").Alias(".role").Alias(".cr").Alias(".createrole")
|
||||||
.Description("Creates a role with a given name, and color.\n*Both the user and the bot must have the sufficient permissions.*")
|
.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_name",Discord.Commands.ParameterType.Required)
|
||||||
.Parameter("role_color",Discord.Commands.ParameterType.Optional)
|
.Parameter("role_color",Discord.Commands.ParameterType.Optional)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
|
if (!e.User.ServerPermissions.ManageRoles) return;
|
||||||
|
|
||||||
var color = Discord.Color.Blue;
|
var color = Discord.Color.Blue;
|
||||||
if (e.GetArg("role_color") != null)
|
if (e.GetArg("role_color") != null)
|
||||||
{
|
{
|
||||||
@ -34,18 +103,16 @@ namespace NadekoBot.Modules
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
System.Console.WriteLine(ex.ToString());
|
Console.WriteLine(ex.ToString());
|
||||||
await client.SendMessage(e.Channel, "Please supply a proper color.\n Example: DarkBlue, Orange, Teal");
|
await client.SendMessage(e.Channel, "Please supply a proper color.\n Example: DarkBlue, Orange, Teal");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
|
||||||
if (e.User.ServerPermissions.ManageRoles)
|
|
||||||
{
|
{
|
||||||
var r = await client.CreateRole(e.Server, e.GetArg("role_name"));
|
var r = await client.CreateRole(e.Server, e.GetArg("role_name"));
|
||||||
await client.EditRole(r, null,null, color);
|
await client.EditRole(r, null,null, color);
|
||||||
}
|
await client.SendMessage(e.Channel, $"Successfully created role **{r.Mention}**.");
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@ -93,7 +160,26 @@ namespace NadekoBot.Modules
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(".vch")
|
cgb.CreateCommand(".rvch").Alias(".removevoicechannel")
|
||||||
|
.Description("Removes a 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.DeleteChannel(client.FindChannels(e.Server,e.GetArg("channel_name"),Discord.ChannelType.Voice).FirstOrDefault());
|
||||||
|
await client.SendMessage(e.Channel, $"Removed channel **{e.GetArg("channel_name")}**.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
await client.SendMessage(e.Channel, "No sufficient permissions.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
cgb.CreateCommand(".vch").Alias(".cvch").Alias(".createvoicechannel")
|
||||||
.Description("Creates a new voice channel with a given name.\n*Both the user and the bot must have the sufficient permissions.*")
|
.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)
|
.Parameter("channel_name", Discord.Commands.ParameterType.Required)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
@ -103,6 +189,7 @@ namespace NadekoBot.Modules
|
|||||||
if (e.User.ServerPermissions.ManageChannels)
|
if (e.User.ServerPermissions.ManageChannels)
|
||||||
{
|
{
|
||||||
await client.CreateChannel(e.Server, e.GetArg("channel_name"), Discord.ChannelType.Voice);
|
await client.CreateChannel(e.Server, e.GetArg("channel_name"), Discord.ChannelType.Voice);
|
||||||
|
await client.SendMessage(e.Channel, $"Created voice channel **{e.GetArg("channel_name")}**.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
@ -111,8 +198,26 @@ namespace NadekoBot.Modules
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(".ch")
|
cgb.CreateCommand(".rch").Alias(".rtch").Alias(".removetextchannel").Alias(".removechannel")
|
||||||
.Alias(".tch")
|
.Description("Removes a 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.DeleteChannel(client.FindChannels(e.Server, e.GetArg("channel_name"), Discord.ChannelType.Text).FirstOrDefault());
|
||||||
|
await client.SendMessage(e.Channel, $"Removed text channel **{e.GetArg("channel_name")}**.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
await client.SendMessage(e.Channel, "No sufficient permissions.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
cgb.CreateCommand(".ch").Alias(".tch").Alias(".createchannel").Alias(".createtextchannel")
|
||||||
.Description("Creates a new text channel with a given name.\n*Both the user and the bot must have the sufficient permissions.*")
|
.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)
|
.Parameter("channel_name", Discord.Commands.ParameterType.Required)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
@ -122,6 +227,7 @@ namespace NadekoBot.Modules
|
|||||||
if (e.User.ServerPermissions.ManageChannels)
|
if (e.User.ServerPermissions.ManageChannels)
|
||||||
{
|
{
|
||||||
await client.CreateChannel(e.Server, e.GetArg("channel_name"), Discord.ChannelType.Text);
|
await client.CreateChannel(e.Server, e.GetArg("channel_name"), Discord.ChannelType.Text);
|
||||||
|
await client.SendMessage(e.Channel, $"Added text channel **{e.GetArg("channel_name")}**.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception) {
|
catch (Exception) {
|
||||||
@ -129,7 +235,7 @@ namespace NadekoBot.Modules
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(".uid")
|
cgb.CreateCommand(".uid").Alias(".userid")
|
||||||
.Description("Shows user id")
|
.Description("Shows user id")
|
||||||
.Parameter("user",Discord.Commands.ParameterType.Required)
|
.Parameter("user",Discord.Commands.ParameterType.Required)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
@ -140,14 +246,14 @@ namespace NadekoBot.Modules
|
|||||||
await client.SendMessage(e.Channel, "You must mention a user.");
|
await client.SendMessage(e.Channel, "You must mention a user.");
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(".cid")
|
cgb.CreateCommand(".cid").Alias(".channelid")
|
||||||
.Description("Shows current channel id")
|
.Description("Shows current channel id")
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
await client.SendMessage(e.Channel, "This channel's id is " + e.Channel.Id);
|
await client.SendMessage(e.Channel, "This channel's id is " + e.Channel.Id);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(".sid")
|
cgb.CreateCommand(".sid").Alias(".serverid")
|
||||||
.Description("Shows current server id")
|
.Description("Shows current server id")
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user