Wenn ich versuche ein neues ticket zu öffnen Kommt in discord der fehler: "Diese Interaktion ist fehlgeschlagen und im code-editor kommt die Fehlermeldung: "Traceback (most recent call last):
, line 427, in _scheduled_task
await item.callback(interaction)
, line 35, in ticket
await interaction.defer(
AttributeError: 'Button' object has no attribute 'defer'
import discord
from discord.ext import commands
TOKEN = "DISCORD-BOTTOKEN"
bot = commands.Bot(command_prefix="!",
intents=discord.Intents.all(),
status=discord.Status.dnd)
async def change_bot_activity():
activity = discord.Activity(type=discord.ActivityType.watching, name="")
await bot.change_presence(activity=activity)
@bot.event
async def on_ready():
print("Bot is Ready!")
await change_bot_activity()
@bot.command(name="ticket")
@commands.has_permissions(administrator=True)
async def ticket(ctx):
embed = discord.Embed(
description="Drück den Button, um ein neues Ticket zu erstellen!"
)
view = CreateButton()
await ctx.send(embed=embed, view=view)
class CreateButton(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
@discord.ui.button(label="Create Ticket", style=discord.ButtonStyle.blurple, emoji="🎫", custom_id="ticketopen")
async def ticket(self, button: discord.ui.Button, interaction: discord.Interaction):
# Nutzerinteraktion bestätigen
await interaction.defer()
category = discord.utils.get(interaction.guild.categories, id=)
for ch in category.text_channels:
if ch.topic == f"{interaction.user.id} DO NOT CHANGE THE TOPIC OF THIS CHANNEL":
await interaction.followup.send("Du hast bereits ein Ticket: {0}".format(ch.mention), ephemeral=True)
return
r1 = discord.utils.get(interaction.guild.roles, id=)
overwrites = {
interaction.guild.default_role: discord.PermissionOverwrite(read_messages=False),
r1: discord.PermissionOverwrite(read_messages=True, send_messages=True, manage_messages=True),
interaction.user: discord.PermissionOverwrite(read_messages=True, send_messages=True),
interaction.guild.me: discord.PermissionOverwrite(read_messages=True, send_messages=True)
}
channel = await category.create_text_channel(
name=str(interaction.user),
topic=f"{interaction.user.id} DO NOT CHANGE THE TOPIC OF THIS CHANNEL!",
overwrites=overwrites
)
await channel.send(embed=discord.Embed(
title="Ticket erstellen",
description="Pinge keine Teammitglieder",
color=discord.Color.green()
))
await interaction.followup.send(
embed=discord.Embed(
description="Erstelle ein neues Ticket {0}".format(channel.mention),
color=discord.Color.white()
)
)
bot.run(TOKEN)