Skip to content

Commit

Permalink
🐛 Handle error while sending message
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasCtrl authored Oct 19, 2021
1 parent 79dae38 commit 7110f95
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 17 deletions.
8 changes: 5 additions & 3 deletions commands/Configuration/setlang.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ export default {
)
}

message.channel.send({ embeds: [embed] }).then((m) => {
setTimeout(() => m.delete().catch((err) => console.log('Error while deleting the message: ', err)), 20000)
})
message.channel.send({ embeds: [embed] })
.then((m) => {
setTimeout(() => m.delete().catch((err) => console.log('Error while deleting the message: ', err)), 20000)
})
.catch((err) => console.log('Error while sending the message: ', err))
},
}
2 changes: 1 addition & 1 deletion commands/Info/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ export default {
}
})

message.channel.send({ embeds: [embed] })
message.channel.send({ embeds: [embed] }).catch((err) => console.log('Error while sending the message: ', err))
},
}
2 changes: 1 addition & 1 deletion commands/Info/invite.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ export default {
'You can click on the following link to add the bot on your server: [https://discord.com/oauth2/authorize?client_id=761568927188123669&scope=bot&permissions=380108139840](https://discord.com/oauth2/authorize?client_id=761568927188123669&scope=bot&permissions=380108139840)'
)

message.channel.send({ embeds: [embed] })
message.channel.send({ embeds: [embed] }).catch((err) => console.log('Error while sending the message: ', err))
},
}
20 changes: 11 additions & 9 deletions commands/Info/ping.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ export default {
run: async (client, message) => {
const beforePing = new MessageEmbed().setColor(client.config.colors.primary).setDescription('Pinging...')

message.channel.send({ embeds: [beforePing] }).then((m) => {
let ping = m.createdTimestamp - message.createdTimestamp
message.channel.send({ embeds: [beforePing] })
.then((m) => {
let ping = m.createdTimestamp - message.createdTimestamp

const afterPing = new MessageEmbed()
.setColor(client.config.colors.primary)
.setDescription(
`Pong! :ping_pong:\nBot Latency: \`${ping}ms\`, API Latency: \`${Math.round(client.ws.ping)}ms\``
)
const afterPing = new MessageEmbed()
.setColor(client.config.colors.primary)
.setDescription(
`Pong! :ping_pong:\nBot Latency: \`${ping}ms\`, API Latency: \`${Math.round(client.ws.ping)}ms\``
)

m.edit({ embeds: [afterPing] })
})
m.edit({ embeds: [afterPing] })
})
.catch((err) => console.log('Error while sending the message: ', err))
},
}
2 changes: 1 addition & 1 deletion commands/Info/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ export default {
.addField('Memory usage ¬', `${Math.ceil(memoryStats.heapUsed / 1048576)} Mo`, true)
.setFooter(`Requested by ${message.author.username}`, message.author.avatarURL({ dynamic: true }))

message.channel.send({ embeds: [embed] })
message.channel.send({ embeds: [embed] }).catch((err) => console.log('Error while sending the message: ', err))
},
}
2 changes: 1 addition & 1 deletion commands/Info/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ export default {
'You can click on the following link to join the support server: [https://discord.gg/nEDcagb](https://discord.gg/nEDcagb)'
)

message.channel.send({ embeds: [embed] })
message.channel.send({ embeds: [embed] }).catch((err) => console.log('Error while sending the message: ', err))
},
}
2 changes: 1 addition & 1 deletion commands/Info/vote.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ export default {
'You can vote for the bot by clicking on the following link: [https://discordbotlist.com/bots/spookybot/upvote](https://discordbotlist.com/bots/spookybot/upvote)'
)

message.channel.send({ embeds: [embed] })
message.channel.send({ embeds: [embed] }).catch((err) => console.log('Error while sending the message: ', err))
},
}

0 comments on commit 7110f95

Please sign in to comment.