Advertisement
Techniker357

Untitled

Dec 15th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.62 KB | None | 0 0
  1. @bot.command()
  2. async def to(ctx, channel: str, limit_or_after_id: int, before_id: int = 0):
  3.     if len(ctx.message.channel_mentions) == 1:
  4.         if limit_or_after_id > 25 and before_id != 0:
  5.             before_message = await ctx.channel.fetch_message(before_id)
  6.             after_message = await ctx.channel.fetch_message(limit_or_after_id)
  7.             messages = [
  8.                 before_message,
  9.                 *(
  10.                     await ctx.history(
  11.                         limit=25, before=before_message, after=after_message
  12.                     ).flatten()
  13.                 ),
  14.                 after_message,
  15.             ]
  16.         elif limit_or_after_id > 25 and before_id == 0:
  17.             await ctx.send(f"You can't redirect more than 25 messages in one time!")
  18.         else:
  19.             messages = await ctx.history(limit=limit_or_after_id + 1).flatten()
  20.             messages.reverse()
  21.  
  22.         embed = discord.Embed(
  23.             title="Messages Redirected",
  24.             type="rich",
  25.             description=f"Source Channel: #{ctx.channel.name}",
  26.         )
  27.         for message in messages:
  28.             embed.add_field(
  29.                 name=f"{message.author.name}#{message.author.discriminator} ({message.author.nick})",
  30.                 value=message.content if message.content else "<Unsupported Content>",
  31.                 inline=False,
  32.             )
  33.             embed.set_image(url = message.attachments[1].url)
  34.         await ctx.message.channel_mentions[0].send(embed=embed)
  35.         await ctx.channel.delete_messages(messages)
  36.     else:
  37.         await ctx.send(f"Channels must be mentioned like `#{channel}`")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement