admin管理员组文章数量:1405378
The await interaction.response.send_message(f"A ticket has been created {ticket_channel.mention}", ephemeral=True)
part of the code does not send a message after the interaction.
import discord
from discord.ext import commands
from discord.ui import View, Select
import asyncio
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
class TicketDropdown(Select):
def __init__(self):
options = [
discord.SelectOption(label="Issue 1", description="Lorem ipsum", value="issue1"),
discord.SelectOption(label="Issue 2", description="Lorem ipsum", value="issue2"),
discord.SelectOption(label="Issue 3", description="Lorem ipsum", value="issue3"),
]
super().__init__(placeholder="Select an issue...", options=options)
async def callback(self, interaction: discord.Interaction):
issue = self.values[0]
user = interaction.user
category = discord.utils.get(interaction.guild.categories, name="Support Tickets")
if not category:
category = await interaction.guild.create_category("Support Tickets")
ticket_channel = await interaction.guild.create_text_channel(
f"ticket-{user.name}-{issue}", category=category
)
await interaction.response.send_message(f"A ticket has been created {ticket_channel.mention}", ephemeral=True)
role = discord.utils.get(interaction.guild.roles, name="Moderators")
await ticket_channel.set_permissions(role, view_channel=True, send_messages=True)
await ticket_channel.set_permissions(user, view_channel=True, send_messages=True)
await ticket_channel.send(
f"**{user.mention}** created a ticket: **{issue}**.\nSend a reason within **15 minutes**, or the ticket will close."
)
def check(m):
return m.channel == ticket_channel and m.author == user
try:
message = await bot.wait_for("message", timeout=900, check=check)
await message.reply("Lorem ipsum")
except asyncio.TimeoutError:
await ticket_channel.send("Ticket closed due to inactivity.")
await ticket_channel.delete()
class TicketView(View):
def __init__(self):
super().__init__()
self.add_item(TicketDropdown())
@bot.event
async def on_ready():
print(f"Logged in as {bot.user}")
@bot.event
async def on_message(message):
if message.author.bot:
return
if message.channel.category and "Support Tickets" in message.channel.category.name:
await message.reply("Lorem ipsum")
await bot.process_commands(message)
@botmand()
async def ticket(ctx):
embed = discord.Embed(title="Create a Support Ticket", description="Lorem ipsum", color=discord.Color.blue())
await ctx.send(embed=embed, view=TicketView())
@botmand()
async def close(ctx):
if isinstance(ctx.channel, discord.TextChannel) and ctx.channel.category and "Support Tickets" in ctx.channel.category.name:
await ctx.send("Closing ticket...")
await ctx.channel.delete()
else:
await ctx.send("This command can only be used in a ticket channel.")
I tried changing the interaction.response.send_message
to interaction.followup.send
but to no avail
本文标签: pythonMy Discord pycord interaction doesn39t respond with a messageStack Overflow
版权声明:本文标题:python - My Discord py-cord interaction doesn't respond with a message - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744890685a2630760.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论