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
|
@ -19,6 +19,7 @@
|
||||||
"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"
|
||||||
|
|
16
index.js
16
index.js
|
@ -156,7 +156,7 @@ 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