Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion bot/exts/easter/easter_riddle.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import discord
from discord.ext import commands

from bot.constants import Colours
from bot.constants import Colours, NEGATIVE_REPLIES

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -36,6 +36,17 @@ async def riddle(self, ctx: commands.Context) -> None:
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
Comment thread
ChrisLovering marked this conversation as resolved.

self.current_channel = ctx.message.channel

random_question = random.choice(RIDDLE_QUESTIONS)
Expand Down
38 changes: 35 additions & 3 deletions bot/exts/evergreen/issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@
import discord
from discord.ext import commands, tasks

from bot.constants import Categories, Channels, Colours, ERROR_REPLIES, Emojis, Tokens, WHITELISTED_CHANNELS
from bot.constants import (
Categories,
Channels,
Colours,
ERROR_REPLIES,
Emojis,
NEGATIVE_REPLIES,
Tokens,
WHITELISTED_CHANNELS
)

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -150,10 +159,20 @@ async def issue(
user: str = "python-discord"
) -> None:
"""Command to retrieve issue(s) from a GitHub repository."""
if not(
if not ctx.guild or not(
ctx.channel.category.id in WHITELISTED_CATEGORIES
or ctx.channel.id in WHITELISTED_CHANNELS
):
await ctx.send(
embed=discord.Embed(
title=random.choice(NEGATIVE_REPLIES),
description=(
"You can't run this command in this channel. "
f"Try again in <#{Channels.community_bot_commands}>"
),
colour=discord.Colour.red()
)
)
return

result = await self.fetch_issues(set(numbers), repository, user)
Expand All @@ -180,7 +199,8 @@ async def issue(
@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 not in whitelisted categories / channels, only when in guild.
if message.guild and not (
message.channel.category.id in WHITELISTED_CATEGORIES
or message.channel.id in WHITELISTED_CHANNELS_ON_MESSAGE
):
Expand All @@ -190,6 +210,18 @@ async def on_message(self, message: discord.Message) -> None:
links = []

if message_repo_issue_map:
if not message.guild:
await message.channel.send(
embed=discord.Embed(
title=random.choice(NEGATIVE_REPLIES),
description=(
"You can't retreive issues from DMs. "
f"Try again in <#{Channels.community_bot_commands}>"
),
colour=discord.Colour.red()
)
)
return
for repo_issue in message_repo_issue_map:
if not self.check_in_block(message, " ".join(repo_issue)):
result = await self.fetch_issues({repo_issue[1]}, repo_issue[0], "python-discord")
Expand Down
3 changes: 2 additions & 1 deletion bot/exts/evergreen/wolfram.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ async def predicate(ctx: Context) -> bool:
# 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):
Comment thread
ChrisLovering marked this conversation as resolved.
Comment thread
HassanAbouelela marked this conversation as resolved.
return guild_cooldown and not usercd.get_bucket(ctx.message).get_tokens() == 0
return guild_cooldown

Expand Down
3 changes: 3 additions & 0 deletions bot/exts/halloween/candy_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def __init__(self, bot: commands.Bot):
@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
Expand Down