mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
Fixed a bug that would prevent a bot on the whitelist processing the message.
This commit is contained in:
parent
f9c6702108
commit
4aef891312
5 changed files with 59 additions and 9 deletions
|
|
@ -29,8 +29,7 @@ namespace ServerManagerTool.DiscordBot.Services
|
|||
private async Task OnMessageReceivedAsync(SocketMessage s)
|
||||
{
|
||||
// Ensure the message is from a user/bot
|
||||
var msg = s as SocketUserMessage;
|
||||
if (msg is null)
|
||||
if (!(s is SocketUserMessage msg))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -41,10 +40,15 @@ namespace ServerManagerTool.DiscordBot.Services
|
|||
return;
|
||||
}
|
||||
|
||||
// Tell bot to ignore itself, unless on the whitelist
|
||||
if (msg.Author.IsBot && !_botWhitelist.DiscordBotWhitelists.Any(b => b.BotId.Equals(msg.Author.Id)))
|
||||
// check if the author is a bot
|
||||
if (msg.Author.IsBot)
|
||||
{
|
||||
return;
|
||||
// check if bot is on the whitelist
|
||||
if (!_botWhitelist.DiscordBotWhitelists.Any(b => b.BotId.Equals(msg.Author.Id.ToString())))
|
||||
{
|
||||
// Tell bot to ignore
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Create the command context
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue