从一个命令记录 message.author 并将其拉到另一个
Logging message.author from one command and pulling it to another
我正在创建一个不和谐的机器人,它可以处理用作应用程序的票证,我已经完成了大部分工作,除了当 -close
命令用于记录已关闭的票证时我想要机器人。
我尝试了一些方法,例如调用 .then 将消息发送到正在删除的特定频道的日志记录频道,然后调用另一个 .then 当它被删除时,除了它仍然会发送消息说 #deleted-channel
。我尝试了几种方法,但我无法弄清楚。
我尝试的另一个解决方案是在 -apply
命令中创建一个变量,该变量将记录创建消息的人的姓名,但我意识到,在许多人使用命令 apply 后,如果我试图关闭一个它会记录最近的申请人姓名,而不是我正在关闭的申请
-应用命令
const reason = message.content.split(" ").slice(1).join(" ");
var tAuthor = message.author.tag
if (!message.guild.roles.exists("name", "[»] Helpers")) return message.channel.send(`Server does not have role set correctly., This error has been logged. \nPlease contact bot developer <@251557870603075586>`);
if (message.guild.channels.exists("name", "t-staff-" + message.author.tag)) return message.reply(`You already have an application open.`);
message.guild.createChannel(`t-staff-${message.author.tag}`, "text").then(c => {
let role = message.guild.roles.find("name", `${config.role}`);
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
});
c.setParent(message.guild.category.exists("name", "t-staff-"))
message.reply(`:white_check_mark: Your application has been created, #${c.name}.`);
const embed = new Discord.RichEmbed()
.setColor(0xCF40FA)
.setTitle(`Staff Application`)
.setDescription(`<@${message.author.id}>`)
.addField(`Requirements`, `You must meet all the requirements:\n\n1. Professional attitude and grammar\n2. Working Microphone\n3. No severe punishments on the server. (Racial Slurs, DDos Threats, etc..)\n4. You must be over the age of 14`)
.addBlankField()
.addField(`Note:`, `Please check in announcements for open staff positions`)
.addField(`Note:`, `Please paste the format with your answers`)
.addField(`Note:`, `If your previous application was denied you must wait one week to sumbit a new one`)
.addBlankField()
.addField('Format', `\nWhat position are you applying for: \n\nMinecraft username: \n\nPrevious Minecraft usernames: \n\nWhat is your age: \n\nTimezone: \n\nAbility to record Minecraft video: \n\nHow much time do you have to contribute a week? \n\nWhat do you consider to be your biggest weaknesses?\n\nWhat's your dream job? \n\nHow do you deal with pressure or stressful situations? \n\nAny previous staff skills or experience? \n\nHave you ever been banned or punished for your actions on this server? If so, please include details. \n\nTell us about a time you made a mistake within the last year? How did you deal with it? What did you learn? \n\nAre you currently staff on any other servers? \n\nWhere did you hear about nodepvp? \n\nHave you made any previous applications, if so how many and what is the date of your last one? \n\nWhat would be your daily tasks for the rank you are applying for \n\nAnything else we should know? `)
.addBlankField()
.setTimestamp();
c.send({ embed: embed });
client.channels.get(`568210811009499136`).send(`:white_check_mark: !!!Ticket Created ${message.author} at **${current_date}**`);
-关闭命令
if (!message.channel.name.startsWith(`ticket-`)) return message.channel.send(`You can't use the close command outside of a ticket channel.`);
if(!message.member.hasPermission("MANAGE_MESSAGES")) return message.channel.send(`${message.author} Do not have permission to close this application`);
// Confirm delete - with timeout (Not command)
message.channel.send(`Are you sure? Once confirmed, you cannot reverse this action!\nTo confirm, type \`/confirm\`. This will time out in 10 seconds and be cancelled.`)
.then((m) => {
message.channel.awaitMessages(response => response.content === '/confirm', {
max: 1,
time: 10000,
errors: ['time'],
})
.then((collected) => {
message.channel.delete();
})
.catch(() => {
m.edit('Ticket close timed out, the ticket was not closed.').then(m2 => {
m2.delete();
}, 3000);
});
});
当我尝试在
之前的关闭命令中使用 .then
函数来记录它时
.then((collected) => {
message.channel.delete();
它仍然向频道发送消息说 #deleted-channel
即使我在删除频道之前发送命令。
如果您发送带有频道提及的消息,例如 #test
,只要 test
频道存在,它将作为可点击的 link 保留在该频道中。如果您删除该频道,所有 link 将占用并成为一个沉闷的 #deleted-channel
。
一种解决方案是登录 Closed ${channel.name}
,然后删除该频道。
你不能做到这一点,所以它会保留 linked 消息(除非你做到这一点,所以没有人可以通过拒绝对 closed[ 的读取访问来看到 deleted 频道=20=] 除了用于记录目的的工作人员之外的所有人的门票。
我正在创建一个不和谐的机器人,它可以处理用作应用程序的票证,我已经完成了大部分工作,除了当 -close
命令用于记录已关闭的票证时我想要机器人。
我尝试了一些方法,例如调用 .then 将消息发送到正在删除的特定频道的日志记录频道,然后调用另一个 .then 当它被删除时,除了它仍然会发送消息说 #deleted-channel
。我尝试了几种方法,但我无法弄清楚。
我尝试的另一个解决方案是在 -apply
命令中创建一个变量,该变量将记录创建消息的人的姓名,但我意识到,在许多人使用命令 apply 后,如果我试图关闭一个它会记录最近的申请人姓名,而不是我正在关闭的申请
-应用命令
const reason = message.content.split(" ").slice(1).join(" ");
var tAuthor = message.author.tag
if (!message.guild.roles.exists("name", "[»] Helpers")) return message.channel.send(`Server does not have role set correctly., This error has been logged. \nPlease contact bot developer <@251557870603075586>`);
if (message.guild.channels.exists("name", "t-staff-" + message.author.tag)) return message.reply(`You already have an application open.`);
message.guild.createChannel(`t-staff-${message.author.tag}`, "text").then(c => {
let role = message.guild.roles.find("name", `${config.role}`);
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
});
c.setParent(message.guild.category.exists("name", "t-staff-"))
message.reply(`:white_check_mark: Your application has been created, #${c.name}.`);
const embed = new Discord.RichEmbed()
.setColor(0xCF40FA)
.setTitle(`Staff Application`)
.setDescription(`<@${message.author.id}>`)
.addField(`Requirements`, `You must meet all the requirements:\n\n1. Professional attitude and grammar\n2. Working Microphone\n3. No severe punishments on the server. (Racial Slurs, DDos Threats, etc..)\n4. You must be over the age of 14`)
.addBlankField()
.addField(`Note:`, `Please check in announcements for open staff positions`)
.addField(`Note:`, `Please paste the format with your answers`)
.addField(`Note:`, `If your previous application was denied you must wait one week to sumbit a new one`)
.addBlankField()
.addField('Format', `\nWhat position are you applying for: \n\nMinecraft username: \n\nPrevious Minecraft usernames: \n\nWhat is your age: \n\nTimezone: \n\nAbility to record Minecraft video: \n\nHow much time do you have to contribute a week? \n\nWhat do you consider to be your biggest weaknesses?\n\nWhat's your dream job? \n\nHow do you deal with pressure or stressful situations? \n\nAny previous staff skills or experience? \n\nHave you ever been banned or punished for your actions on this server? If so, please include details. \n\nTell us about a time you made a mistake within the last year? How did you deal with it? What did you learn? \n\nAre you currently staff on any other servers? \n\nWhere did you hear about nodepvp? \n\nHave you made any previous applications, if so how many and what is the date of your last one? \n\nWhat would be your daily tasks for the rank you are applying for \n\nAnything else we should know? `)
.addBlankField()
.setTimestamp();
c.send({ embed: embed });
client.channels.get(`568210811009499136`).send(`:white_check_mark: !!!Ticket Created ${message.author} at **${current_date}**`);
-关闭命令
if (!message.channel.name.startsWith(`ticket-`)) return message.channel.send(`You can't use the close command outside of a ticket channel.`);
if(!message.member.hasPermission("MANAGE_MESSAGES")) return message.channel.send(`${message.author} Do not have permission to close this application`);
// Confirm delete - with timeout (Not command)
message.channel.send(`Are you sure? Once confirmed, you cannot reverse this action!\nTo confirm, type \`/confirm\`. This will time out in 10 seconds and be cancelled.`)
.then((m) => {
message.channel.awaitMessages(response => response.content === '/confirm', {
max: 1,
time: 10000,
errors: ['time'],
})
.then((collected) => {
message.channel.delete();
})
.catch(() => {
m.edit('Ticket close timed out, the ticket was not closed.').then(m2 => {
m2.delete();
}, 3000);
});
});
当我尝试在
之前的关闭命令中使用.then
函数来记录它时
.then((collected) => {
message.channel.delete();
它仍然向频道发送消息说 #deleted-channel
即使我在删除频道之前发送命令。
如果您发送带有频道提及的消息,例如 #test
,只要 test
频道存在,它将作为可点击的 link 保留在该频道中。如果您删除该频道,所有 link 将占用并成为一个沉闷的 #deleted-channel
。
一种解决方案是登录 Closed ${channel.name}
,然后删除该频道。
你不能做到这一点,所以它会保留 linked 消息(除非你做到这一点,所以没有人可以通过拒绝对 closed[ 的读取访问来看到 deleted 频道=20=] 除了用于记录目的的工作人员之外的所有人的门票。