Skip to content

Commit baffeff

Browse files
committed
feat: support autocomplete
1 parent a686324 commit baffeff

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

chiya/cogs/kick.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
from chiya.utils.helpers import can_action_member, log_embed_to_channel
1010

1111

12+
async def reasons(
13+
interaction: discord.Interaction,
14+
current: str,
15+
) -> list[app_commands.Choice[str]]:
16+
reasons = ("Compromised or hacked account", "Spam")
17+
return [app_commands.Choice(name=reason, value=reason) for reason in reasons if current.lower() in reason.lower()]
18+
19+
1220
class KickCog(commands.Cog):
1321
def __init__(self, bot: commands.Bot) -> None:
1422
self.bot = bot
@@ -17,6 +25,7 @@ def __init__(self, bot: commands.Bot) -> None:
1725
@app_commands.guilds(config.guild_id)
1826
@app_commands.describe(user="The member that will be kicked")
1927
@app_commands.describe(reason="The reason why the member is being kicked")
28+
@app_commands.autocomplete(reason=reasons)
2029
async def kick(self, ctx: discord.Interaction, user: discord.User | discord.Member, reason: str) -> None:
2130
"""
2231
Kick the member, log the action to the database, and attempt to send
@@ -55,7 +64,7 @@ async def kick(self, ctx: discord.Interaction, user: discord.User | discord.Memb
5564
user_embed.color = discord.Color.blurple()
5665
user_embed.add_field(name="Server:", value=ctx.guild.name, inline=True)
5766
user_embed.add_field(name="Reason:", value=reason, inline=False)
58-
user_embed.set_image(url="https://files.catbox.moe/8weubv.gif")
67+
user_embed.set_image(url="https://files.catbox.moe/nyla1m.gif")
5968

6069
try:
6170
await user.send(embed=user_embed)
@@ -81,6 +90,7 @@ async def kick(self, ctx: discord.Interaction, user: discord.User | discord.Memb
8190
@app_commands.describe(user="The member that will be kicked")
8291
@app_commands.describe(reason="The reason why the member is being kicked")
8392
@app_commands.describe(daystodelete="Days worth of messages to delete from the member, up to 7")
93+
@app_commands.autocomplete(reason=reasons)
8494
async def purgekick(
8595
self,
8696
ctx: discord.Interaction,
@@ -129,7 +139,7 @@ async def purgekick(
129139
user_embed.color = discord.Color.blurple()
130140
user_embed.add_field(name="Server:", value=ctx.guild.name, inline=True)
131141
user_embed.add_field(name="Reason:", value=reason, inline=False)
132-
user_embed.set_image(url="https://files.catbox.moe/8weubv.gif")
142+
user_embed.set_image(url="https://files.catbox.moe/nyla1m.gif")
133143

134144
try:
135145
await user.send(embed=user_embed)

0 commit comments

Comments
 (0)