我正在尝试在用户发送消息之前做到这一点,直到其他人发送消息为止,在那里该消息被删除,因此1个人在其他人发送之前不能发送两次消息。但是我不知道该怎么做,也许是通过检查频道上最后的消息和消息作者是什么?
client.on('message', message => {
if (!oChannel.includes(message.channel.id)) return;
const args = message.content.slice().trim().split(/ +/);
const { author, member } = message;
if (!message.guild) return;
if (author.bot) return;
if (args.length === 3) {
message.reply('Thanks, wait until other people continue')
.then(m => m.delete({ timeout: 3000 }))
} else {
if (!oChannel.includes(message.channel.id)) return;
if (message.deletable) message.delete({ timeout: 500 })
message.reply('Please write 3 words !')
.then(m => m.delete({ timeout: 2000 }))
}
})
client.on('messageUpdate', (oldMessage, newMessage) => {
if (!oChannel.includes(newMessage.channel.id)) return;
if(newMessage.content != oldMessage) {
if (newMessage.deletable) newMessage.delete({ timeout: 500 })
newMessage.reply('Edit not allowed !')
.then(m => m.delete({ timeout: 2000 }))
}
})
到目前为止,这是我的代码,就像一个三个单词的故事代码,现在该代码所执行的操作是,当有人在一个通道中发送消息的长度大于或小于三个单词时,它会删除该消息,并使人们无法编辑消息,但
答案 0 :(得分:0)
您可以这样做:
只需过滤message.channel.messages.cache
即可跳过漫游器消息并获取最后一个元素
client.on('message', (message) => {
if (!oChannel.includes(message.channel.id)) return;
const args = message.content.slice().trim().split(/ +/);
const { author, member } = message;
if (!message.guild) return;
if (author.bot) return;
if (args.length === 3) return message.reply('Thanks, wait until other people continue').then((m) => m.delete({ timeout: 3000 }));
let previousMessage = message.channel.messages.cache.filter((m) => !m.author.bot).last();
if (previousMessage.author.id === message.author.id) {
message.channel.send('No no no').then((msg) => {
msg.delete({
timeout: 2000,
});
});
}
});