commands group with cog py discord code example
Example 1: is_on_cooldown discord.py
is_on_cooldown(Context)
'''
Context is the context for the command
is_on_cooldown returns a boolean operator of if the command mentioned is on cooldown.
You need to pass_context to use it
'''
EXAMPLE:
@client.command(pass_content=True)
async def notcool(ctx):
for command in client.commands():
await ctx.channel.send(ctx.is_on_cooldown(command))
Example 2: how to make a cog discord.py
from discord.ext import commands
class Test_Cog(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
print('Bot is ready!.')
@commands.command()
async def ping(self, ctx):
await ctx.send(f'Pong! {round(self.bot.latency * 1000)}')
def setup(bot):
bot.add_cog(Test_Cog(bot))