Reminder

Bases: Cog

Class that holds reminder commands This class extends commands.Cog from discord.

Parameters:
  • bot

    Discord API client

  • logger

    Logger object for logging purposes

Attributes:
  • bot

    Discord API client

  • logger

    Logger object for logging purposes

  • hidden (bool) –

    Attribute that determines if this list of command should show in the help command or not. If false, will show in help.

  • __cog_name__ (str) –

    Command designation for the help command

Source code in /Users/caoma/Documents/Programming/GIT/SkyWizz/skywizz/cogs/reminder_commands.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
class Reminder(commands.Cog):
    """
        Class that holds reminder commands
        This class extends `commands.Cog` from discord.

        Args:
            bot: Discord API client
            logger: Logger object for logging purposes

        Attributes:
            bot: Discord API client
            logger: Logger object for logging purposes
            hidden (bool): Attribute that determines if this list of
                     command should show in the help command or not.
                     If `false`, will show in help.
            __cog_name__ (str): Command designation for the help command
    """

    def __init__(self, bot, logger):
        self.bot = bot
        self.logger = logger
        self.hidden = False
        self.__cog_name__ = "Reminder Commands"
        self.logger.info(f"Loaded {self.__cog_name__}")

    @commands.cooldown(2, 30, commands.BucketType.user)
    @commands.command(name='remindme')
    async def remindme_command(self, ctx, duration: int, *, message: str):
        """
        Command that sets a reminder for a specified duration from now.

        Args:
            duration: The duration of the reminder in minutes.
            message: The message to send as a reminder.

        Example:
            `!remindme 10 Take a break`
        """
        reminder_time = datetime.datetime.utcnow() + datetime.timedelta(
            minutes=duration)

        embed = embd.newembed(title=f"Reminder: {message}",
                              description=f"Set for {reminder_time.strftime('%Y-%m-%d %H:%M:%S')} UTC.",
                              )
        embed.set_footer(text="Reminder set by {}".format(ctx.author.display_name))
        await ctx.send(embed=embed)

        await asyncio.sleep(duration * 60)
        feedback_embed = embd.newembed(title="Reminder",
                                       description=f"{message}")
        feedback_embed.set_footer(text="Reminder sent by {}".format(self.bot.user.display_name))
        await ctx.author.send(embed=feedback_embed)

remindme_command(ctx, duration, *, message) async

Command that sets a reminder for a specified duration from now.

Parameters:
  • duration (int) –

    The duration of the reminder in minutes.

  • message (str) –

    The message to send as a reminder.

Example

!remindme 10 Take a break

/Users/caoma/Documents/Programming/GIT/SkyWizz/skywizz/cogs/reminder_commands.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
@commands.cooldown(2, 30, commands.BucketType.user)
@commands.command(name='remindme')
async def remindme_command(self, ctx, duration: int, *, message: str):
    """
    Command that sets a reminder for a specified duration from now.

    Args:
        duration: The duration of the reminder in minutes.
        message: The message to send as a reminder.

    Example:
        `!remindme 10 Take a break`
    """
    reminder_time = datetime.datetime.utcnow() + datetime.timedelta(
        minutes=duration)

    embed = embd.newembed(title=f"Reminder: {message}",
                          description=f"Set for {reminder_time.strftime('%Y-%m-%d %H:%M:%S')} UTC.",
                          )
    embed.set_footer(text="Reminder set by {}".format(ctx.author.display_name))
    await ctx.send(embed=embed)

    await asyncio.sleep(duration * 60)
    feedback_embed = embd.newembed(title="Reminder",
                                   description=f"{message}")
    feedback_embed.set_footer(text="Reminder sent by {}".format(self.bot.user.display_name))
    await ctx.author.send(embed=feedback_embed)