Help with making a discord bot
YanıtlandıI am new in making a Discord Bot and I am stuck at some kind of error. I tried to make one in visual Studio C# 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\Bot\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, "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("with 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}");
}
}
}
}
Would you please help me?
-
Kurumsal yorum
If you have a general question about Discord or you feel you need support help, please contact our support team via https://dis.gd/contact or tweet us @discordapp. This website is specifically for new feature suggestions to add to Discord. As such, I'm closing out this ticket as invalid.
Gönderi yorumlara kapalı.
Yorumlar
1 yorum