Added some logging for failed message sends
This commit is contained in:
parent
d8cd40c821
commit
1d4d7d2f92
3 changed files with 16 additions and 9 deletions
|
@ -18,7 +18,8 @@
|
||||||
"no-plusplus": "off",
|
"no-plusplus": "off",
|
||||||
"no-bitwise": "off",
|
"no-bitwise": "off",
|
||||||
"no-continue": "off",
|
"no-continue": "off",
|
||||||
"no-unused-expressions": "off",
|
"no-unused-expressions": "off",
|
||||||
|
"no-console": "off",
|
||||||
"arrow-parens": [
|
"arrow-parens": [
|
||||||
2,
|
2,
|
||||||
"as-needed"
|
"as-needed"
|
||||||
|
@ -46,4 +47,4 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ function _drawImage(ctx, img, x, y, args = {}) {
|
||||||
}
|
}
|
||||||
if (args.attributes) {
|
if (args.attributes) {
|
||||||
_.each(args.attributes, (val, prop) => {
|
_.each(args.attributes, (val, prop) => {
|
||||||
console.log(`Setting ${prop } to ${val}`);
|
console.log(`Setting ${prop} to ${val}`);
|
||||||
ctx[prop] = val;
|
ctx[prop] = val;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
18
index.js
18
index.js
|
@ -155,8 +155,8 @@ app.get('/debug/frame/', async (req, res) => {
|
||||||
app.get('/:templateName/', async (req, res) => {
|
app.get('/:templateName/', async (req, res) => {
|
||||||
if (!templates[req.params.templateName]) return res.status(404).end();
|
if (!templates[req.params.templateName]) return res.status(404).end();
|
||||||
try {
|
try {
|
||||||
if(!/^https?:/.test(req.query.url)) {
|
if (!/^https?:/.test(req.query.url)) {
|
||||||
return res.status(400).end("Invalid url!")
|
return res.status(400).end('Invalid url!');
|
||||||
}
|
}
|
||||||
const img = new ImageEx(req.query.url);
|
const img = new ImageEx(req.query.url);
|
||||||
const canvas = render(templates[req.params.templateName], await img.loaded);
|
const canvas = render(templates[req.params.templateName], await img.loaded);
|
||||||
|
@ -181,8 +181,8 @@ const client = new Discord.Client({
|
||||||
// manage roles permission is required
|
// manage roles permission is required
|
||||||
const invitelink = `https://discordapp.com/oauth2/authorize?client_id=${
|
const invitelink = `https://discordapp.com/oauth2/authorize?client_id=${
|
||||||
config.discord.client_id}&scope=bot&permissions=0`;
|
config.discord.client_id}&scope=bot&permissions=0`;
|
||||||
const authlink = `https://discordapp.com/oauth2/authorize?client_id=${
|
/* const authlink = `https://discordapp.com/oauth2/authorize?client_id=${
|
||||||
config.discord.client_id}&scope=email`;
|
config.discord.client_id}&scope=email`; */
|
||||||
console.log(`Bot invite link: ${invitelink}`);
|
console.log(`Bot invite link: ${invitelink}`);
|
||||||
|
|
||||||
client.login(config.discord.token).catch(error => {
|
client.login(config.discord.token).catch(error => {
|
||||||
|
@ -255,7 +255,8 @@ const otherCommands = {
|
||||||
|
|
||||||
|
|
||||||
client.on('message', async message => {
|
client.on('message', async message => {
|
||||||
console.log(`[${message.guild.name} - ${message.channel.name}] ${message.author.username}#${message.author.discriminator}: ${message.cleanContent}`);
|
console.log(`[${message.guild.name} - ${message.channel.name}] ${message.author.username}`
|
||||||
|
+ `#${message.author.discriminator}: ${message.cleanContent}`);
|
||||||
|
|
||||||
let commandParsed = /^([/\\])(\w+)\b/.exec(message.cleanContent);
|
let commandParsed = /^([/\\])(\w+)\b/.exec(message.cleanContent);
|
||||||
if (commandParsed) {
|
if (commandParsed) {
|
||||||
|
@ -301,7 +302,12 @@ client.on('message', async message => {
|
||||||
{ attachment, name: `${name}.${emoji.ext}` }
|
{ attachment, name: `${name}.${emoji.ext}` }
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
await message.channel.send('', messageOptions);
|
console.log('Sending message with result:', result);
|
||||||
|
await message.channel.send('', messageOptions).then(() => {
|
||||||
|
console.log('Message sent!');
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('Message sending failed:', err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
Reference in a new issue