diff --git a/cogs/events.py b/cogs/events.py index 009e880..ee0297f 100644 --- a/cogs/events.py +++ b/cogs/events.py @@ -111,11 +111,13 @@ class Events(commands.Cog): # Someone used a command that was on cooldown elif isinstance(err, commands.CommandOnCooldown): await ctx.send("Je kan dit commando niet (meer) spammen.", delete_after=10) + elif isinstance(err, commands.MessageNotFound): + await ctx.send("Geen message gevonden die overeenkomt met het opgegeven argument.") + elif isinstance(err, (commands.ChannelNotFound, commands.ChannelNotReadable)): + await ctx.send("Geen channel gevonden dat overeenkomt met het opgegeven argument.") # Someone forgot an argument or passed an invalid argument elif isinstance(err, (commands.BadArgument, commands.MissingRequiredArgument)): await ctx.send("Controleer je argumenten.") - elif isinstance(err, commands.MessageNotFound): - await ctx.send("Geen bericht gevonden dat overeenkomt met het opgegeven argument.") else: # Remove the InvokeCommandError because it's useless information x = traceback.format_exception(type(err), err, err.__traceback__) diff --git a/cogs/reactword.py b/cogs/reactword.py index 7c879b1..b48e59a 100644 --- a/cogs/reactword.py +++ b/cogs/reactword.py @@ -19,25 +19,16 @@ class ReactWord(commands.Cog): @help.Category(category=Category.Other) async def react(self, ctx, *words): words = list(words) + message = ctx.message target = False - channel = ctx.channel - # Check if the URL or the Id was passed - if str(words[-1]).count("/") > 3: - spl = str(words[-1]).split("/") - channel = self.client.get_channel(int(spl[-2])) - if channel is None: - return await ctx.send("Ik kan geen kanaal zien met dit id.") - words[-1] = spl[-1] - - # Get the message object if an Id was passed, otherwise react to the message itself - try: - message = await channel.fetch_message(words[-1]) - if message is None: - return await ctx.send("Ik kan geen bericht zien met dit id.") + # Message id or URL passed as final argument + if (len(words[-1]) == 18 and all(i.isdigit() for i in words[-1])) or "discord.com/channels/" in words[-1]: target = True - except discord.HTTPException: - message = ctx.message + message = await commands.MessageConverter().convert(ctx, words[-1]) + + # Cut id or URL + words = words[:-1] # Reactions that were added before this command was executed previousReactions = ([x.emoji for x in message.reactions]) if len(message.reactions) != 0 else []