Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @bot.command()
- async def to(ctx, channel: str, limit_or_after_id: int, before_id: int = 0):
- if len(ctx.message.channel_mentions) == 1:
- if limit_or_after_id > 25 and before_id != 0:
- before_message = await ctx.channel.fetch_message(before_id)
- after_message = await ctx.channel.fetch_message(limit_or_after_id)
- messages = [
- before_message,
- *(
- await ctx.history(
- limit=25, before=before_message, after=after_message
- ).flatten()
- ),
- after_message,
- ]
- elif limit_or_after_id > 25 and before_id == 0:
- await ctx.send(f"You can't redirect more than 25 messages in one time!")
- else:
- messages = await ctx.history(limit=limit_or_after_id + 1).flatten()
- messages.reverse()
- embed = discord.Embed(
- title="Messages Redirected",
- type="rich",
- description=f"Source Channel: #{ctx.channel.name}",
- )
- for message in messages:
- embed.add_field(
- name=f"{message.author.name}#{message.author.discriminator} ({message.author.nick})",
- value=message.content if message.content else "<Unsupported Content>",
- inline=False,
- )
- embed.set_image(url = message.attachments[1].url)
- await ctx.message.channel_mentions[0].send(embed=embed)
- await ctx.channel.delete_messages(messages)
- else:
- await ctx.send(f"Channels must be mentioned like `#{channel}`")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement