More async
This commit is contained in:
parent
dba2478a9a
commit
6bbfc0e855
20
index.js
20
index.js
|
@ -41,7 +41,7 @@ client.on("ready", () => {
|
||||||
// Load Commands
|
// Load Commands
|
||||||
console.log(`${colors.cyan("[INFO]")} Loading Commands...`)
|
console.log(`${colors.cyan("[INFO]")} Loading Commands...`)
|
||||||
const commands = require('./commands.json');
|
const commands = require('./commands.json');
|
||||||
(async () => {
|
await (async () => {
|
||||||
try {
|
try {
|
||||||
console.log(`${colors.cyan("[INFO]")} Registering Commands...`)
|
console.log(`${colors.cyan("[INFO]")} Registering Commands...`)
|
||||||
let start = Date.now()
|
let start = Date.now()
|
||||||
|
@ -71,6 +71,7 @@ client.on("ready", () => {
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// Automatically leave servers that aren't in the authorized channels list
|
// Automatically leave servers that aren't in the authorized channels list
|
||||||
|
await (async () => {
|
||||||
console.log(`${colors.cyan("[INFO]")} Leaving Servers...`)
|
console.log(`${colors.cyan("[INFO]")} Leaving Servers...`)
|
||||||
client.guilds.cache.forEach((guild) => {
|
client.guilds.cache.forEach((guild) => {
|
||||||
if (!config.discord.authorized_guilds.includes(guild.id)) {
|
if (!config.discord.authorized_guilds.includes(guild.id)) {
|
||||||
|
@ -78,12 +79,17 @@ client.on("ready", () => {
|
||||||
console.log(`${colors.cyan("[INFO]")} Left ${colors.green(guild.name)}`)
|
console.log(`${colors.cyan("[INFO]")} Left ${colors.green(guild.name)}`)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('interactionCreate', async (interaction) => {
|
client.on('interactionCreate', async (interaction) => {
|
||||||
if (!interaction.isCommand()) return;
|
if (!interaction.isCommand()) return;
|
||||||
if (interaction.guild !== null) {
|
if (interaction.guild !== null) {
|
||||||
if ((!config.discord.authorized_channels.includes(interaction.channelId) && !config.discord.authorized_channels.includes(interaction.channel.parentId))) return interaction.reply({ephemeral: true, content: lang.noauth}); // Only allow messages in the authorized channels
|
if ((!config.discord.authorized_channels.includes(interaction.channelId) && !config.discord.authorized_channels.includes(interaction.channel.parentId))) return interaction.reply({
|
||||||
|
ephemeral: true,
|
||||||
|
content: lang.noauth
|
||||||
|
}); // Only allow messages in the authorized channels
|
||||||
}
|
}
|
||||||
switch (interaction.commandName) {
|
switch (interaction.commandName) {
|
||||||
case "reset":
|
case "reset":
|
||||||
|
@ -96,7 +102,10 @@ client.on('interactionCreate', async (interaction) => {
|
||||||
await resetSession(interaction.channelId);
|
await resetSession(interaction.channelId);
|
||||||
interaction.reply(lang.reset);
|
interaction.reply(lang.reset);
|
||||||
} else {
|
} else {
|
||||||
interaction.reply({content: lang.busy, ephemeral: true});
|
interaction.reply({
|
||||||
|
content: lang.busy,
|
||||||
|
ephemeral: true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "info": // Info about the current session
|
case "info": // Info about the current session
|
||||||
|
@ -258,7 +267,10 @@ if (fs.existsSync(path.join(__dirname, "modPrompt.txt"))) {
|
||||||
// Handle SIGINT gracefully
|
// Handle SIGINT gracefully
|
||||||
process.on('SIGINT', async () => {
|
process.on('SIGINT', async () => {
|
||||||
await console.log(`${colors.cyan("[INFO]")} Stop received, exiting...`);
|
await console.log(`${colors.cyan("[INFO]")} Stop received, exiting...`);
|
||||||
await client.user.setPresence({status: "invisible", activities: []});
|
await client.user.setPresence({
|
||||||
|
status: "invisible",
|
||||||
|
activities: []
|
||||||
|
});
|
||||||
await client.destroy();
|
await client.destroy();
|
||||||
await console.log(`${colors.cyan("[INFO]")} Goodbye!`);
|
await console.log(`${colors.cyan("[INFO]")} Goodbye!`);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
|
|
Loading…
Reference in a new issue