import discord
from discord.ext import commands
from discord.app import Option # alpha
bot = commands.Bot()
@bot.user_command(name="Wow these can have spaces", description="This created a global user command")
async def coolname(ctx, member:discord.Member):
await ctx.send(f"You chose {member.mention}!")
@bot.message_command(name="Reapeat", description="This created a global message command")
async def coolname(ctx, message:discord.Message):
await ctx.send(f"You said: {message.content}")
Last active
September 6, 2021 16:17
-
-
Save BruceCodesGithub/f448844d32b4f648672fdb7c03f7b8d1 to your computer and use it in GitHub Desktop.
Application Commands Examples 101
import discord
from discord.ext import commands
from discord.app import Option # alpha
bot = commands.Bot()
bot.slash_command(name="hello", description="Say hello to a user", guild_ids=[...])
async def hello(ctx, text:Option(str, 'description'), user:Option(discord.user, 'Choose a user', required=False)):
await ctx.send("Hello, {user.mention}!", ephemeral=True, allowed_mentions=discord.AllowedMentions.none())
import discord
from discord.ext import commands
from discord.app import Option # alpha
bot = commands.Bot()
greet = discord.command_group(name="greet", description="Greet related commands", guild_ids=[...])
greet.command(name="hello", description="Say hello to a user")
async def hello(ctx, text:Option(str, 'description'), user:Option(discord.user, 'Choose a user', required=False)):
await ctx.send("Hello, {user.mention}!", ephemeral=True, allowed_mentions=discord.AllowedMentions.none())
Also discord.user
should be discord.User
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bot.command_group
notdiscord.command_group