Ad
Python 3.6 Discord Bot Cooldown Message
so I have this command which allows the user to change the game and it works perfectly but I put a 15 second cooldown on it and it too works fine, but my issue is getting it to display a message that you are in cooldown period OR if the command has successfully executed. I'm new to python and this is probably a simple fix so I apologize for wasting your time, but thx in advance
My code:
@client.command(name="status")
@commands.cooldown(1, 15, commands.BucketType.server)
async def client_status(*, status: str = None):
"""Change the bot's 'playing' status.
Running this command without any arguments will turn the 'playing' status off'
"""
game = Game(name=status)
await client.change_presence(game=game)
Ad
Answer
If a member tries to invoke a command that is currently on cooldown a CommandOnCooldown exception is thrown and triggers on_command_error.
Although async does not document it there is an event on_command_completion
on_command_completion(command, ctx)
this is dispatched if a command has successfully completed its invocation.
Ad
source: stackoverflow.com
Related Questions
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Can't turn off Javascript using Selenium
- → WebDriver click() vs JavaScript click()
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module
Ad