Fixed a bug that would prevent a bot on the whitelist processing the message.

This commit is contained in:
Brett Hewitson 2021-12-16 20:44:11 +10:00
parent f9c6702108
commit 4aef891312
5 changed files with 59 additions and 9 deletions

View file

@ -9,8 +9,8 @@
<entry>
<id>urn:uuid:3E33DCB2-ECFE-4489-B1A4-56F5D386F9DC</id>
<title>1.1.413 (1.1.413.3)</title>
<summary>1.1.413.3</summary>
<title>1.1.413 (1.1.413.4)</title>
<summary>1.1.413.4</summary>
<link href="" />
<updated>2021-12-16T00:00:00Z</updated>
<content type="xhtml">

View file

@ -7,6 +7,29 @@
<link href="http://arkservermanager.freeforums.net/" />
<updated>2021-12-16T00:00:00Z</updated>
<entry>
<id>urn:uuid:98FFBFA1-4E99-4801-BF2B-CA68BE300C27</id>
<title>1.1.413 (1.1.413.4)</title>
<summary>1.1.413.4</summary>
<link href="" />
<updated>2021-12-16T00:00:00Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
<p>
<u style="font-size: .9em;">BUGFIX</u>
<br/>
<ul>
<li>Fixed a bug that would prevent a bot on the whitelist processing the message.</li>
</ul>
</p>
</div>
</content>
<author>
<name>bletch</name>
<email>bletch1971@hotmail.com</email>
</author>
</entry>
<entry>
<id>urn:uuid:8958A494-DE13-4F6F-ACA2-10026D5FB8A9</id>
<title>1.1.413 (1.1.413.3)</title>

View file

@ -9,8 +9,8 @@
<entry>
<id>urn:uuid:19B09A66-43F2-4D5F-AF33-5C77D7EA9A6B</id>
<title>1.1.58 (1.1.58.3)</title>
<summary>1.1.58.3</summary>
<title>1.1.58 (1.1.58.4)</title>
<summary>1.1.58.4</summary>
<link href="" />
<updated>2021-12-16T00:00:00Z</updated>
<content type="xhtml">

View file

@ -7,6 +7,29 @@
<link href="http://servermanagers.freeforums.net/" />
<updated>2021-12-16T00:00:00Z</updated>
<entry>
<id>urn:uuid:F3C22842-A089-46F7-AB1A-5D3DED105412</id>
<title>1.1.58 (1.1.58.4)</title>
<summary>1.1.58.4</summary>
<link href="" />
<updated>2021-12-16T00:00:00Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
<p>
<u style="font-size: .9em;">BUGFIX</u>
<br/>
<ul>
<li>Fixed a bug that would prevent a bot on the whitelist processing the message.</li>
</ul>
</p>
</div>
</content>
<author>
<name>bletch</name>
<email>bletch1971@hotmail.com</email>
</author>
</entry>
<entry>
<id>urn:uuid:F3C22842-A089-46F7-AB1A-5D3DED105412</id>
<title>1.1.58 (1.1.58.3)</title>

View file

@ -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