送信したメッセージを数秒後に削除するサンプル
code:js
const { setTimeout } = require('node:timers/promises');
// ...
client.on('messageCreate', async message => {
if (message.content === 'hello') {
const reply = await message.channel.send('hi!')
await setTimeout(5000);
await reply.delete()
}
})
code:js
client.on('message', async message => {
if (message.content === 'hello') {
const reply = await message.channel.send('hi!')
await reply.delete({ timeout: 5000 })
// v11では代わりに reply.delete(5000) と書く
}
})
関連