Created
October 22, 2022 01:17
-
-
Save sonyakun/c684a79eba27a1e47df76b54915d7bb8 to your computer and use it in GitHub Desktop.
pycordの比較用
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from discord.commands import Option | |
import discord | |
bot = discord.Bot() | |
COLORS = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'] | |
async def get_colors(ctx): | |
return [color for color in COLORS if color.startswith(ctx.value)] | |
@bot.slash_command(guild_ids=[...]) | |
async def color( | |
ctx, | |
color: Option(str, '色を選択してください', autocomplete=get_colors), | |
): | |
await ctx.respond(f'{color}が選択されました') | |
bot.run('DISCORD_BOT_TOKEN') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment