Browse Source

Removed info command and EmbedBuilder created in kick.

pull/1143/head
Patryk R 7 years ago
parent
commit
9ce0c3938a
1 changed files with 13 additions and 15 deletions
  1. +13
    -15
      samples/02_commands_framework/Modules/PublicModule.cs

+ 13
- 15
samples/02_commands_framework/Modules/PublicModule.cs View File

@@ -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
{ {
@@ -52,14 +53,24 @@ namespace _02_commands_framework.Modules
// Kick a user // Kick a user
[Command("kick")] [Command("kick")]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
// make sure the user invoking the coomand can kick
// make sure the user invoking the command can kick
[RequireUserPermission(GuildPermission.KickMembers)] [RequireUserPermission(GuildPermission.KickMembers)]
// make sure the bot itself can kick // make sure the bot itself can kick
[RequireBotPermission(GuildPermission.KickMembers)] [RequireBotPermission(GuildPermission.KickMembers)]
public async Task KickUserAsync(IGuildUser user, [Remainder] string reason = null) 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 user.KickAsync(reason, null);
await ReplyAsync("ok!");
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
@@ -72,18 +83,5 @@ namespace _02_commands_framework.Modules
[Command("list")] [Command("list")]
public Task ListAsync(params string[] objects) public Task ListAsync(params string[] objects)
=> ReplyAsync("You listed: " + string.Join("; ", objects)); => ReplyAsync("You listed: " + string.Join("; ", objects));

// Can be used to example put information
[Command("info")]
public async Task InformationAsync()
{
// Creates the pattern TextBlock
EmbedBuilder builder = new EmbedBuilder();
//builder.AddField("title", "");
builder.WithTitle("This is Discord!")
.WithColor(Color.Orange);

await ReplyAsync("", false, builder.Build());
}
} }
} }

Loading…
Cancel
Save