mirror of
https://github.com/Lilac-Rose/Lacie.git
synced 2026-04-25 07:29:06 -05:00
added /help with a category dropdown that covers all non-mod commands, also user's avatar fading in from the left side at an angle. went through every file and fixed pylance errors - Optional type hints on params that default to None, made cog_unload async everywhere, added isinstance guards before accessing Member-only attributes, and narrowed get_channel() return types before calling send(). birthday list now removes db entries for users who have left the server when someone queries a month.
62 lines
2.4 KiB
Python
62 lines
2.4 KiB
Python
import discord
|
|
from discord.ext import commands
|
|
from discord.ui import View, Button
|
|
from .loader import ModerationBase
|
|
|
|
class KickCommand(ModerationBase):
|
|
@commands.command(name="kick")
|
|
@ModerationBase.is_admin()
|
|
async def kick(self, ctx, user: discord.Member, *, reason: str | None = None):
|
|
"""Kick a user with confirmation and log infraction"""
|
|
view = View(timeout=30)
|
|
confirmed = {"value": False}
|
|
|
|
async def yes_callback(interaction: discord.Interaction):
|
|
if interaction.user != ctx.author:
|
|
await interaction.response.send_message("You can't confirm this action.", ephemeral=True)
|
|
return
|
|
confirmed["value"] = True
|
|
await interaction.response.edit_message(content="✅ Confirmed.", view=None)
|
|
view.stop()
|
|
|
|
async def no_callback(interaction: discord.Interaction):
|
|
if interaction.user != ctx.author:
|
|
await interaction.response.send_message("You can't cancel this action.", ephemeral=True)
|
|
return
|
|
confirmed["value"] = False
|
|
await interaction.response.edit_message(content="❌ Cancelled.", view=None)
|
|
view.stop()
|
|
|
|
yes_button = Button(label="Yes", style=discord.ButtonStyle.green)
|
|
no_button = Button(label="No", style=discord.ButtonStyle.red)
|
|
yes_button.callback = yes_callback
|
|
no_button.callback = no_callback
|
|
view.add_item(yes_button)
|
|
view.add_item(no_button)
|
|
|
|
await ctx.send(f"Are you sure you want to kick {user.mention}? Reason: {reason or 'No reason provided'}", view=view)
|
|
await view.wait()
|
|
if not confirmed["value"]:
|
|
return
|
|
|
|
if not ctx.guild:
|
|
return
|
|
|
|
try:
|
|
await user.send(f"You have been **kicked** from **{ctx.guild.name}**.\nReason: {reason or 'No reason provided'}")
|
|
except Exception:
|
|
await ctx.send("Could not DM the user.")
|
|
|
|
await ctx.guild.kick(user, reason=reason)
|
|
await ctx.send(f"{user.mention} has been kicked.")
|
|
await self.log_infraction(ctx.guild.id, user.id, ctx.author.id, "kick", reason)
|
|
|
|
# Log to logging system
|
|
logger = self.bot.get_cog("Logger")
|
|
if logger:
|
|
await logger.log_moderation_action(
|
|
ctx.guild.id, "kick", user, ctx.author, reason
|
|
)
|
|
|
|
async def setup(bot: commands.Bot):
|
|
await bot.add_cog(KickCommand(bot)) |