Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1. class Bot(commands.Bot):
  2.  
  3.     embedlist = []
  4.  
  5.     async def on_ready(self):
  6.         print('Logged on as ', self.user)
  7.  
  8.     async def on_message(self, msg):
  9.         # Adding DMs to modmail list
  10.         if msg.type == discord.ChannelType.private:
  11.             add_to_embedlist(msg.author, msg.created_at, msg.content)
  12.             await msg.channel.send("Your request has been received")
  13.  
  14.         await bot.process_commands(msg)
  15.  
  16.  
  17.     @bot.command()
  18.     async def fetch(ctx):
  19.         for embed in embedlist:
  20.             await ctx.send(embed)
  21.  
  22.    
  23.     # Add a message to the embed list.
  24.     def add_to_embedlist(self, author, timestamp, msg):
  25.         for embed in self.embedlist:
  26.             if embed.timestamp + datetime.timedelta(minutes=5) > timestamp:
  27.                 embed.add_field("Message at {}".format(timestamp), msg)
  28.                 added = True
  29.                 break
  30.         if not added:
  31.             new_embed = discord.Embed()
  32.             new_embed.set_author(name=author)
  33.             new_embed.add_field("Message at {}".format(timestamp), msg)
  34.             embedlist.append(new_embed)
  35.  
  36. bot = Bot("!")
  37. bot.run(token)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement