From b4d95b5635faed81298f7521f26b5b1b1e4f1bd1 Mon Sep 17 00:00:00 2001 From: Mary Date: Tue, 12 Apr 2022 20:13:55 +0200 Subject: [PATCH] Fix last commit again --- robocop_ng/cogs/mod.py | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/robocop_ng/cogs/mod.py b/robocop_ng/cogs/mod.py index 8dc2622..059fa81 100644 --- a/robocop_ng/cogs/mod.py +++ b/robocop_ng/cogs/mod.py @@ -693,20 +693,12 @@ class Mod(Cog): @commands.guild_only() @commands.check(check_if_staff) @commands.command() - async def move(context): + async def move(self, ctx, channelTo: discord.TextChannel, *, limit: int): + """Move a user to another channel, staff only. - # get the content of the message - content = context.message.content.split(' ') - # if the length is not three the command was used incorrectly - if len(content) != 3 or not content[2].isnumeric(): - await context.message.channel.send("Incorrect usage of !move. Example: !move {channel to move to} {number of messages}.") - return - # channel that it is going to be posted to - channelTo = content[1] - # get the number of messages to be moved (including the command message) - numberOfMessages = int(content[2]) + 1 + !move {channel to move to} {number of messages}""" # get a list of the messages - fetchedMessages = await context.channel.history(limit=numberOfMessages).flatten() + fetchedMessages = await ctx.channel.history(limit=limit + 1).flatten() # delete all of those messages from the channel for i in fetchedMessages: @@ -718,9 +710,6 @@ class Mod(Cog): # Loop over the messages fetched for messages in fetchedMessages: - # get the channel object for the server to send to - channelTo = discord.utils.get(messages.guild.channels, name=channelTo) - # if the message is embeded already if messages.embeds: # set the embed message to the old embed object @@ -728,15 +717,15 @@ class Mod(Cog): # else else: # Create embed message object and set content to original - embedMessage = discord.Embed( - description = messages.content - ) + embedMessage = discord.Embed(description=messages.content) # set the embed message author to original author - embedMessage.set_author(name=messages.author, icon_url=messages.author.avatar_url) + embedMessage.set_author( + name=messages.author, icon_url=messages.author.avatar_url + ) # if message has attachments add them if messages.attachments: for i in messages.attachments: - embedMessage.set_image(url = i.proxy_url) + embedMessage.set_image(url=i.proxy_url) # Send to the desired channel await channelTo.send(embed=embedMessage)