Add a little bit of color :)
This commit is contained in:
parent
681142330c
commit
33fbad2a1e
31
index.js
31
index.js
|
@ -1,7 +1,7 @@
|
|||
//Load static files
|
||||
const config = require("./config.json");
|
||||
const funcs = require("./funcs.js");
|
||||
|
||||
const colors = require("colors");
|
||||
// FreePBX GraphQL Client
|
||||
const {
|
||||
FreepbxGqlClient,
|
||||
|
@ -213,21 +213,21 @@ const rest = new REST({
|
|||
}).setToken(config.discord.token);
|
||||
|
||||
dcClient.on('ready', () => {
|
||||
console.log(`Logged in as ${dcClient.user.tag}!`);
|
||||
console.log(`${colors.cyan("[INFO]")} Logged in as ${dcClient.user.tag}!`);
|
||||
// Set up application commands
|
||||
const commands = require('./commands.json');
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
console.log('Started refreshing application (/) commands.');
|
||||
console.log(`${colors.cyan("[INFO]")} Started refreshing application (/) commands.`);
|
||||
await rest.put(
|
||||
Routes.applicationGuildCommands(dcClient.user.id, config.discord.guildId), {
|
||||
body: commands
|
||||
}
|
||||
);
|
||||
console.log('Successfully reloaded application (/) commands.');
|
||||
console.log(`${colors.cyan("[INFO]")} Successfully reloaded application (/) commands.`);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
console.error(`${colors.red("[ERROR]")} ${error}`);
|
||||
}
|
||||
})();
|
||||
|
||||
|
@ -241,7 +241,7 @@ dcClient.on('ready', () => {
|
|||
status: "online"
|
||||
});
|
||||
}).catch((error) => {
|
||||
console.log(error);
|
||||
console.log(`${colors.red("[ERROR]")} ${error}`);
|
||||
});
|
||||
|
||||
// Run every 5 minutes
|
||||
|
@ -255,7 +255,7 @@ dcClient.on('ready', () => {
|
|||
status: "online"
|
||||
});
|
||||
}).catch((error) => {
|
||||
console.log(error);
|
||||
console.log(`${colors.red("[ERROR]")} ${error}`);
|
||||
});
|
||||
}, 300000);
|
||||
|
||||
|
@ -271,10 +271,11 @@ dcClient.on('ready', () => {
|
|||
// They're in the server, do nothing
|
||||
}).catch((error) => {
|
||||
// They're not in the server, delete the extension
|
||||
console.log(`${colors.cyan("[INFO]")} ${extension.user.extension} is not in the server, deleting it`);
|
||||
deleteExtension(extension.user.extension).then((result) => {
|
||||
console.log(`Deleted extension ${extension.user.extension} because the user is no longer in the server`);
|
||||
console.log(`${colors.cyan("[INFO]")} Deleted extension ${extension.user.extension} because the user is no longer in the server`);
|
||||
}).catch((error) => {
|
||||
console.log(error);
|
||||
console.log(`${colors.red("[ERROR]")} ${error}`);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -287,18 +288,18 @@ dcClient.on('ready', () => {
|
|||
|
||||
dcClient.on("guildMemberRemove", (member) => {
|
||||
// Delete the extension if the user leaves the server
|
||||
console.log(`User ${member.id} left the server`)
|
||||
console.log(`${colors.cyan("[INFO]")} User ${member.id} left the server`)
|
||||
lookupExtension(member.id, "uid").then((result) => {
|
||||
if (result.status == "exists") {
|
||||
console.log(`User ${member.id} has extension ${result.result.fetchVoiceMail.extension}, deleting it`)
|
||||
console.log(`${colors.cyan("[INFO]")} User ${member.id} has extension ${result.result.fetchVoiceMail.extension}, deleting it`)
|
||||
deleteExtension(result.result.fetchVoiceMail.extension).then((result) => {
|
||||
console.log(`Deleted extension ${result.result.fetchVoiceMail.extension} because the user left the server`);
|
||||
console.log(`${colors.cyan("[INFO]")} Deleted extension ${result.result.fetchVoiceMail.extension} because the user left the server`);
|
||||
}).catch((error) => {
|
||||
console.log(error);
|
||||
console.log(`${colors.red("[ERROR]")} ${error}`);
|
||||
});
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.log(error);
|
||||
console.log(`${colors.red("[ERROR]")} ${error}`);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -389,7 +390,7 @@ dcClient.on('interactionCreate', async interaction => {
|
|||
}
|
||||
}).catch((error) => {
|
||||
// The user doesn't have an extension, create one
|
||||
console.log(error)
|
||||
console.log(`${colors.red("[ERROR]")} ${error}`)
|
||||
interaction.editReply({
|
||||
content: "You don't have an extension!",
|
||||
ephemeral: true
|
||||
|
|
14
package-lock.json
generated
14
package-lock.json
generated
|
@ -9,6 +9,7 @@
|
|||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"colors": "^1.4.0",
|
||||
"discord.js": "^14.7.1",
|
||||
"freepbx-graphql-client": "^0.1.1",
|
||||
"sqlite3": "^5.1.4"
|
||||
|
@ -323,6 +324,14 @@
|
|||
"color-support": "bin.js"
|
||||
}
|
||||
},
|
||||
"node_modules/colors": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz",
|
||||
"integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==",
|
||||
"engines": {
|
||||
"node": ">=0.1.90"
|
||||
}
|
||||
},
|
||||
"node_modules/combined-stream": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
|
@ -1764,6 +1773,11 @@
|
|||
"resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz",
|
||||
"integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg=="
|
||||
},
|
||||
"colors": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz",
|
||||
"integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA=="
|
||||
},
|
||||
"combined-stream": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"colors": "^1.4.0",
|
||||
"discord.js": "^14.7.1",
|
||||
"freepbx-graphql-client": "^0.1.1",
|
||||
"sqlite3": "^5.1.4"
|
||||
|
|
Loading…
Reference in a new issue