discord - 不和谐.JS | 检查频道是否存在票务机器人
问题描述
所以再次你好,
我正在为不和谐制作一个票务机器人,但我遇到了这个我无法自己解决的错误。
这是创建票证命令:
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
解决方案
请下次更具体并使用javascript块代码,这样更容易理解
no block code
"Javascript block code"
推荐阅读
- ruby-on-rails - sRails 4.2 / Rspec / rspec-retry - 关联属于/has_many 失败
- c# - 在 C# 中的列表中循环遍历列表
- h2 - H2 通过 Shell “连接断开”连接到网站
- python - 如何在 s3 中将 lambda 输出写入 JSON
- ios - 展开或折叠时可展开的 UItableview 内容高度不同
- php - ajax,语法错误:位置 0 的 json 中的意外标记 A
- java - 我无法让我的原色与屏幕上的按钮相匹配,即使它们在 Android Studio 中是相同的 HEX 颜色
- python - 是否有任何 python 代码可以在不使用 ImageMagick 或 Ghost 脚本的情况下将多页 pdf 转换为图像
- angular - 无法使用 Karma 和 Jasmine 测试 Angular http 拦截器
- scala - 连接以形成列表 scala