aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Chris <[email protected]>2021-02-05 19:17:59 +0000
committerGravatar Chris <[email protected]>2021-02-05 19:17:59 +0000
commit0d5da9e1304865034e8a2349d33b132e149ad890 (patch)
treee39b5f94a79c98cc121d0b97714ead21fe96c5cb
parentMerge pull request #572 from Shivansh-007/feature/cheat.sh (diff)
First pass of easy to produce errors
-rw-r--r--bot/exts/easter/easter_riddle.py13
-rw-r--r--bot/exts/evergreen/issues.py7
-rw-r--r--bot/exts/evergreen/wolfram.py3
-rw-r--r--bot/exts/halloween/candy_collection.py3
4 files changed, 23 insertions, 3 deletions
diff --git a/bot/exts/easter/easter_riddle.py b/bot/exts/easter/easter_riddle.py
index 3c612eb1..a93b3745 100644
--- a/bot/exts/easter/easter_riddle.py
+++ b/bot/exts/easter/easter_riddle.py
@@ -7,7 +7,7 @@ from pathlib import Path
import discord
from discord.ext import commands
-from bot.constants import Colours
+from bot.constants import Colours, NEGATIVE_REPLIES
log = logging.getLogger(__name__)
@@ -36,6 +36,17 @@ class EasterRiddle(commands.Cog):
if self.current_channel:
return await ctx.send(f"A riddle is already being solved in {self.current_channel.mention}!")
+ # Don't let users start in a DM
+ if not ctx.guild:
+ await ctx.send(
+ embed=discord.Embed(
+ title=random.choice(NEGATIVE_REPLIES),
+ description="You can't start riddles in DMs",
+ colour=discord.Colour.red()
+ )
+ )
+ return
+
self.current_channel = ctx.message.channel
random_question = random.choice(RIDDLE_QUESTIONS)
diff --git a/bot/exts/evergreen/issues.py b/bot/exts/evergreen/issues.py
index 73ebe547..1f22f287 100644
--- a/bot/exts/evergreen/issues.py
+++ b/bot/exts/evergreen/issues.py
@@ -178,7 +178,12 @@ class Issues(commands.Cog):
@commands.Cog.listener()
async def on_message(self, message: discord.Message) -> None:
"""Command to retrieve issue(s) from a GitHub repository using automatic linking if matching <repo>#<issue>."""
- if not(
+ # Ignore messages from DMs
+ if not message.guild:
+ return
+
+ # Ignore messages not in whitelisted categories / channels
+ if not (
message.channel.category.id in WHITELISTED_CATEGORIES
or message.channel.id in WHITELISTED_CHANNELS_ON_MESSAGE
):
diff --git a/bot/exts/evergreen/wolfram.py b/bot/exts/evergreen/wolfram.py
index 898e8d2a..077a99f5 100644
--- a/bot/exts/evergreen/wolfram.py
+++ b/bot/exts/evergreen/wolfram.py
@@ -62,7 +62,8 @@ def custom_cooldown(*ignore: List[int]) -> Callable:
# if the invoked command is help we don't want to increase the ratelimits since it's not actually
# invoking the command/making a request, so instead just check if the user/guild are on cooldown.
guild_cooldown = not guildcd.get_bucket(ctx.message).get_tokens() == 0 # if guild is on cooldown
- if not any(r.id in ignore for r in ctx.author.roles): # check user bucket if user is not ignored
+ # check the message is in a guild, and check user bucket if user is not ignored
+ if ctx.guild and not any(r.id in ignore for r in ctx.author.roles):
return guild_cooldown and not usercd.get_bucket(ctx.message).get_tokens() == 0
return guild_cooldown
diff --git a/bot/exts/halloween/candy_collection.py b/bot/exts/halloween/candy_collection.py
index 0cb37ecd..40e21f40 100644
--- a/bot/exts/halloween/candy_collection.py
+++ b/bot/exts/halloween/candy_collection.py
@@ -47,6 +47,9 @@ class CandyCollection(commands.Cog):
@commands.Cog.listener()
async def on_message(self, message: discord.Message) -> None:
"""Randomly adds candy or skull reaction to non-bot messages in the Event channel."""
+ # Ignore messages in DMs
+ if not message.guild:
+ return
# make sure its a human message
if message.author.bot:
return