added /kick and /ban commands by doomed-neko · Pull Request #92 · allthingslinux/tux

Expand Up @@ -9,10 +9,54 @@ def __init__(self, bot: commands.Bot) -> None: self.bot = bot
@app_commands.command(name="ban", description="Bans a user from the server.") async def ban(self, interaction: discord.Interaction) -> None: logger.info(f"{interaction.user} used the ban command in {interaction.channel}.") @app_commands.describe(member="Which member to ban", reason="Reason to ban member") async def ban( self, interaction: discord.Interaction, member: discord.Member, reason: str | None = None ) -> None: logger.info( f"{interaction.user} used the ban command in {interaction.channel} to ban user {member.display_name}." )
await interaction.response.send_message("Ban command is not implemented yet.") try: await member.ban() except discord.errors.Forbidden as e: embed_error = discord.Embed( colour=discord.Colour.red(), title=f"Failed to ban {member.display_name}", description=f"`Error info: {e}`", timestamp=interaction.created_at, ) embed_error.set_footer( text=f"Requested by {interaction.user.display_name}", icon_url=interaction.user.display_avatar, ) await interaction.response.send_message(embed=embed_error) return
embed: discord.Embed = discord.Embed( title=f"Banned {member.display_name}!", color=discord.Colour.gold(), timestamp=interaction.created_at, type="rich", )
embed.add_field( name="Reason", value="`none provided`" if not reason else f"`{reason}`", inline=True, ) embed.add_field( name="User", value=f"<@{member.id}>", inline=True, )
embed.set_footer( text=f"Requested by {interaction.user.display_name}", icon_url=interaction.user.display_avatar, )
await interaction.response.send_message(embed=embed)

async def setup(bot: commands.Bot) -> None: Expand Down