From 1d2c7e4ee244b1eb975b8c9bda79a38a91e58bca Mon Sep 17 00:00:00 2001 From: sgoudham Date: Fri, 19 Jun 2020 00:01:08 +0100 Subject: [PATCH] Added a bump reminder command --- EnsoBot.py | 15 +++++++++++++-- cogs/Reminder.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 cogs/Reminder.py diff --git a/EnsoBot.py b/EnsoBot.py index 6819affc..e7e15ae0 100644 --- a/EnsoBot.py +++ b/EnsoBot.py @@ -1,5 +1,6 @@ import asyncio import datetime +from asyncio import sleep import discord from decouple import config @@ -17,7 +18,8 @@ client.remove_command('help') # Instantiates a list for all the cogs extensions = ['cogs.WaifuImages', 'cogs.FunCommands', 'cogs.Music', - 'cogs.HelpCommands', 'cogs.OwOText', 'cogs.Embeds', 'cogs.GetInfo'] + 'cogs.HelpCommands', 'cogs.OwOText', 'cogs.Embeds', + 'cogs.GetInfo', 'cogs.Reminder'] # Calls the cogs if __name__ == '__main__': @@ -25,6 +27,16 @@ if __name__ == '__main__': client.load_extension(ext) +@client.command() +async def remind(ctx, time=None): + author = ctx.message.author + if time: + await sleep(float(time)) + await author.send("uwu") + else: + await author.send("owo") + + # Bot Status on Discord @client.event async def on_ready(): @@ -248,7 +260,6 @@ async def on_raw_reaction_remove(payload): except Exception as ex: print(ex) - # Run the bot, allowing to come online try: client.run(API_TOKEN) diff --git a/cogs/Reminder.py b/cogs/Reminder.py new file mode 100644 index 00000000..e90998ab --- /dev/null +++ b/cogs/Reminder.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +""" +Created on Thu Jun 18 18:27:47 2020 + +@author: Lukas +""" +from datetime import datetime +from datetime import timedelta +from time import sleep + +from discord.ext import commands + + +class Reminder(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.command() + async def remindme(self, ctx): + time_left = [float(i) for i in str(datetime.now().time()).split(":")] + time_left = timedelta(hours=2) - timedelta(hours=time_left[0] % 2, minutes=time_left[1], + seconds=time_left[2]) + + sleep(round(time_left.total_seconds())) + + while True: + await ctx.send("Bump the Server Idiots") + sleep(7200) + + +def setup(bot): + bot.add_cog(Reminder(bot))