不和谐.JS |检查频道是不是存在票务机器人
Posted
技术标签:
【中文标题】不和谐.JS |检查频道是不是存在票务机器人【英文标题】:Discord.JS | Check If channel exists Ticket bot不和谐.JS |检查频道是否存在票务机器人 【发布时间】:2020-12-30 15:54:31 【问题描述】:你好,
我正在制作一个不和谐的票务机器人,但我遇到了这个我无法自己解决的错误。
这里是创建工单命令:
if(cmd === "new")
const reason = message.content.split(" ").slice(1).join(" ");
if (message.guild.channels.exists("name", "ticket-" + message.author.username)) return message.channel.send(`You already have a ticket open.`);
message.guild.createChannel(`ticket-$message.author.username`, "text").then(c =>
let role = message.guild.roles.find("name", "Support Team");
let role2 = message.guild.roles.find("name", "@everyone");
c.overwritePermissions(role,
SEND_MESSAGES: true,
READ_MESSAGES: true
);
c.overwritePermissions(role2,
SEND_MESSAGES: false,
READ_MESSAGES: false
);
c.overwritePermissions(message.author,
SEND_MESSAGES: true,
READ_MESSAGES: true
);
var embedcreated = new Discord.RichEmbed()
.setColor("#f00202")
.setDescription(`You ticket has been created ` + message.guild.channels.find(channel => channel.name === c.name).toString())
.setTitle("Tickets | MiZ")
.setFooter(`Tickets System`)
.setTimestamp();
message.channel.send(embedcreated);
const embed = new Discord.RichEmbed()
.setColor("#f00202")
.addField(`Hey $message.author.username!`, ` Please explain your problen to the staff team.`)
.setTimestamp();
c.send( embed: embed );
).catch(console.error);
let sChannel = message.guild.channels.find(x => x.name === "logs");
if(!sChannel) return message.channel.send("logs channel not found.")
var staff = new Discord.RichEmbed()
.setColor("#f00202")
.addField("Created a ticket: " , message.author)
.setTitle("Logs | MiZ")
.setTimestamp();
sChannel.send(staff)
我有一条线路检查频道是否存在,但它不起作用,因为我可以创建更多票证。
使用: Discord.js:^11.3.2
【问题讨论】:
【参考方案1】:请下次更具体,并使用javascript块代码,这样更容易理解
no block code
"Javascript block code"
【讨论】:
没关系,我找到了检测频道的方法,但谢谢。以上是关于不和谐.JS |检查频道是不是存在票务机器人的主要内容,如果未能解决你的问题,请参考以下文章