Skip to content
This repository was archived by the owner on May 25, 2021. It is now read-only.

Commit 063def0

Browse files
author
dragdev
committed
Make it so commands don't transmit across rifts
Signed-off-by: dragdev <samueljohnnicholson@gmail.com>
1 parent 0b599d9 commit 063def0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

riftgun/cog.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,11 @@ async def close_rift(self, ctx: commands.Context, notify: Optional[bool]=True, *
138138
@commands.Cog.listener(name="on_message")
139139
async def message(self, message: discord.Message):
140140
context: commands.Context = await self.bot.get_context(message)
141-
if message.author == self.bot.user: return # only ignore the current bot to prevent loops.
142-
elif context.command:
143-
if context.command.name == "close":
144-
return
141+
if message.author == self.bot.user:
142+
return # only ignore the current bot to prevent loops.
143+
elif context.valid:
144+
return
145+
145146
sources = {}
146147
targets = {}
147148
sid = message.channel.id
@@ -168,6 +169,7 @@ async def channel_info(self, ctx: commands.Context, *, channel: GlobalTextChanne
168169
"""Shows you information on a channel before you open a rift in it
169170
170171
This should be used to make sure you got the right channel before opening."""
172+
channel: discord.TextChannel
171173
nsfw = channel.is_nsfw()
172174
ago = channel.created_at.strftime("%c") + " " + humanize.naturaltime(channel.created_at)
173175
e = discord.Embed(
@@ -183,6 +185,8 @@ async def cog_command_error(self, ctx, error):
183185
error = getattr(error, "original", error)
184186
if isinstance(error, commands.BadArgument):
185187
return await ctx.send(f"Argument conversion error (an invalid argument was passed): `{error}`")
188+
elif isinstance(error, commands.MissingRequiredArgument):
189+
return await ctx.send(str(error))
186190
print(f"Exception raised in command {ctx.command}:", error, error.__traceback__, file=sys.stderr)
187191
return await ctx.send(f"\N{cross mark} an error was raised, and printed to console. If the issue persists,"
188192
f" please open an issue on github (<https://github.com/dragdev-studios/RiftGun/issues/new>)")

0 commit comments

Comments
 (0)