Browse Source

Merge 9ce0c3938a into de4d415053

pull/1143/merge
Patryk Rajca GitHub 7 years ago
parent
commit
62bb3a7d61
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 0 deletions
  1. +24
    -0
      samples/02_commands_framework/Modules/PublicModule.cs

+ 24
- 0
samples/02_commands_framework/Modules/PublicModule.cs View File

@@ -3,6 +3,7 @@ using System.Threading.Tasks;
using Discord;
using Discord.Commands;
using _02_commands_framework.Services;
using System;

namespace _02_commands_framework.Modules
{
@@ -49,6 +50,29 @@ namespace _02_commands_framework.Modules
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
[Command("echo")]
public Task EchoAsync([Remainder] string text)


Loading…
Cancel
Save