/
application_commands.py
73 lines (66 loc) · 2.69 KB
/
application_commands.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import pycord
# start the bot with no intents, and with default config
bot = pycord.Bot(intents=pycord.Intents())
# the guild id to deploy on. Often used for developing to
# avoid having to wait the extraneous amount of time Discord has for global
# commands
GUILD_ID: int | pycord.MissingEnum = pycord.MISSING
# make a chat input command which
# is named favorite and that displays
# an autocompleted list of animes to pick from
@bot.command(guild_id=GUILD_ID)
# make a function for what to do once the user
# has completed their input.
# this has the option anime, displayed as a Parameter,
# which is parsed by Pycord to give you the information the user gave.
async def favorite(
ctx: pycord.Context,
# The name of this option,
# can be set to anything but
# try to keep it short
anime: str = pycord.Option(
# The description for this option,
# this is a longer version of name displaying
# more detail and technicalities
description='Your favorite Anime Show',
# this just sets it so the user cannot proceed without
# entering this option
required=True,
# enables autocomplete on Discord's side
autocomplete=True,
# these are the choices the user can pick.
# the first value is the name, which is what
# the user will see. The second is the value, which is what
# you, or the bot, will see.
choices=[
pycord.CommandChoice('Attack on Titan'),
pycord.CommandChoice("JoJo's Bizzare Adventure"),
pycord.CommandChoice('Cowboy Bebop'),
pycord.CommandChoice('Hunter x Hunter'),
pycord.CommandChoice('Spy x Family'),
],
),
):
"""Pick which one is your favorite anime"""
# checks the value of the int
# and if it matches up to an anime,
# it responds with a custom response.
match anime:
case 'Attack on Titan':
await ctx.send('It seems like you like Attack on Titan, Nice!')
case "JoJo's Bizzare Adventure":
await ctx.send("おにいちゃんありがとう. You like JoJo's Bizzare Adventure. Nice!")
case 'Cowboy Bebop':
await ctx.send('良い!あなたはカウボーイビバップが好きです')
case 'Hunter x Hunter':
await ctx.send(
'I ran out of responses... Well anyway, you like Hunter x Hunter which is Nice!'
)
case 'Spy x Family':
await ctx.send(
'I have a friend which really likes this anime, '
"it's good seeing you like it too. Of course, Spy x Family!"
)
# run the bot with the token.
# PLEASE REMEMBER TO CHANGE!
bot.run('token')