'How do I make my bot delete a channel after some time has passed?
I'm a little bit lost here, how do I make my bot delete a channel after some time has passed? Such as 3 seconds.
Code:
if((message.author.bot) && (message.channel.name.includes('closed')) && (message.author.id === "id")){
for (let embed of message.embeds) {
if(embed.description.includes('custom msg')){
setTimeout(function(){
message.channel.delete
}, 3000);
}
}
}
Have a great rest of your day!
Solution 1:[1]
Tested this code out and it worked for me, give it a try and see what it does
// just verifying here, please double check the statement below becuase that is what is going to trigger the bot
// if a bot sends a message in a channel whose name includes 'closed' and that bots id is "id" then
if (message.author.bot && message.channel.name.includes('closed') && message.author.id === "id") {
message.channel.messages.fetch().then(messages => {
messages.forEach(message => {
const embed = message.embed[0]
if (embed) {
if (embed.description.includes('custom msg')) {
setTimeout(() => {
message.channel.delete()
}, 3000)
}
}
})
})
}
If that comment above the if statement is wrong and needs to be adjusted, let me know and we can fix it
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Gh0st |
