Ticket System Discord.js v.13



我正在尝试脚本票务系统。我可以成功地创建一个票,但我不知道如何关闭它(删除它),我试着查找的东西,但我找不到我的代码的解决方案。

我代码:


case 'ticket':
case 'Ticket':
var guild = client.guilds.cache.get('877207084251369512')
guild.channels.create(message.author.username + '-ticket', {
type: 'text',
topic: 'Ticket' + message.author.id,
parent: '896402801428456046',
permissionOverwrites: [
{
id: message.author.id,
allow: ['SEND_MESSAGES', 'VIEW_CHANNEL', 'READ_MESSAGE_HISTORY', 'EMBED_LINKS', 'ATTACH_FILES'],
},
{
id: message.guild.roles.everyone,
deny: ['VIEW_CHANNEL'],
},
{
id: "877570054710001735",
allow: ['SEND_MESSAGES', 'VIEW_CHANNEL'],
},
],
})
let created = new Discord.MessageEmbed()
.setTitle("Ticket-System")
.setDescription("You're Ticket was created!")
.setTimestamp()
.setFooter('Ticket System')
.setColor("GREY")


message.channel.send({embeds: [created]});

let channel = message.guild.channels.cache.find(channel => channel.name === `${message.author.username}-ticket`);
message.guild.channels.cache.get(`${channel}`)

在这里

guild.channels.create(message.author.username + '-ticket', {

您使用的是<someusername>-ticket

.find(channel => channel.name === `ticket-${message.author.username}`);

您使用了ticket-<someusername>

选择将ticket-<someusername>放在您的两行或<someusername>-ticket

PS:我建议你使用id而不是用户名,因为你知道id只有数字,而用户名可以有特殊和烦人的字符。此外,为了解决一些潜在的问题,您可以将channel更改为channel.id

message.guild.channels.cache.get(`${channel.id}`)

通道名称中将有特殊符号。您可以使用以下程序删除特殊符号和空白

const channelname1 = removeSpaces(`${message.author.username}`)
const channelname = channelname1.replace(/[`~!@#$%^&*()_|+-=?;:'",.<>{}[]\/]/gi, '');

删除频道那么我不确定你想怎么删除通道,我只能给你一个删除通道的方法

channel.delete();

另外,我建议在定义通道

时可以延迟0.5秒。

最新更新