Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Bot(commands.Bot):
- embedlist = []
- async def on_ready(self):
- print('Logged on as ', self.user)
- async def on_message(self, msg):
- # Adding DMs to modmail list
- if msg.type == discord.ChannelType.private:
- add_to_embedlist(msg.author, msg.created_at, msg.content)
- await msg.channel.send("Your request has been received")
- await bot.process_commands(msg)
- @bot.command()
- async def fetch(ctx):
- for embed in embedlist:
- await ctx.send(embed)
- # Add a message to the embed list.
- def add_to_embedlist(self, author, timestamp, msg):
- for embed in self.embedlist:
- if embed.timestamp + datetime.timedelta(minutes=5) > timestamp:
- embed.add_field("Message at {}".format(timestamp), msg)
- added = True
- break
- if not added:
- new_embed = discord.Embed()
- new_embed.set_author(name=author)
- new_embed.add_field("Message at {}".format(timestamp), msg)
- embedlist.append(new_embed)
- bot = Bot("!")
- bot.run(token)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement