C
C#15mo ago
zita epsilon

❔ I wrote a discord bot but it's not answering me ?

using DSharpPlus;
using DSharpPlus.EventArgs;
using System.Threading.Tasks;

class Program
{
static DiscordClient discord;

static void Main(string[] args)
{
MainAsync().ConfigureAwait(false).GetAwaiter().GetResult();
}

static async Task MainAsync()
{
discord = new DiscordClient(new DiscordConfiguration
{
Token = "MTA5NzI0MDEyODA4MDA3Mjc3NQ.GJawtS.2odUYCCE4EGZwvHWso6G9mmyrGk9LqUB07HeVc",
TokenType = TokenType.Bot,
Intents = DiscordIntents.AllUnprivileged
});

discord.MessageCreated += async (s, e) =>
{
if (e.Message.Content.ToLower().StartsWith("!ping"))
{
await e.Message.RespondAsync("@here");
}
};

await discord.ConnectAsync();
await Task.Delay(-1);
}
}
using DSharpPlus;
using DSharpPlus.EventArgs;
using System.Threading.Tasks;

class Program
{
static DiscordClient discord;

static void Main(string[] args)
{
MainAsync().ConfigureAwait(false).GetAwaiter().GetResult();
}

static async Task MainAsync()
{
discord = new DiscordClient(new DiscordConfiguration
{
Token = "MTA5NzI0MDEyODA4MDA3Mjc3NQ.GJawtS.2odUYCCE4EGZwvHWso6G9mmyrGk9LqUB07HeVc",
TokenType = TokenType.Bot,
Intents = DiscordIntents.AllUnprivileged
});

discord.MessageCreated += async (s, e) =>
{
if (e.Message.Content.ToLower().StartsWith("!ping"))
{
await e.Message.RespondAsync("@here");
}
};

await discord.ConnectAsync();
await Task.Delay(-1);
}
}
Is there any wrong code or something else? And if there's no bug's in code maybe I couldn't authorize my bot to server. Do you guys know any tutorial for this or can you guys teach me how to add?
4 Replies
Buddy
Buddy15mo ago
Regenerate the bot token immediately As now it has been exposed in a public discord, in a public channel.
occluder
occluder15mo ago
You need DiscordIntents.MessageContents in the intents too. So it would be DiscordIntents.AllUnprivileged | DiscordIntents.MessageContents. Also do what the guy above me said lol
jcotton42
jcotton4215mo ago
You also need message content enabled in the bot portal
Accord
Accord15mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts