Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Command("help")]
- [Remarks("List all available commands")]
- public async Task Help()
- {
- // Send the message via DM to not flood the chat
- var dmChannel = await Context.User.GetOrCreateDMChannelAsync();
- if (Context.Channel != dmChannel)
- await Context.Message.DeleteAsync(); // Only delete the command if we're not in a DM
- string prefix = BotConfig.Load().Prefix;
- var builder = new EmbedBuilder() // Post the commands within an embedded message
- {
- Color = new Color(255, 0, 0),
- Description = "These are the commands you can use:"
- };
- // Loop through each of the modules loaded in the CommandService
- foreach (var module in _commands.Modules)
- {
- string description = null;
- foreach (var cmd in module.Commands)
- {
- // Check if each command passes
- var result = cmd.CheckPreconditionsAsync(Context);
- if (result.IsCompleted)
- // If they do pass, add the first alias (the actual name of the command) to the description tag of the embed
- description += $"{prefix}{cmd.Aliases[0]}\n";
- }
- if (!string.IsNullOrWhiteSpace(description))
- {
- builder.AddField(x =>
- {
- x.Name = module.Name;
- x.Value = description;
- x.IsInline = false;
- });
- }
- }
- await dmChannel.SendMessageAsync("", false, builder.Build());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement