using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using Discord.Commands;namespace BotTesting.Modules{ public class Commands : ModuleBase<SocketCommandContext> { [Command("ping")] public async Task Ping() { await ReplyAsync("Pong"); } }}
private async Task HandleCommandAsync(SocketMessage arg) { var message = arg as SocketUserMessage; var context = new SocketCommandContext(_client, message); { if (message.Author.IsBot) return; int argPos = 0; if (message.HasStringPrefix("!", ref argPos)) { var result = await _commands.ExecuteAsync(context, argPos, _services); if (!result.IsSuccess) Console.WriteLine(result.ErrorReason); } } } }}