You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Added new `dailyfact` command that gives a random fact every day, using cool down
* Fixed some typos in README.md
* Remade the `on_command_error` event for `CommandOnCooldown`
description="This command is on a %.2fs cool down"%error.retry_after,
124
+
title="Hey, please slow down!",
125
+
description=f"You can use this command again in {f'{round(hours)} hours'ifround(hours) >0else''}{f'{round(minutes)} minutes'ifround(minutes) >0else''}{f'{round(seconds)} seconds'ifround(seconds) >0else''}.",
Copy file name to clipboardExpand all lines: cogs/fun.py
+37
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,11 @@
3
3
importrandom
4
4
importsys
5
5
6
+
importaiohttp
6
7
importdiscord
7
8
importyaml
8
9
fromdiscord.extimportcommands
10
+
fromdiscord.ext.commandsimportBucketType
9
11
10
12
ifnotos.path.isfile("config.yaml"):
11
13
sys.exit("'config.yaml' not found! Please add it and try again.")
@@ -18,6 +20,41 @@ class Fun(commands.Cog, name="fun"):
18
20
def__init__(self, bot):
19
21
self.bot=bot
20
22
23
+
"""
24
+
Why 1 and 86400?
25
+
-> Because the user should be able to use the command *once* every *86400* seconds
26
+
27
+
Why BucketType.user?
28
+
-> Because the cool down only affects the current user, if you want other types of cool downs, here are they:
29
+
- BucketType.default for a global basis.
30
+
- BucketType.user for a per-user basis.
31
+
- BucketType.server for a per-server basis.
32
+
- BucketType.channel for a per-channel basis.
33
+
"""
34
+
35
+
@commands.command(name="dailyfact")
36
+
@commands.cooldown(1, 86400, BucketType.user)
37
+
asyncdefdailyfact(self, context):
38
+
"""
39
+
Get a daily fact, command can only be ran once every day per user.
40
+
"""
41
+
# This will prevent your bot from stopping everything when doing a web request - see: https://discordpy.readthedocs.io/en/stable/faq.html#how-do-i-make-a-web-request
0 commit comments