javascript - Discord.js 收集器问题未更新嵌入
问题描述
我正在尝试获取它,以便我的不和谐机器人将使用用户回复更新嵌入,但是我没有收到任何错误,控制台日志中也没有任何内容。
因此,在我认为问题在于我没有从该代码中获得任何控制台日志的部分。我已经尝试过获得帮助,但我似乎无法找到解决此问题的解决方案。
我将在不和谐聊天(!开始)中发布一个命令,然后机器人将回复 3 个嵌入,然后等待 3 个字母的回复(UUU),然后它意味着用用户的回复更新嵌入但是对于一些未知的原因,我的代码看起来不错,除非 discord.js 不支持某些东西。
完整代码:
const collector = battleChannel.createMessageCollector(filter, {max: 200, maxMatches: 200, time: 180000});
collector.on('collect', m => {
console.log(`Collected ${m.content} | ${m.author.username}`);
if (game.data.length === 0 && m.content.length === 3){
game.addID(m.content.toUppercase(), m.author.username);
}else if (m.content.length === 3){
if (game.userPresent(m.author.username)){
game.deleteUserEntry(m.author.username);
if (game.idPresent(m.content.toUppercase())){
game.addUser(m.content.toUppercase(), m.author.username);
}else {
game.addID(m.content.toUppercase(), m.author.username);
}
} else {
if (game.idPresent(m.content.toUppercase())){
game.addUser(message.content.toUppercase(), message.author.username);
}else {
game.addID(m.content.toUppercase(), m.author.username);
}
}
}
game.sort();
let str = "";
last3 = new Discord.MessageEmbed()
.setTitle ("Alliance joined!")
.setColor ("#0099ff")
.setTimestamp();
for (var i = 0; i < game.data.length; i++){
str = "";
for (var j = 0; j < game.data[i].users.length; j++){
str += game.data[i].users[j] + "\n";
}
last3.addField(`${game.data[i].id.toUppercase()} - ${game.data[i].users.length} PLAYERS`, str, true);
}
editLast3.edit({embed: last3}).catch((err) => {
console.log("Caught edit error");
});
if (m.deletable){
m.delete().catch((err) => {
console.log("Cannot Delete");
console.log(err);
});
collector.on('end', collected => {
console.log(`Collected ${collected.size} items`);
});
}
});
};
我认为问题出在哪里:
const collector = battleChannel.createMessageCollector(filter, {max: 200, maxMatches: 200, time: 180000});
collector.on('collect', m => {
console.log(`Collected ${m.content} | ${m.author.username}`);
if (game.data.length === 0 && m.content.length === 3){
game.addID(m.content.toUppercase(), m.author.username);
}else if (m.content.length === 3){
if (game.userPresent(m.author.username)){
game.deleteUserEntry(m.author.username);
if (game.idPresent(m.content.toUppercase())){
game.addUser(m.content.toUppercase(), m.author.username);
}else {
game.addID(m.content.toUppercase(), m.author.username);
}
} else {
if (game.idPresent(m.content.toUppercase())){
game.addUser(message.content.toUppercase(), message.author.username);
}else {
game.addID(m.content.toUppercase(), m.author.username);
}
}
}
game.sort();
let str = "";
last3 = new Discord.MessageEmbed()
.setTitle ("Alliance joined!")
.setColor ("#0099ff")
.setTimestamp();
for (var i = 0; i < game.data.length; i++){
str = "";
for (var j = 0; j < game.data[i].users.length; j++){
str += game.data[i].users[j] + "\n";
}
last3.addField(`${game.data[i].id.toUppercase()} - ${game.data[i].users.length} PLAYERS`, str, true);
}
editLast3.edit({embed: last3}).catch((err) => {
console.log("Caught edit error");
});
if (m.deletable){
m.delete().catch((err) => {
console.log("Cannot Delete");
console.log(err);
});
collector.on('end', collected => {
console.log(`Collected ${collected.size} items`);
});
}
});
};
感谢您花时间查看此线程并为我提供帮助。
解决方案
推荐阅读
- react-native - React-Native - 一个屏幕上没有标题(堆栈+抽屉导航)
- swiftui - 图像正文中的swiftui三元运算符不播放动画和过渡
- python - 函数内的数据框名称无法识别
- jquery - 使用 jQuery 更改值属性的文本
- android - 调用 startActivity(intent) 不会重新创建 Activity
- label - PyTesseract 获取几个单词的边界框
- python - 获取 json 存储数据 kivy 中的元素总和以解决滚动高度问题
- google-apps-script - 谷歌应用脚本在几个小时之间自动回复
- android - Android BLE 扫描未在某些设备上解析 ScanRecord
- html - 如何在其他人的前景上为孩子应用背景(他们已经有背景设置)?