class BanButtons(discord.ui.View): def __init__(self, bot, member: discord.Member, reason: str): super().__init__() self.bot = bot self.member = member self.reason = reason self.ban_reason_buttons = BanReasonButtons(self) self.original_message_content = None @discord.ui.button(label="Global Ban", style=discord.ButtonStyle.red) async def globalban_button(self, interaction: discord.Interaction, button: discord.ui.Button): await self.global_ban_user() embed = self.get_embed() await interaction.edit_original_message(embed=embed, view=self.ban_reason_buttons) @discord.ui.button(label="Ban", style=discord.ButtonStyle.red) async def ban_button(self, interaction: discord.Interaction, button: discord.ui.Button): await self.ban_user() embed = self.get_embed() await interaction.edit_original_message(embed=embed, view=self.ban_reason_buttons) @discord.ui.button(label="Reasons", style=discord.ButtonStyle.blurple) async def banreasons(self, interaction: discord.Interaction, button: discord.ui.Button): self.clear_items() embed = discord.Embed( title="Ban Reasons", description="Click a button to choose a reason for the ban.", colour=0x5c0000, ) embed.set_author(name="Crocodile", url="https://discord.com/users/978461641853263963", icon_url="https://cdn.discordapp.com/avatars/978461641853263963/30102d4adb39f55e90a7c6b4e2455ad3.webp?size=1024&format=webp&width=0&height=256") embed.set_image(url="https://cubedhuang.com/images/alex-knight-unsplash.webp") embed.set_thumbnail(url="https://dan.onl/images/emptysong.jpg") embed.set_footer(text="Made By Crocodile") self.add_item(discord.ui.Button(label="Reason 1", style=discord.ButtonStyle.red, custom_id="reason1_button")) self.add_item(discord.ui.Button(label="Reason 2", style=discord.ButtonStyle.red, custom_id="reason2_button")) self.add_item(discord.ui.Button(label="Reason 3", style=discord.ButtonStyle.red, custom_id="reason3_button")) self.original_message_content = await interaction.edit_original_message(embed=embed, view=self) await interaction.response.defer(ephemeral=True) async def global_ban_user(self): for guild in self.bot.guilds: try: await guild.ban(self.member, reason=self.reason) except discord.Forbidden: print(f"Failed to ban {self.member} from {guild.name}") async def ban_user(self): # Will get my ban logic soon lol pass async def set_reason(self, reason): self.reason = reason def get_embed(self): embed = discord.Embed(title="Ban", color=discord.Color.red()) embed.add_field(name="Banned Member", value=self.member.mention, inline=False) embed.add_field(name="Reason", value=self.reason, inline=False) return embed class BanReasonButtons(discord.ui.View): def __init__(self, ban_view): super().__init__() self.ban_view = ban_view @discord.ui.button(label="Reason 1", style=discord.ButtonStyle.red, custom_id="reason1_button") async def reason1_button(self, interaction: discord.Interaction, button: discord.ui.Button): await self.ban_view.set_reason("Reason 1") embed = self.ban_view.get_embed() await interaction.response.send_message(embed=embed, view=self.ban_view, ephemeral=True) @discord.ui.button(label="Reason 2", style=discord.ButtonStyle.red, custom_id="reason2_button") async def reason2_button(self, interaction: discord.Interaction, button: discord.ui.Button): await self.ban_view.set_reason("Reason 2") await interaction.response.defer(ephemeral=True) @discord.ui.button(label="Reason 3", style=discord.ButtonStyle.red, custom_id="reason3_button") async def reason3_button(self, interaction: discord.Interaction, button: discord.ui.Button): await self.ban_view.set_reason("Reason 3") await interaction.response.defer(ephemeral=True)