Skip to content

Instantly share code, notes, and snippets.

@sonyakun
Created October 22, 2022 01:17
Show Gist options
  • Save sonyakun/c684a79eba27a1e47df76b54915d7bb8 to your computer and use it in GitHub Desktop.
Save sonyakun/c684a79eba27a1e47df76b54915d7bb8 to your computer and use it in GitHub Desktop.
pycordの比較用
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