Ejemplo n.º 1
0
        private async Task HandleCommandsAsync(DSharpPlus.EventArgs.MessageUpdateEventArgs e)
        {
            //Skip if its invalid
            if (e == null)
            {
                return;
            }
            if (e.Author == null)
            {
                return;
            }
            if (e.Author.IsBot)
            {
                return;
            }

            //Resolve the prefix
            var mpos = e.Message.GetMentionPrefixLength(Bot.Discord.CurrentUser);

            if (mpos == -1)
            {
                mpos = await Bot.ResolvePrefix(e.Message);
            }
            if (mpos == -1)
            {
                return;
            }
            var pfx = e.Message.Content.Substring(0, mpos);

            //Prepare the command
            var command = e.Message.Content.Substring(mpos);
            var cmd     = Bot.CommandsNext.FindCommand(command, out var args);

            if (cmd == null)
            {
                return;
            }

            //Make sure the user has permission to replay
            var member = e.Message.GetMember();

            if (member != null)
            {
                //Create a context and execute the command
                var fctx = Bot.CommandsNext.CreateContext(e.Message, pfx, cmd, args);
                await Bot.CommandsNext.ExecuteCommandAsync(fctx).ConfigureAwait(false);
            }
        }
Ejemplo n.º 2
0
 public static Task Client_MessageUpdated(DiscordClient sender, DSharpPlus.EventArgs.MessageUpdateEventArgs e)
 {
     return(Task.CompletedTask);
 }