Compare commits
5 commits
main
...
fix/retry-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
329eaa0113 | ||
|
|
0ccebafb1d | ||
|
|
43864df9c0 | ||
|
|
1095537b34 | ||
|
|
19b15f3572 |
22
index.js
22
index.js
|
|
@ -458,15 +458,15 @@ Example data object:
|
||||||
}, 10 * 60 * 1000);
|
}, 10 * 60 * 1000);
|
||||||
let errCount = 0;
|
let errCount = 0;
|
||||||
function sendMessage() {
|
function sendMessage() {
|
||||||
channel.send(thisMsg).then((msg) => {
|
channel.send(thisMsg).catch((err) => {
|
||||||
// Message sent successfully. Note in the logs
|
|
||||||
console.log(`${colors.cyan("[INFO]")} Sent message to ${channel.guild.name}/${channel.name} (${channel.guild.id}/${channel.id}). ${errCount}/3`);
|
|
||||||
}).catch((err) => {
|
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
}).then((msg) => {
|
||||||
|
if (msg.channel.type === Discord.ChannelType.GuildAnnouncement) msg.crosspost();
|
||||||
|
}).catch(() => {
|
||||||
console.log(`${colors.yellow("[WARN]")} Failed to send message to ${channel.guild.name}/${channel.name} (${channel.guild.id}/${channel.id})`);
|
console.log(`${colors.yellow("[WARN]")} Failed to send message to ${channel.guild.name}/${channel.name} (${channel.guild.id}/${channel.id})`);
|
||||||
if (errCount < 3) {
|
if (errCount < 3) {
|
||||||
errCount++;
|
errCount++;
|
||||||
setTimeout(sendMessage, 5000 * errCount); // Retry after 5 seconds
|
setTimeout(sendMessage, 5000); // Retry after 5 seconds
|
||||||
} else {
|
} else {
|
||||||
const logChannel = discord.guilds.cache.get(config.discord.mainGuild).channels.cache.get(config.discord.logChannel);
|
const logChannel = discord.guilds.cache.get(config.discord.mainGuild).channels.cache.get(config.discord.logChannel);
|
||||||
logChannel.send({
|
logChannel.send({
|
||||||
|
|
@ -481,9 +481,7 @@ Example data object:
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}).then((msg) => {
|
});
|
||||||
// if (msg.channel.type === Discord.ChannelType.GuildAnnouncement) msg.crosspost();
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
sendMessage()
|
sendMessage()
|
||||||
});
|
});
|
||||||
|
|
@ -536,15 +534,11 @@ Example data object:
|
||||||
let errCount = 0;
|
let errCount = 0;
|
||||||
|
|
||||||
function sendMessage() {
|
function sendMessage() {
|
||||||
user.send(thisMsg).then((msg) => {
|
user.send(thisMsg).catch((err) => {
|
||||||
// Message sent successfully. Note in the logs
|
|
||||||
console.log(`${colors.cyan("[INFO]")} Sent message to ${user.tag} (${user.id}). ${errCount}/3`);
|
|
||||||
}).catch((err) => {
|
|
||||||
console.log(err)
|
|
||||||
console.log(`${colors.yellow("[WARN]")} Failed to send message to ${user.tag} (${user.id})`);
|
console.log(`${colors.yellow("[WARN]")} Failed to send message to ${user.tag} (${user.id})`);
|
||||||
if (errCount < 3) {
|
if (errCount < 3) {
|
||||||
errCount++;
|
errCount++;
|
||||||
setTimeout(sendMessage, 5000 * errCount); // Retry after 5 seconds
|
setTimeout(sendMessage, 5000); // Retry after 5 seconds
|
||||||
} else {
|
} else {
|
||||||
const logChannel = discord.guilds.cache.get(config.discord.mainGuild).channels.cache.get(config.discord.logChannel);
|
const logChannel = discord.guilds.cache.get(config.discord.mainGuild).channels.cache.get(config.discord.logChannel);
|
||||||
logChannel.send({
|
logChannel.send({
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue