Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>discord4py Code SnippetsNew to Visual Studio Code? Get it now.
discord4py Code Snippets

discord4py Code Snippets

eudach

|
884 installs
| (0) | Free
Code snippets for the library discord4py(discord-message-components)
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

-> Informations <-

This is just a code snippet that is developed for the discord4py python library.



Change Logs

[ 0.7.0 ] - 2023/04/15

❌ Removed the snippet get (it became obsolete)
✅ Fixed a problem with the snippet %errorcmd
✅ Fixed a problem with the snippet %cog
✅ Fixed a problem with the snippet %emb, %embauthor

Usage

Specials

Name Description Prefixes
Basic bot Create a basic bot %bot
Advanced bot Create an advanced bot %bot_advanced
Help command The help command for the bot in main file %help
Cog Create a cog %cog
Command cooldown Set the cooldown of a command %cooldown
Member has role to command Check if the caller has the specified role %cmdhasrole
Command Error decorator Create a custom response to a command error %errorcmd
Wait for Wait for the event of a certain member %wait

Components

Name Description Prefixes
Button Create a button %button
SelectMenu Create a SelectMenu %selectmenu
Modal Create a Modal %modal

Outside of a cog

Name Description Prefixes
Command A complete command %cmd
Basic command Just a basic command %cmdb
Slash command Application/Slash command %slash
Check Create a check %check
Base event Event base %event
Member evets Containing various member events %event_member
Guild events Containing various guild events %event_guild
Message events Containing various events %event_message
Event button is pressed Event when a button is pressed %button_click
Event selectmenu is selected Event when select an option %selectmenu_select
Event modal is sended Event when a bot modal is sent %modal_send

Inside a cog

Name Description Prefixes
Command A complete command %cgcmd
Basic command Just a basic command %cgcmdb
Slash command Application/Slash command %cgslash
Check Create a check %cgcheck
Base event Event base %cgevent
Member evets Containing various member events %cgevent_member
Guild events Containing various guild events %cgevent_guild
Message events Containing various events %cgevent_message
Event button is pressed Event when a button is pressed %cgbutton_click
Event selectmenu is selected Event when select an option %cgselectmenu_select
Event modal is sended Event when a bot modal is sent %cgmodal_send

Embed

Name Description Prefixes
Embed base Create a embed %emb
Embed author Put the author in the embed %embauthor
Embed Field Add a field to an embed %embfield
Embed image Set an image for an embed %embimg
Embed thumbail Set a thumbnail for an embed %embthum
Embed footer Put a footer for an embed %embfoot

Examples

#Command
@bot.command()
async def pong(ctx):
    #Wait for
    try:
        message = bot.wait_for("message", check= lambda interaction: interaction.author.id == ctx.author.id and interaction.channel.id == ctx.channel.id, timeout=30)
    except asyncio.TimeoutError:
        return await ctx.send("You took too long to reply")

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft