| @@ -3,6 +3,7 @@ using System.Threading.Tasks; | |||||
| using Discord; | using Discord; | ||||
| using Discord.Commands; | using Discord.Commands; | ||||
| using _02_commands_framework.Services; | using _02_commands_framework.Services; | ||||
| using System; | |||||
| namespace _02_commands_framework.Modules | namespace _02_commands_framework.Modules | ||||
| { | { | ||||
| @@ -49,6 +50,29 @@ namespace _02_commands_framework.Modules | |||||
| await ReplyAsync("ok!"); | await ReplyAsync("ok!"); | ||||
| } | } | ||||
| // Kick a user | |||||
| [Command("kick")] | |||||
| [RequireContext(ContextType.Guild)] | |||||
| // make sure the user invoking the command can kick | |||||
| [RequireUserPermission(GuildPermission.KickMembers)] | |||||
| // make sure the bot itself can kick | |||||
| [RequireBotPermission(GuildPermission.KickMembers)] | |||||
| public async Task KickUserAsync(IGuildUser user, [Remainder] string reason = null) | |||||
| { | |||||
| // Creates the pattern TextBlock | |||||
| EmbedBuilder builder = new EmbedBuilder(); | |||||
| builder.WithTitle(user.Username + " kicked from server!") | |||||
| .WithColor(Color.Orange) | |||||
| .WithDescription("by " + | |||||
| $"{Context.User.Username}" + | |||||
| Environment.NewLine + | |||||
| "Reason: " + reason); | |||||
| await user.KickAsync(reason, null); | |||||
| await ReplyAsync("", false, builder.Build()); | |||||
| } | |||||
| // [Remainder] takes the rest of the command's arguments as one argument, rather than splitting every space | // [Remainder] takes the rest of the command's arguments as one argument, rather than splitting every space | ||||
| [Command("echo")] | [Command("echo")] | ||||
| public Task EchoAsync([Remainder] string text) | public Task EchoAsync([Remainder] string text) | ||||