Skip to content

Commit

Permalink
Ignore forbidden exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnoyingRain5 committed May 12, 2023
1 parent 1942f28 commit 6f7bf06
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cogs/QuickResponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from discord.ext.commands import has_permissions, CheckFailure
from discord.channel import DMChannel
from discord.commands.context import ApplicationContext as SlashContext
from discord.errors import Forbidden


class QuickResponse(commands.Cog):
Expand Down Expand Up @@ -61,14 +62,20 @@ async def on_message(self, ctx):
if trigger != "":
if trigger.lower() == ctx.content.lower():
# send the response from the guild's responses
await ctx.channel.send(self.db.read()[str(ctx.guild.id)]["MessageResponses"][trigger])
try:
await ctx.channel.send(self.db.read()[str(ctx.guild.id)]["MessageResponses"][trigger])
except Forbidden:
pass

# phrase responses
for trigger in self.db.read()[str(ctx.guild.id)]["PhraseResponses"]:
if trigger != "":
if trigger in ctx.content:
# send the response from the guild's responses
await ctx.channel.send(self.db.read()[str(ctx.guild.id)]["PhraseResponses"][trigger])
try:
await ctx.channel.send(self.db.read()[str(ctx.guild.id)]["PhraseResponses"][trigger])
except Forbidden:
pass

@has_permissions(manage_guild=True)
@PhraseQuickResponseSlashGroup.command(description="Add/set a phrase response", name="add")
Expand Down

0 comments on commit 6f7bf06

Please sign in to comment.