Fix last commit again

This commit is contained in:
Mary 2022-04-12 20:13:55 +02:00 committed by TSR Berry
parent 5ee601bda5
commit b4d95b5635
No known key found for this signature in database
GPG key ID: 52353C0A4CCA15E2

View file

@ -693,20 +693,12 @@ class Mod(Cog):
@commands.guild_only() @commands.guild_only()
@commands.check(check_if_staff) @commands.check(check_if_staff)
@commands.command() @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 !move {channel to move to} {number of messages}"""
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
# get a list of the 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 # delete all of those messages from the channel
for i in fetchedMessages: for i in fetchedMessages:
@ -718,9 +710,6 @@ class Mod(Cog):
# Loop over the messages fetched # Loop over the messages fetched
for messages in fetchedMessages: 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 the message is embeded already
if messages.embeds: if messages.embeds:
# set the embed message to the old embed object # set the embed message to the old embed object
@ -728,15 +717,15 @@ class Mod(Cog):
# else # else
else: else:
# Create embed message object and set content to original # Create embed message object and set content to original
embedMessage = discord.Embed( embedMessage = discord.Embed(description=messages.content)
description = messages.content
)
# set the embed message author to original author # 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 message has attachments add them
if messages.attachments: if messages.attachments:
for i in 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 # Send to the desired channel
await channelTo.send(embed=embedMessage) await channelTo.send(embed=embedMessage)