Restructure how sendAlert works and add ability to add text to it for pings eg
This commit is contained in:
parent
cb4f6fc5fd
commit
30a9ece95c
@ -23,7 +23,7 @@ module.exports = {
|
|||||||
message.reply({ embeds: [ replyEmbed ]});
|
message.reply({ embeds: [ replyEmbed ]});
|
||||||
|
|
||||||
const errorEmbed = fn.embeds.error(`An error has occurred in command ${this.name}:\n${err}`);
|
const errorEmbed = fn.embeds.error(`An error has occurred in command ${this.name}:\n${err}`);
|
||||||
fn.sendAlert(errorEmbed, message.client);
|
fn.sendAlert(message.client, [errorEmbed]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
10
functions.js
10
functions.js
@ -921,13 +921,19 @@ const functions = {
|
|||||||
const errorId = digits.join("");
|
const errorId = digits.join("");
|
||||||
return errorId;
|
return errorId;
|
||||||
},
|
},
|
||||||
async sendAlert(embed, client) {
|
async sendAlert(client, embeds, text) {
|
||||||
const statusChannel = await client.channels.fetch(statusChannelId)
|
const statusChannel = await client.channels.fetch(statusChannelId)
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
await statusChannel.send({ embeds: [ embed ] })
|
const messageOptions = {
|
||||||
|
embeds: embeds
|
||||||
|
};
|
||||||
|
|
||||||
|
if (text) messageOptions.content = text;
|
||||||
|
|
||||||
|
await statusChannel.send(messageOptions)
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
|
|||||||
28
main.js
28
main.js
@ -4,14 +4,13 @@
|
|||||||
const dotenv = require('dotenv');
|
const dotenv = require('dotenv');
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
const token = process.env.TOKEN;
|
const token = process.env.TOKEN;
|
||||||
const statusChannelId = process.env.statusChannelId;
|
|
||||||
const ownerId = process.env.ownerId;
|
const ownerId = process.env.ownerId;
|
||||||
|
|
||||||
// Dump the env vars to log in dev environment:
|
// Dump the env vars to log in dev environment:
|
||||||
if (process.env.isDev === "true") console.log(JSON.stringify(process.env));
|
if (process.env.isDev === 'true') console.log(JSON.stringify(process.env));
|
||||||
|
|
||||||
// Discord.JS
|
// Discord.JS
|
||||||
const { Client, Intents } = require('discord.js');
|
const { Client } = require('discord.js');
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
intents: [
|
intents: [
|
||||||
'GUILDS',
|
'GUILDS',
|
||||||
@ -25,13 +24,10 @@ const client = new Client({
|
|||||||
'MESSAGE',
|
'MESSAGE',
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
const { MessageActionRow, MessageButton } = require('discord.js');
|
|
||||||
|
|
||||||
// Various imports
|
// Various imports
|
||||||
const fn = require('./functions.js');
|
const fn = require('./functions.js');
|
||||||
const config = require('./config.json');
|
const { CommandData } = require('./CustomModules/NodBot.js');
|
||||||
const strings = require('./strings.json');
|
|
||||||
const { GifData, CommandData } = require('./CustomModules/NodBot.js');
|
|
||||||
const ButtonHandlers = require('./CustomModules/ButtonHandlers.js');
|
const ButtonHandlers = require('./CustomModules/ButtonHandlers.js');
|
||||||
const InteractionStorage = require('./CustomModules/InteractionStorage.js');
|
const InteractionStorage = require('./CustomModules/InteractionStorage.js');
|
||||||
const appVersion = require('./package.json').version;
|
const appVersion = require('./package.json').version;
|
||||||
@ -57,10 +53,12 @@ client.once('ready', async () => {
|
|||||||
// console.log(JSON.stringify(icaoArray));
|
// console.log(JSON.stringify(icaoArray));
|
||||||
// statusChannel = await client.channels.fetch(statusChannelId).catch(e => console.error(e));
|
// statusChannel = await client.channels.fetch(statusChannelId).catch(e => console.error(e));
|
||||||
// await statusChannel.send(`${new Date().toISOString()} -- <@${process.env.ownerId}>\nStartup Sequence Complete`).catch(e => console.error(e));
|
// await statusChannel.send(`${new Date().toISOString()} -- <@${process.env.ownerId}>\nStartup Sequence Complete`).catch(e => console.error(e));
|
||||||
const readyTimestamp = new Date().toISOString();
|
const readyTimestamp = Math.floor(Date.now() / 1000);
|
||||||
const readyMessage = readyTimestamp + ' -- <@' + ownerId + '>\nStartup Sequence Complete';
|
const timestampDiscordString = '<t:' + readyTimestamp + ':f>';
|
||||||
|
const readyMessage = 'Startup Sequence Complete at ' + timestampDiscordString;
|
||||||
|
const readyMsgContent = '<@' + ownerId + '>';
|
||||||
const readyMsgEmbed = fn.embeds.text({ command: 'Boot', content: readyMessage, author: appVersion });
|
const readyMsgEmbed = fn.embeds.text({ command: 'Boot', content: readyMessage, author: appVersion });
|
||||||
await fn.sendAlert(readyMsgEmbed, client);
|
await fn.sendAlert(client, [readyMsgEmbed], readyMsgContent);
|
||||||
// Check for banned servers
|
// Check for banned servers
|
||||||
fn.checkBannedServers(client, statusChannel);
|
fn.checkBannedServers(client, statusChannel);
|
||||||
});
|
});
|
||||||
@ -79,7 +77,8 @@ client.on('interactionCreate', async interaction => {
|
|||||||
|
|
||||||
if (client.slashCommands.has(commandName)) {
|
if (client.slashCommands.has(commandName)) {
|
||||||
client.slashCommands.get(commandName).execute(interaction);
|
client.slashCommands.get(commandName).execute(interaction);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
interaction.reply('Sorry, I don\'t have access to that command.');
|
interaction.reply('Sorry, I don\'t have access to that command.');
|
||||||
console.error('Slash command attempted to run but not found: ' + commandName);
|
console.error('Slash command attempted to run but not found: ' + commandName);
|
||||||
}
|
}
|
||||||
@ -98,16 +97,18 @@ client.on('interactionCreate', async interaction => {
|
|||||||
const searchString = interaction.options.getFocused();
|
const searchString = interaction.options.getFocused();
|
||||||
const choices = fn.weed.strain.lookup(searchString, interaction.client);
|
const choices = fn.weed.strain.lookup(searchString, interaction.client);
|
||||||
await interaction.respond(
|
await interaction.respond(
|
||||||
|
// eslint-disable-next-line comma-dangle
|
||||||
choices.map(choice => ({ name: choice, value: choice }))
|
choices.map(choice => ({ name: choice, value: choice }))
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case "edit":
|
case 'edit':
|
||||||
// TODO
|
// TODO
|
||||||
switch (interaction.options.getSubcommand()) {
|
switch (interaction.options.getSubcommand()) {
|
||||||
case 'gif':
|
case 'gif':
|
||||||
const gifQuery = interaction.options.getFocused();
|
const gifQuery = interaction.options.getFocused();
|
||||||
const gifChoices = fn.search.gifs(gifQuery, interaction.client);
|
const gifChoices = fn.search.gifs(gifQuery, interaction.client);
|
||||||
await interaction.respond(
|
await interaction.respond(
|
||||||
|
// eslint-disable-next-line comma-dangle
|
||||||
gifChoices.map(choice => ({ name: choice, value: choice }))
|
gifChoices.map(choice => ({ name: choice, value: choice }))
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
@ -115,15 +116,14 @@ client.on('interactionCreate', async interaction => {
|
|||||||
const pastaQuery = interaction.options.getFocused();
|
const pastaQuery = interaction.options.getFocused();
|
||||||
const pastaChoices = fn.search.pastas(pastaQuery, interaction.client);
|
const pastaChoices = fn.search.pastas(pastaQuery, interaction.client);
|
||||||
await interaction.respond(
|
await interaction.respond(
|
||||||
|
// eslint-disable-next-line comma-dangle
|
||||||
pastaChoices.map(choice => ({ name: choice, value: choice }))
|
pastaChoices.map(choice => ({ name: choice, value: choice }))
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user