better discord send fail log

This commit is contained in:
Lamp 2021-08-14 17:33:24 -07:00
parent 4a5d4b8dd6
commit d7e81475b8
1 changed files with 5 additions and 4 deletions

View File

@ -11,16 +11,17 @@ global.createMPPbridge = function createMPPbridge(room, DiscordChannelID, site =
{
let msgBuffer = [];
function _dSend(msg, embed) {
if (!msg && !embed) return console.warn("wtf send empty messag");
if (webhook && !config.testmode) {
let username = gClient.channel && gClient.channel._id || room;
if (username.length > 32) username = username.substr(0,31) + '…';
else if (username.length < 2) username = undefined;
webhook.send(msg, {username, embed, split:{char:''}}).catch(e => {
console.error(e);
DiscordChannel.send(msg, {embed, split:{char:''}}).catch(console.error);
webhook.send(msg, {username, embed, split:{char:''}}).catch(error => {
console.error(`webhook fail in ${DiscordChannel.id}: ${error.message}`);
DiscordChannel.send(msg, {embed, split:{char:''}}).catch(error => console.error(`send fail in ${DiscordChannel.id} after webhook send fail: ${error.message}`));
});
}
else DiscordChannel.send(msg, {embed, split:{char:''}}).catch(console.error);
else DiscordChannel.send(msg, {embed, split:{char:''}}).catch(error => console.error(`send fail in ${DiscordChannel.id}: ${error.message}`));
}
function dSend(msg) {
msgBuffer.push(msg);