TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
DjJungle Gaming
NA
4
920
Making a Discord Bot
Jan 19 2019 1:57 PM
Hi! I try to make an discord bot at my own on Visual Studio 2017 C# and I faced this kind of error: " Severity Code Description Project File Line Suppression State
Error CS1501 No overload for method 'ExecuteAsync' takes 2 arguments Test btotC:\Users\user\source\repos\Botl\Bot\Program.cs 65 Active "
Also, there is the code program:
using System;
using System.Reflection;
using System.Threading.Tasks;
using Discord;
using Discord.Commands;
using Discord.WebSocket;
using Microsoft.Extensions.DependencyInjection;
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, "Actual bot token...");
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("League of Legends", "");
}
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("g!", 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}");
}
}
}
}
The error it says is on line 65. I tried to put null and didn't work eighter...
Would you help me please?
Reply
Answers (
0
)
How to start a blog with two writers in c# corner
Can we edit the published article?