Another problem with making a discord bot RRS feed

  • Question

  • I was planning to write another syntax for my bot and I got this kind of error: "Severity Code Description Project File Line Suppression State
    Error CS1501 No overload for method 'ExecuteAsync' takes 2 arguments Bot C:\Users\user\source\repos\Botl\Botl\Program.cs 64 Active" for line 64

    Would you please help me? Thanks in advance.

    Also... this is the code program:

    using System;
    using System.Reflection;
    using System.Threading.Tasks;
    using Discord;
    using Discord.Commands;
    using Discord.WebSocket;
    namespace Bot
        class Program
            private DiscordSocketClient Client;
            private CommandService Commands;
            static void Main(string[] args) => new Program().MainAsync().GetAwaiter().GetResult();
            private async Task MainAsync()
                Client = new DiscordSocketClient(new DiscordSocketConfig
                    LogLevel = LogSeverity.Debug
                Commands = new CommandService(new CommandServiceConfig
                    CaseSensitiveCommands = true,
                    DefaultRunMode = RunMode.Async,
                    LogLevel = LogSeverity.Debug
                Client.MessageReceived += Client_MessageReceived;
                await Commands.AddModulesAsync(assembly: Assembly.GetEntryAssembly(), services: null);
                Client.Ready += Client_Ready;
                Client.Log += Client_Log;
                await Client.LoginAsync(TokenType.Bot, "");
                await Client.StartAsync();
                await Task.Delay(-1);
            private async Task Client_Log(LogMessage Message)
                Console.WriteLine($"{DateTime.Now} at {Message.Source}] {Message.Message}");
            private async Task Client_Ready()
                await Client.SetGameAsync("ur dad", "");
            private async Task Client_MessageReceived(SocketMessage MessageParam)
                var Message = MessageParam as SocketUserMessage;
                var Context = new SocketCommandContext(Client, Message);
                if (Context.Message == null || Context.Message.Content == "") return;
                if (Context.User.IsBot) return;
                int ArgPos = 0;
                if (!(Message.HasStringPrefix("gay!", ref ArgPos) || Message.HasMentionPrefix(Client.CurrentUser, ref ArgPos))) return;
                var Result = await Commands.ExecuteAsync(Context, ArgPos);
                if (!Result.IsSucces)
                    Console.WriteLine($"{DateTime.Now} at Commands] Something went wrong with executing a command. Text: {Context.Message.Content} | Error: {Result.ErrorReason}");

    • Edited by Smashy77 Friday, January 18, 2019 10:17 PM
    Friday, January 18, 2019 10:17 PM


  • You need to check with the Discord.Net folks for this.  As I see their code, CommandService.ExecuteAsync requires three parameters: an ICommandContext (which you are giving), an integer (which you are giving), and an IServiceProvider, which you are not giving.  That's why you got the error.

    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    Saturday, January 19, 2019 11:31 PM