File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 1
1
import discord
2
2
3
- bot = discord .Bot ()
3
+ bot = discord .Bot ()
4
+
5
+ # If you use commands.Bot, @bot.slash_command should be used for
6
+ # slash commands. You can use @bot.slash_command with discord.Bot aswell
4
7
5
8
6
9
@bot .command (guild_ids = [...]) # create a slash command for the supplied guilds
7
10
async def hello (ctx ):
8
11
"""Say hello to the bot""" # the command description can be supplied as the docstring
9
- await ctx .respond (f"Hello { ctx .author } !" )
12
+ await ctx .send (f"Hello { ctx .author } !" )
10
13
11
- @bot .command (name = 'global ' ) # creates a global slash command (might take an hour to register)
14
+ @bot .command (name = 'hi ' ) # Not passing in guild_ids creates a global slash command (might take an hour to register)
12
15
async def global_command (ctx , num : int ): # Takes one integer parameter
13
- await ctx .respond (f"This is a global command, { num } !" )
16
+ await ctx .send (f"This is a global command, { num } !" )
17
+
18
+ @bot .command (guild_ids = [...])
19
+ async def joined (ctx , member : discord .Member = None ): # Passing a default value makes the argument optional
20
+ user = member or ctx .author
21
+ await ctx .send (f'{ user .name } joined at { discord .utils .format_dt (user .joined_at )} ' )
14
22
15
23
bot .run ("TOKEN" )
You can’t perform that action at this time.
0 commit comments