discordClient.on('messageCreate', async (message) => {
async function dt() {
if (message.content.includes('has been timed out for')){
const user = message.content.split(" ")[1]
const time = message.content.split(" ")[7]
if (message.content === `** ${user} has been timed out for ${time} seconds.**`) {
await message.channel.messages.fetch({
limit: 20
}).then((messages) => {
const msg = [];
messages.filter(m => m.author.username.toLowerCase() === user.toLowerCase()).forEach(message => msg.push(message))
message.channel.bulkDelete(msg).then(() => {
console.log('cleared messages')
});
})
}
}
}
dt().catch(error)
});
I made something that makes Twitch chat logs display on Discord, but I am now trying to make it that if a user has been timed out it deletes their messages. The code works fine but if someone typed it in chat it will consider it the same as a timeout so people in chat can delete messages on Discord. Is there any possible way to make it if a certain username did this then you apply the code using webhooks?
The one with the name User Timed Out
I got it from /timeout
on Twitch but with DancingPotato
I just typed the same words as what it would do if it deleted the message without /timeout and it will clear the messages of both.