我一直在编写一个不和谐的票证机器人,该机器人在用户打开票证后会打开一个私人频道,我还添加了一个运行良好的高级设置系统。但是,我无法弄清楚为什么机器人在单击“创建票证”按钮后没有创建票证(下面的视频展示)。我花了几个小时试图弄清楚但我无法解决任何问题。请帮忙。 代码如下:https://github.com/ScremerMemer/Advanced-Ticket-Bot
视频:https://www.youtube.com/watch?v=_6ZS_IC780c&ab_channel=Saket
以下代码即可完成这项工作。
const ticketType = interaction.values[0];
// We get the value of the select menu.
const embed = new EmbedBuilder()
.setTitle("New Ticket")
.setColor("Green")
.setDescription(`New ticket of type ‘${ticketType}’.`)
interaction.guild?.channels.create({
name: `${interaction.user.displayName}-ticket`,
type: ChannelType.GuildText,
permissionOverwrites: [
{
id: interaction.user.id,
allow: [PermissionsBitField.Flags.ViewChannel],
},
{
id: "roleId", // The role you want him to see this channel.
allow: [PermissionsBitField.Flags.ViewChannel],
},
{
id: interaction.guild.id,
deny: [PermissionsBitField.Flags.ViewChannel],
},
],
parent: "categoryId", // Under which category the channel will open.
}).then((channel) => {
channel.send({
content: `<@${interaction.user.id}>`,
embeds: [embed]
})
})