From ce008917de9fb04f2965cb8908e5a1104794b8cd Mon Sep 17 00:00:00 2001 From: ikifar2012 Date: Wed, 13 Jul 2022 21:42:42 +0000 Subject: [PATCH 01/13] add chords and fix embed --- commands/chord.js | 29 ++++ embed.js | 2 +- package-lock.json | 403 +++++++++++++++++++++++++++++++++++++++++++++- package.json | 1 + 4 files changed, 432 insertions(+), 3 deletions(-) create mode 100644 commands/chord.js diff --git a/commands/chord.js b/commands/chord.js new file mode 100644 index 0000000..e224325 --- /dev/null +++ b/commands/chord.js @@ -0,0 +1,29 @@ +const { SlashCommandBuilder } = require('@discordjs/builders'); +const embedcreator = require('../embed.js'); +const { Chord } = require('@tonaljs/tonal'); + +module.exports = { + data: new SlashCommandBuilder() + .setName('chord') + .setDescription('Get chord info') + .addStringOption(option => + option.setName('chord') + .setDescription('Chord to get info for') + .setRequired(true), + ), + async execute(interaction) { + const chord = interaction.options.get('chord').value; + const chordInfo = Chord.get(chord); + if (chordInfo) { + console.log(chordInfo); + return interaction.reply({ + embeds: [embedcreator.setembed({ + title: `${chordInfo.name}`, + description: `**Notes:** ${chordInfo.notes.join(' ')} + **Intervals:** ${chordInfo.intervals.join(' ')}`, + })], + }); + } + + }, +}; \ No newline at end of file diff --git a/embed.js b/embed.js index b908902..22ca059 100644 --- a/embed.js +++ b/embed.js @@ -3,9 +3,9 @@ const merge = require('lodash.merge'); var setembed = function(opts){ var embed = { // Discord Embed Template Coda - color: 0x00ff00, title: '', description: '', + color: '#19ebfe', url: '', timestamp: `${new Date()}`, footer: { diff --git a/package-lock.json b/package-lock.json index 3550413..b720bff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,17 @@ { "name": "coda-utilities", - "version": "1.0.2", + "version": "1.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "coda-utilities", - "version": "1.0.2", + "version": "1.1.0", "license": "ISC", "dependencies": { "@discordjs/builders": "^0.15.0", "@discordjs/rest": "^0.5.0", + "@tonaljs/tonal": "^4.6.5", "discord-api-types": "^0.36.1", "discord.js": "^13.8.1", "emoji-unicode": "^2.0.1", @@ -161,6 +162,205 @@ "npm": ">=7.0.0" } }, + "node_modules/@tonaljs/abc-notation": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/abc-notation/-/abc-notation-4.6.5.tgz", + "integrity": "sha512-1S0Jnx0NfDLgyhkQOMEHqOacELL6RUdPcWWUP+nAnsOsb9owvB9RKYLSzp5odd16FVUR7U8c/JLc2yxIRvSeJw==", + "dependencies": { + "@tonaljs/core": "^4.6.5" + } + }, + "node_modules/@tonaljs/array": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/array/-/array-4.6.5.tgz", + "integrity": "sha512-7A3DbBQ+qIQ134FqE518b4tJ8V2a15Sn303JjHzgnqZqKrNh/s3wqwkL60F7LKcd09tcp+vIKQP/MYt4xMcRAA==", + "dependencies": { + "@tonaljs/core": "^4.6.5" + } + }, + "node_modules/@tonaljs/chord": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/chord/-/chord-4.6.5.tgz", + "integrity": "sha512-Pjdel4aDVv4kcx9PW6Qozt5BB9nAt13AOExfzKztpgPmlBSy0SKHse7Jp1cA4MGAuLHU8dzVssTFYpCskEFw3w==", + "dependencies": { + "@tonaljs/chord-detect": "^4.6.5", + "@tonaljs/chord-type": "^4.6.5", + "@tonaljs/collection": "^4.6.2", + "@tonaljs/core": "^4.6.5", + "@tonaljs/pcset": "^4.6.5", + "@tonaljs/scale-type": "^4.6.5" + } + }, + "node_modules/@tonaljs/chord-detect": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/chord-detect/-/chord-detect-4.6.5.tgz", + "integrity": "sha512-4xu53UP4kNTfdTNpAAVijhXcQ+ypJqmeMnsST08ZXSjoYfJUhmf5rWDWfz36KOTtNdCA6AbYgdtTYV/Xw0nd/w==", + "dependencies": { + "@tonaljs/chord-type": "^4.6.5", + "@tonaljs/core": "^4.6.5", + "@tonaljs/pcset": "^4.6.5" + } + }, + "node_modules/@tonaljs/chord-type": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/chord-type/-/chord-type-4.6.5.tgz", + "integrity": "sha512-Ol4DDopqpZCF9odosO2i8I+plud3Ul7VWJGNvL+PPCf4Qnwuz87q3aJQDLNoRUz4VyW0u66mq3LyVh6A8kb6Ug==", + "dependencies": { + "@tonaljs/core": "^4.6.5", + "@tonaljs/pcset": "^4.6.5" + } + }, + "node_modules/@tonaljs/collection": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/@tonaljs/collection/-/collection-4.6.2.tgz", + "integrity": "sha512-bfPCotLJNB/tG1NrdbsQPLDKZB5jlMs7uPQ6RYKiNkaena3345ZKkbCGl5pj6YTXeDm/oblXiSbFAn7SlLRZdQ==" + }, + "node_modules/@tonaljs/core": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/core/-/core-4.6.5.tgz", + "integrity": "sha512-t7Vx0+L3j/ubQj2AhI1H45D/K745np4DwJjJjXNi5FlGD+TL2wyw50dCwkHKGHsrLDqup1qqP6yN7LBpC6UwNg==" + }, + "node_modules/@tonaljs/duration-value": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/@tonaljs/duration-value/-/duration-value-4.6.2.tgz", + "integrity": "sha512-zrXT0L/qsDQ6251Mlqz54vcUbYUB9xb6uJhlxUzc6VauXOt8UOfrdTULubRTXTaBwWt1h8J5n9pXTQmNGzNI9A==" + }, + "node_modules/@tonaljs/interval": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/interval/-/interval-4.6.5.tgz", + "integrity": "sha512-7EDWhqZ7Nnh9oD4ahRYJHLc799ACGxYL4hDHwMKD16B2MgXqPvDeDvwQ31qUuO0ruGz8tMb3FDlgg0Hplowcbw==", + "dependencies": { + "@tonaljs/core": "^4.6.5" + } + }, + "node_modules/@tonaljs/key": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/key/-/key-4.6.5.tgz", + "integrity": "sha512-ZdZWb5IStx6CLRmdEjawR66CqNpoW3EVUua2nVZBMdgnNebWxt4nvgH/ZNvGlCQGFZkUZzRhCfTwqsS6e3OmSA==", + "dependencies": { + "@tonaljs/core": "^4.6.5", + "@tonaljs/note": "^4.6.5", + "@tonaljs/roman-numeral": "^4.6.5" + } + }, + "node_modules/@tonaljs/midi": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/midi/-/midi-4.6.5.tgz", + "integrity": "sha512-fJEZtNvV3M6yW1w+Tep60Rbv5PvuKszQcQzaJS1Loq5mHOKAzdmRfuJSpEpZBiaKEZ1WAMh1QKXYyOd+imyGQg==", + "dependencies": { + "@tonaljs/core": "^4.6.5" + } + }, + "node_modules/@tonaljs/mode": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/mode/-/mode-4.6.5.tgz", + "integrity": "sha512-54iaON1rJ6q8fV5iuei8RGDxYhKBGGxZz3rjAxGSqdTUwBRVOdPqtzOkofThf9gRGYOMhzPp1BMbxbV+UCAPsA==", + "dependencies": { + "@tonaljs/collection": "^4.6.2", + "@tonaljs/core": "^4.6.5", + "@tonaljs/interval": "^4.6.5", + "@tonaljs/pcset": "^4.6.5", + "@tonaljs/scale-type": "^4.6.5" + } + }, + "node_modules/@tonaljs/note": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/note/-/note-4.6.5.tgz", + "integrity": "sha512-Y0/eTzcReXzfcSLLG4k/dLLayqbvh/XYIkybG/QMDyR0BREuJq0Sw+NavbzhTtO0dadIQb/qfe0GFq4k2xS+NQ==", + "dependencies": { + "@tonaljs/core": "^4.6.5", + "@tonaljs/midi": "^4.6.5" + } + }, + "node_modules/@tonaljs/pcset": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/pcset/-/pcset-4.6.5.tgz", + "integrity": "sha512-oWAKflP3cREnUfScqsBzg2LLKNevxSnpDtrq8CPtwOAsrAa8PjQG07NQfhqIiFMjPUdgkDiER3qVA1n8dDwAJA==", + "dependencies": { + "@tonaljs/collection": "^4.6.2", + "@tonaljs/core": "^4.6.5" + } + }, + "node_modules/@tonaljs/progression": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/progression/-/progression-4.6.5.tgz", + "integrity": "sha512-ijYEgMFQG4izHYUw5cRtBRNBuoYzmpGvb/tRiykhJNI6XIjekZEMiMsOMfb1u5q+EGvnVNXRmrluMRDIz2rmRw==", + "dependencies": { + "@tonaljs/chord": "^4.6.5", + "@tonaljs/core": "^4.6.5", + "@tonaljs/roman-numeral": "^4.6.5" + } + }, + "node_modules/@tonaljs/range": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/range/-/range-4.6.5.tgz", + "integrity": "sha512-99cOvVJ3l4X0UJuTSa6qE87JriREnnWIsi3xo1/n7RoqFxnfi8YPh4SfJJyysvHcT18X4EfcTNde9ancMBVu6A==", + "dependencies": { + "@tonaljs/collection": "^4.6.2", + "@tonaljs/midi": "^4.6.5" + } + }, + "node_modules/@tonaljs/roman-numeral": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/roman-numeral/-/roman-numeral-4.6.5.tgz", + "integrity": "sha512-bWYQNZWKmYDDcmbQQNwcWAHfTWanpzmvI0wplrMnGd4x0op5etwUEv+Yzjg0B1ef+E+zcU02Sl0WwRJhaDK3hg==", + "dependencies": { + "@tonaljs/core": "^4.6.5" + } + }, + "node_modules/@tonaljs/scale": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/scale/-/scale-4.6.5.tgz", + "integrity": "sha512-isYDamelOBtcd5bEnJ8QV0Js7jKRwZ0FlFVE/+bUN3wsyo9u6KLL5gMyfH9RKdx74m8lE13JXYTXgKqe+AOa4A==", + "dependencies": { + "@tonaljs/chord-type": "^4.6.5", + "@tonaljs/collection": "^4.6.2", + "@tonaljs/core": "^4.6.5", + "@tonaljs/note": "^4.6.5", + "@tonaljs/pcset": "^4.6.5", + "@tonaljs/scale-type": "^4.6.5" + } + }, + "node_modules/@tonaljs/scale-type": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/scale-type/-/scale-type-4.6.5.tgz", + "integrity": "sha512-rwcDOYf2UifjLJhmuQ8f8bJSeOCMDQJ1lB7lzlqdFxes03OeQhdOEfrT0nPtW8BhBEvq4GMM2NA6CLxX8MTwOQ==", + "dependencies": { + "@tonaljs/core": "^4.6.5", + "@tonaljs/pcset": "^4.6.5" + } + }, + "node_modules/@tonaljs/time-signature": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/@tonaljs/time-signature/-/time-signature-4.6.2.tgz", + "integrity": "sha512-OlZY4gdLd21WpMeAI1nS9E9zWcYU6oAzh6ptAUndqmVnFIrIWIWKCkWapdFx8dWdqrX8jqya3m4T33wmeo7w5Q==" + }, + "node_modules/@tonaljs/tonal": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/tonal/-/tonal-4.6.5.tgz", + "integrity": "sha512-lmsWinI9dy7nQyzCEgDVeVAwJtsk4ey05cJZd6oa4QVuSFD+CR8ebaEiwT4/Na+W0kHrKicT3h0uYc2PJIvx5Q==", + "dependencies": { + "@tonaljs/abc-notation": "^4.6.5", + "@tonaljs/array": "^4.6.5", + "@tonaljs/chord": "^4.6.5", + "@tonaljs/chord-type": "^4.6.5", + "@tonaljs/collection": "^4.6.2", + "@tonaljs/core": "^4.6.5", + "@tonaljs/duration-value": "^4.6.2", + "@tonaljs/interval": "^4.6.5", + "@tonaljs/key": "^4.6.5", + "@tonaljs/midi": "^4.6.5", + "@tonaljs/mode": "^4.6.5", + "@tonaljs/note": "^4.6.5", + "@tonaljs/pcset": "^4.6.5", + "@tonaljs/progression": "^4.6.5", + "@tonaljs/range": "^4.6.5", + "@tonaljs/roman-numeral": "^4.6.5", + "@tonaljs/scale": "^4.6.5", + "@tonaljs/scale-type": "^4.6.5", + "@tonaljs/time-signature": "^4.6.2" + } + }, "node_modules/@types/geojson": { "version": "7946.0.8", "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.8.tgz", @@ -1741,6 +1941,205 @@ "resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.2.2.tgz", "integrity": "sha512-ula2O0kpSZtX9rKXNeQMrHwNd7E4jPDJYUXmEGTFdMRfyfMw+FPyh04oKMjAiDuOi64bYgVkOV3MjK+loImFhQ==" }, + "@tonaljs/abc-notation": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/abc-notation/-/abc-notation-4.6.5.tgz", + "integrity": "sha512-1S0Jnx0NfDLgyhkQOMEHqOacELL6RUdPcWWUP+nAnsOsb9owvB9RKYLSzp5odd16FVUR7U8c/JLc2yxIRvSeJw==", + "requires": { + "@tonaljs/core": "^4.6.5" + } + }, + "@tonaljs/array": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/array/-/array-4.6.5.tgz", + "integrity": "sha512-7A3DbBQ+qIQ134FqE518b4tJ8V2a15Sn303JjHzgnqZqKrNh/s3wqwkL60F7LKcd09tcp+vIKQP/MYt4xMcRAA==", + "requires": { + "@tonaljs/core": "^4.6.5" + } + }, + "@tonaljs/chord": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/chord/-/chord-4.6.5.tgz", + "integrity": "sha512-Pjdel4aDVv4kcx9PW6Qozt5BB9nAt13AOExfzKztpgPmlBSy0SKHse7Jp1cA4MGAuLHU8dzVssTFYpCskEFw3w==", + "requires": { + "@tonaljs/chord-detect": "^4.6.5", + "@tonaljs/chord-type": "^4.6.5", + "@tonaljs/collection": "^4.6.2", + "@tonaljs/core": "^4.6.5", + "@tonaljs/pcset": "^4.6.5", + "@tonaljs/scale-type": "^4.6.5" + } + }, + "@tonaljs/chord-detect": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/chord-detect/-/chord-detect-4.6.5.tgz", + "integrity": "sha512-4xu53UP4kNTfdTNpAAVijhXcQ+ypJqmeMnsST08ZXSjoYfJUhmf5rWDWfz36KOTtNdCA6AbYgdtTYV/Xw0nd/w==", + "requires": { + "@tonaljs/chord-type": "^4.6.5", + "@tonaljs/core": "^4.6.5", + "@tonaljs/pcset": "^4.6.5" + } + }, + "@tonaljs/chord-type": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/chord-type/-/chord-type-4.6.5.tgz", + "integrity": "sha512-Ol4DDopqpZCF9odosO2i8I+plud3Ul7VWJGNvL+PPCf4Qnwuz87q3aJQDLNoRUz4VyW0u66mq3LyVh6A8kb6Ug==", + "requires": { + "@tonaljs/core": "^4.6.5", + "@tonaljs/pcset": "^4.6.5" + } + }, + "@tonaljs/collection": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/@tonaljs/collection/-/collection-4.6.2.tgz", + "integrity": "sha512-bfPCotLJNB/tG1NrdbsQPLDKZB5jlMs7uPQ6RYKiNkaena3345ZKkbCGl5pj6YTXeDm/oblXiSbFAn7SlLRZdQ==" + }, + "@tonaljs/core": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/core/-/core-4.6.5.tgz", + "integrity": "sha512-t7Vx0+L3j/ubQj2AhI1H45D/K745np4DwJjJjXNi5FlGD+TL2wyw50dCwkHKGHsrLDqup1qqP6yN7LBpC6UwNg==" + }, + "@tonaljs/duration-value": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/@tonaljs/duration-value/-/duration-value-4.6.2.tgz", + "integrity": "sha512-zrXT0L/qsDQ6251Mlqz54vcUbYUB9xb6uJhlxUzc6VauXOt8UOfrdTULubRTXTaBwWt1h8J5n9pXTQmNGzNI9A==" + }, + "@tonaljs/interval": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/interval/-/interval-4.6.5.tgz", + "integrity": "sha512-7EDWhqZ7Nnh9oD4ahRYJHLc799ACGxYL4hDHwMKD16B2MgXqPvDeDvwQ31qUuO0ruGz8tMb3FDlgg0Hplowcbw==", + "requires": { + "@tonaljs/core": "^4.6.5" + } + }, + "@tonaljs/key": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/key/-/key-4.6.5.tgz", + "integrity": "sha512-ZdZWb5IStx6CLRmdEjawR66CqNpoW3EVUua2nVZBMdgnNebWxt4nvgH/ZNvGlCQGFZkUZzRhCfTwqsS6e3OmSA==", + "requires": { + "@tonaljs/core": "^4.6.5", + "@tonaljs/note": "^4.6.5", + "@tonaljs/roman-numeral": "^4.6.5" + } + }, + "@tonaljs/midi": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/midi/-/midi-4.6.5.tgz", + "integrity": "sha512-fJEZtNvV3M6yW1w+Tep60Rbv5PvuKszQcQzaJS1Loq5mHOKAzdmRfuJSpEpZBiaKEZ1WAMh1QKXYyOd+imyGQg==", + "requires": { + "@tonaljs/core": "^4.6.5" + } + }, + "@tonaljs/mode": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/mode/-/mode-4.6.5.tgz", + "integrity": "sha512-54iaON1rJ6q8fV5iuei8RGDxYhKBGGxZz3rjAxGSqdTUwBRVOdPqtzOkofThf9gRGYOMhzPp1BMbxbV+UCAPsA==", + "requires": { + "@tonaljs/collection": "^4.6.2", + "@tonaljs/core": "^4.6.5", + "@tonaljs/interval": "^4.6.5", + "@tonaljs/pcset": "^4.6.5", + "@tonaljs/scale-type": "^4.6.5" + } + }, + "@tonaljs/note": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/note/-/note-4.6.5.tgz", + "integrity": "sha512-Y0/eTzcReXzfcSLLG4k/dLLayqbvh/XYIkybG/QMDyR0BREuJq0Sw+NavbzhTtO0dadIQb/qfe0GFq4k2xS+NQ==", + "requires": { + "@tonaljs/core": "^4.6.5", + "@tonaljs/midi": "^4.6.5" + } + }, + "@tonaljs/pcset": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/pcset/-/pcset-4.6.5.tgz", + "integrity": "sha512-oWAKflP3cREnUfScqsBzg2LLKNevxSnpDtrq8CPtwOAsrAa8PjQG07NQfhqIiFMjPUdgkDiER3qVA1n8dDwAJA==", + "requires": { + "@tonaljs/collection": "^4.6.2", + "@tonaljs/core": "^4.6.5" + } + }, + "@tonaljs/progression": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/progression/-/progression-4.6.5.tgz", + "integrity": "sha512-ijYEgMFQG4izHYUw5cRtBRNBuoYzmpGvb/tRiykhJNI6XIjekZEMiMsOMfb1u5q+EGvnVNXRmrluMRDIz2rmRw==", + "requires": { + "@tonaljs/chord": "^4.6.5", + "@tonaljs/core": "^4.6.5", + "@tonaljs/roman-numeral": "^4.6.5" + } + }, + "@tonaljs/range": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/range/-/range-4.6.5.tgz", + "integrity": "sha512-99cOvVJ3l4X0UJuTSa6qE87JriREnnWIsi3xo1/n7RoqFxnfi8YPh4SfJJyysvHcT18X4EfcTNde9ancMBVu6A==", + "requires": { + "@tonaljs/collection": "^4.6.2", + "@tonaljs/midi": "^4.6.5" + } + }, + "@tonaljs/roman-numeral": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/roman-numeral/-/roman-numeral-4.6.5.tgz", + "integrity": "sha512-bWYQNZWKmYDDcmbQQNwcWAHfTWanpzmvI0wplrMnGd4x0op5etwUEv+Yzjg0B1ef+E+zcU02Sl0WwRJhaDK3hg==", + "requires": { + "@tonaljs/core": "^4.6.5" + } + }, + "@tonaljs/scale": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/scale/-/scale-4.6.5.tgz", + "integrity": "sha512-isYDamelOBtcd5bEnJ8QV0Js7jKRwZ0FlFVE/+bUN3wsyo9u6KLL5gMyfH9RKdx74m8lE13JXYTXgKqe+AOa4A==", + "requires": { + "@tonaljs/chord-type": "^4.6.5", + "@tonaljs/collection": "^4.6.2", + "@tonaljs/core": "^4.6.5", + "@tonaljs/note": "^4.6.5", + "@tonaljs/pcset": "^4.6.5", + "@tonaljs/scale-type": "^4.6.5" + } + }, + "@tonaljs/scale-type": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/scale-type/-/scale-type-4.6.5.tgz", + "integrity": "sha512-rwcDOYf2UifjLJhmuQ8f8bJSeOCMDQJ1lB7lzlqdFxes03OeQhdOEfrT0nPtW8BhBEvq4GMM2NA6CLxX8MTwOQ==", + "requires": { + "@tonaljs/core": "^4.6.5", + "@tonaljs/pcset": "^4.6.5" + } + }, + "@tonaljs/time-signature": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/@tonaljs/time-signature/-/time-signature-4.6.2.tgz", + "integrity": "sha512-OlZY4gdLd21WpMeAI1nS9E9zWcYU6oAzh6ptAUndqmVnFIrIWIWKCkWapdFx8dWdqrX8jqya3m4T33wmeo7w5Q==" + }, + "@tonaljs/tonal": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/@tonaljs/tonal/-/tonal-4.6.5.tgz", + "integrity": "sha512-lmsWinI9dy7nQyzCEgDVeVAwJtsk4ey05cJZd6oa4QVuSFD+CR8ebaEiwT4/Na+W0kHrKicT3h0uYc2PJIvx5Q==", + "requires": { + "@tonaljs/abc-notation": "^4.6.5", + "@tonaljs/array": "^4.6.5", + "@tonaljs/chord": "^4.6.5", + "@tonaljs/chord-type": "^4.6.5", + "@tonaljs/collection": "^4.6.2", + "@tonaljs/core": "^4.6.5", + "@tonaljs/duration-value": "^4.6.2", + "@tonaljs/interval": "^4.6.5", + "@tonaljs/key": "^4.6.5", + "@tonaljs/midi": "^4.6.5", + "@tonaljs/mode": "^4.6.5", + "@tonaljs/note": "^4.6.5", + "@tonaljs/pcset": "^4.6.5", + "@tonaljs/progression": "^4.6.5", + "@tonaljs/range": "^4.6.5", + "@tonaljs/roman-numeral": "^4.6.5", + "@tonaljs/scale": "^4.6.5", + "@tonaljs/scale-type": "^4.6.5", + "@tonaljs/time-signature": "^4.6.2" + } + }, "@types/geojson": { "version": "7946.0.8", "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.8.tgz", diff --git a/package.json b/package.json index e62693c..970c443 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "dependencies": { "@discordjs/builders": "^0.15.0", "@discordjs/rest": "^0.5.0", + "@tonaljs/tonal": "^4.6.5", "discord-api-types": "^0.36.1", "discord.js": "^13.8.1", "emoji-unicode": "^2.0.1", From 5b3482a8872cf0a41dbd396ea8edaf2d8c5f5a51 Mon Sep 17 00:00:00 2001 From: ikifar2012 Date: Thu, 14 Jul 2022 01:02:46 +0000 Subject: [PATCH 02/13] laying the groundwork for botgate --- commands/botgate.js | 111 +++++++++++++++++++++++++++++++++++++++++++ index.js | 2 + utilities/botgate.js | 14 ++++++ 3 files changed, 127 insertions(+) create mode 100644 commands/botgate.js create mode 100644 utilities/botgate.js diff --git a/commands/botgate.js b/commands/botgate.js new file mode 100644 index 0000000..b9f7da2 --- /dev/null +++ b/commands/botgate.js @@ -0,0 +1,111 @@ +const { SlashCommandBuilder } = require('@discordjs/builders'); +const mariadb = require('../db.js'); +const env = require('../env.js'); +const embedcreator = require('../embed.js'); +const botgate = require('../utilities/botgate.js'); +module.exports = { + data: new SlashCommandBuilder() + .setName('botgate') + .setDescription('botgate command') + .addSubcommand(subcommand => + subcommand + .setName('status') + .setDescription('Get the status of the botgate'), + ) + .addSubcommand(subcommand => + subcommand + .setName('set') + .setDescription('Set the status of the botgate') + .addBooleanOption(option => + option.setName('botgate') + .setDescription('Enable or disable botgate'), + ), + ), + async execute(interaction) { + // Limit command to Founders and Mods + if (!(interaction.member.roles.cache.has(env.discord.admin_role) || interaction.member.roles.cache.has(env.discord.mod_role))) { + global.client.channels.cache.get(env.discord.logs_channel).send({ + embeds: [ embedcreator.setembed( + { + title: 'Incident Detected', + description: `${interaction.member.user} tried to use the botgate command but did not have the correct role.`, + color: '#e74c3c', + }, + )], + }, + ); + return interaction.reply({ + embeds: [ embedcreator.setembed( + { + title: 'Incident Reported', + description: 'You do not have permission to use this command. This incident has been reported.', + color: '#e74c3c', + }, + ), + ], ephemeral: true, + }); + } + const subcommand = interaction.options.getSubcommand(); + if (subcommand === 'set') { + if (interaction.options.get('botgate')) { + const botgatevalue = interaction.options.get('botgate').value; + // check if botgate setting exists + db = await mariadb.getConnection(); + const exists = await db.query('SELECT * FROM settings WHERE setting = ?', ['botgate']); + db.end(); + if (exists.length == 0) { + // create botgate setting + db = await mariadb.getConnection(); + await db.query('INSERT INTO settings (setting, value) VALUES (?, ?)', ['botgate', 0]); + db.end(); + } + if (botgatevalue === true) { + db = await mariadb.getConnection(); + db.query('UPDATE settings SET value = ? WHERE setting = ?', [1, 'botgate']); + db.end(); + return interaction.reply({ + embeds: [embedcreator.setembed({ + title: 'Botgate Enabled', + description: 'Botgate is now enabled.', + color: '#19ebfe', + })], + }); + } + if (botgatevalue === false) { + db = await mariadb.getConnection(); + db.query('UPDATE settings SET value = ? WHERE setting = ?', [0, 'botgate']); + db.end(); + return interaction.reply({ + embeds: [embedcreator.setembed({ + title: 'Botgate Disabled', + description: 'Botgate is now disabled.', + color: '#19ebfe', + })], + }); + } + } + } + if (subcommand === 'status') { + // check if botgate is enabled + botgatestatus = await botgate.status(); + if (botgatestatus) { + return interaction.reply({ + embeds: [embedcreator.setembed({ + title: 'Botgate Status', + description: 'Botgate is enabled.', + color: '#19ebfe', + })], + }); + } + else { + return interaction.reply({ + embeds: [embedcreator.setembed({ + title: 'Botgate Status', + description: 'Botgate is disabled.', + color: '#19ebfe', + })], + }); + } + } + }, +}; \ No newline at end of file diff --git a/index.js b/index.js index a0cbf44..ab39ef4 100644 --- a/index.js +++ b/index.js @@ -30,6 +30,8 @@ global.client.once('ready', async () => { await db.query('CREATE TABLE IF NOT EXISTS roles (id VARCHAR(255) PRIMARY KEY, emoji VARCHAR(255), raw_emoji VARCHAR(255), message_id VARCHAR(255), channel_id VARCHAR(255)) COLLATE utf8mb4_general_ci CHARSET utf8mb4;'); // create notify table if it doesn't exist await db.query('CREATE TABLE IF NOT EXISTS notify (user_id VARCHAR(255) PRIMARY KEY, name VARCHAR(255))'); + // create settings table if it doesn't exist + await db.query('CREATE TABLE IF NOT EXISTS settings (setting VARCHAR(255) PRIMARY KEY, value BOOLEAN)'); db.end(); } )(); diff --git a/utilities/botgate.js b/utilities/botgate.js new file mode 100644 index 0000000..c466285 --- /dev/null +++ b/utilities/botgate.js @@ -0,0 +1,14 @@ +const mariadb = require('../db.js'); + +// check if botgate is enabled +async function status() { + db = await mariadb.getConnection(); + const botgatestatus = await db.query('SELECT value FROM settings WHERE setting = ?', ['botgate']); + db.end(); + if (botgatestatus[0].value == 1) { + return true; + } + return false; +} + +module.exports = { status }; \ No newline at end of file From 41bcdb2b9bac1f4cacf9371458a531996d1aac83 Mon Sep 17 00:00:00 2001 From: ikifar2012 Date: Thu, 14 Jul 2022 02:03:56 +0000 Subject: [PATCH 03/13] make chords better --- commands/chord.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/commands/chord.js b/commands/chord.js index e224325..84656eb 100644 --- a/commands/chord.js +++ b/commands/chord.js @@ -14,7 +14,7 @@ module.exports = { async execute(interaction) { const chord = interaction.options.get('chord').value; const chordInfo = Chord.get(chord); - if (chordInfo) { + if (chordInfo && chordInfo.type) { console.log(chordInfo); return interaction.reply({ embeds: [embedcreator.setembed({ @@ -24,6 +24,13 @@ module.exports = { })], }); } - + embedcreator.log(`${interaction.member.user} used the chord command\nparameters: ${chord}\n error: ${JSON.stringify(chordInfo)}`); + return interaction.reply({ + embeds: [embedcreator.setembed({ + title: 'Error', + description: `Could not find chord ${chord}`, + color: '#e74c3c', + })], + }); }, }; \ No newline at end of file From cfcce91b4f12f4561c6ed50b7e14fbb39d334faf Mon Sep 17 00:00:00 2001 From: ikifar2012 Date: Thu, 14 Jul 2022 02:04:34 +0000 Subject: [PATCH 04/13] switch to vars --- embed.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/embed.js b/embed.js index 22ca059..030b386 100644 --- a/embed.js +++ b/embed.js @@ -17,7 +17,7 @@ var setembed = function(opts){ }; var sendError = function(message){ try { - const embed = setembed({ + var embed = setembed({ title: 'Error', description: `${message}`, color: '#e74c3c', @@ -29,7 +29,7 @@ var sendError = function(message){ } }; var log = function(message){ - const embed = setembed({ + var embed = setembed({ title: 'Log', description: `${message}`, color: '#19ebfe', From c4100f982ae3fc7eb5a4ad180d1eb55a1d7899fc Mon Sep 17 00:00:00 2001 From: ikifar2012 Date: Thu, 14 Jul 2022 02:05:24 +0000 Subject: [PATCH 05/13] botgate works now --- commands/botgate.js | 11 ++++++----- index.js | 17 +++++++++++++++++ utilities/greet.js | 24 +++++++++++++++++++++++- 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/commands/botgate.js b/commands/botgate.js index b9f7da2..89f1a3c 100644 --- a/commands/botgate.js +++ b/commands/botgate.js @@ -18,7 +18,8 @@ module.exports = { .setDescription('Set the status of the botgate') .addBooleanOption(option => option.setName('botgate') - .setDescription('Enable or disable botgate'), + .setDescription('Enable or disable botgate') + .setRequired(true), ), ), async execute(interaction) { @@ -68,7 +69,7 @@ module.exports = { title: 'Botgate Enabled', description: 'Botgate is now enabled.', color: '#19ebfe', - })], + })], ephemeral: true, }); } if (botgatevalue === false) { @@ -80,7 +81,7 @@ module.exports = { title: 'Botgate Disabled', description: 'Botgate is now disabled.', color: '#19ebfe', - })], + })], ephemeral: true, }); } } @@ -94,7 +95,7 @@ module.exports = { title: 'Botgate Status', description: 'Botgate is enabled.', color: '#19ebfe', - })], + })], ephemeral: true, }); } else { @@ -103,7 +104,7 @@ module.exports = { title: 'Botgate Status', description: 'Botgate is disabled.', color: '#19ebfe', - })], + })], ephemeral: true, }); } } diff --git a/index.js b/index.js index ab39ef4..349c8af 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,7 @@ const mariadb = require('./db.js'); const greet = require('./utilities/greet.js'); const embedcreator = require('./embed.js'); const emojiUnicode = require('emoji-unicode'); +const botgate = require('./utilities/botgate.js'); global.client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_VOICE_STATES], partials: ['MESSAGE', 'CHANNEL', 'REACTION'], @@ -68,6 +69,22 @@ const rest = new REST({ version: '9' }).setToken(env.discord.token); })(); global.client.on('guildMemberAdd', async member => { + // check if member is a bot + if (member.user.bot) { + botgatestatus = await botgate.status(); + console.log(`${member.user.tag} is a bot.`); + if (botgatestatus === true) { + console.log('Botgate is enabled.'); + console.log('Kicking bot...'); + member.kick('Botgate is enabled.'); + console.log('Kicked bot.'); + return greet.sendKickAlert(member); + } + else { + console.log('Botgate is disabled.'); + } + + } const guild = global.client.guilds.cache.get(env.discord.guild); greet.sendNotify(member); diff --git a/utilities/greet.js b/utilities/greet.js index 1ebc71b..e407bdb 100644 --- a/utilities/greet.js +++ b/utilities/greet.js @@ -34,4 +34,26 @@ async function sendNotify(member) { ); } } -module.exports = { sendNotify, getUsers }; \ No newline at end of file +async function sendKickAlert(member) { + const users = await getUsers(); + for (userId of users) { + console.log(userId); + const user = await global.client.users.fetch(userId); + user.send( + { + embeds: [ embedcreator.setembed( + { + title: 'Bot Kicked', + description: `${member.user} joined ${global.client.guilds.cache.get(env.discord.guild).name} and was kicked due to botgate being enabled`, + color: '#e74c3c', + image: { + url: `${member.user.avatarURL({ dynamic: true })}`, + }, + }, + )], + }, + ); + + } +} +module.exports = { sendNotify, getUsers, sendKickAlert }; \ No newline at end of file From 1c76ebcc7ed52b86d27a75f1564700be468c50c9 Mon Sep 17 00:00:00 2001 From: ikifar2012 Date: Thu, 14 Jul 2022 03:34:38 +0000 Subject: [PATCH 06/13] Add alert embed --- embed.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/embed.js b/embed.js index 030b386..420b43d 100644 --- a/embed.js +++ b/embed.js @@ -36,4 +36,12 @@ var log = function(message){ }); global.client.channels.cache.get(env.discord.logs_channel).send({ embeds: [embed] }); }; -module.exports = { setembed, sendError, log }; \ No newline at end of file +var alert = function(message){ + var embed = setembed({ + title: '🚨 Alert 🚨', + description: `${message}`, + color: '#e74c3c', + }); + global.client.channels.cache.get(env.discord.logs_channel).send({ content: '🚨 Critical Alert 🚨' + '\n<@&' + env.discord.admin_role + '> <@&' + env.discord.mod_role + '>', embeds: [embed] }); +}; +module.exports = { setembed, sendError, log, alert }; From 8cb6d427aab426fc98bc73bd650ccb7fd9bc4878 Mon Sep 17 00:00:00 2001 From: ikifar2012 Date: Thu, 14 Jul 2022 03:35:17 +0000 Subject: [PATCH 07/13] add rich embeds for bot kicked/added --- utilities/greet.js | 55 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/utilities/greet.js b/utilities/greet.js index e407bdb..711ee63 100644 --- a/utilities/greet.js +++ b/utilities/greet.js @@ -41,6 +41,21 @@ async function sendKickAlert(member) { const user = await global.client.users.fetch(userId); user.send( { + embeds: [ embedcreator.setembed( + { + title: '🚨 Bot Kicked 🚨', + description: `${member.user} joined ${global.client.guilds.cache.get(env.discord.guild).name} and was kicked due to botgate being enabled`, + color: '#e74c3c', + image: { + url: `${member.user.avatarURL({ dynamic: true })}`, + }, + }, + )], + }, + ); + global.client.users.cache.get(env.discord.logs_channel).send( + { + content: '🚨 Bot Kicked from Server 🚨' + '\n<@&' + env.discord.admin_role + '> <@&' + env.discord.mod_role + '>', embeds: [ embedcreator.setembed( { title: 'Bot Kicked', @@ -53,7 +68,43 @@ async function sendKickAlert(member) { )], }, ); - } } -module.exports = { sendNotify, getUsers, sendKickAlert }; \ No newline at end of file +async function SendNewBotAlert(member) { + const users = await getUsers(); + for (userId of users) { + console.log(userId); + const user = await global.client.users.fetch(userId); + user.send( + { + embeds: [ embedcreator.setembed( + { + title: '🚨 Bot Added 🚨', + description: `Botgate was disabled and ${member.user} joined ${global.client.guilds.cache.get(env.discord.guild).name}, please re-enable botgate as soon as possible`, + color: '#2ecc71', + image: { + url: `${member.user.avatarURL({ dynamic: true })}`, + }, + }, + )], + }, + ); + global.client.channels.cache.get(env.discord.logs_channel).send( + { + content: '🚨 Bot Added to Server 🚨' + '\n<@&' + env.discord.admin_role + '> <@&' + env.discord.mod_role + '>', + embeds: [ embedcreator.setembed( + { + title: '🚨 Bot Added 🚨', + description: `Botgate was disabled and ${member.user} joined ${global.client.guilds.cache.get(env.discord.guild).name}, please re-enable botgate as soon as possible`, + color: '#2ecc71', + image: { + url: `${member.user.avatarURL({ dynamic: true })}`, + }, + }, + )], + }, + ); + } +} + +module.exports = { sendNotify, getUsers, sendKickAlert, SendNewBotAlert }; \ No newline at end of file From f0f6325842d08099f5c6c8935e53027ab86ec4b0 Mon Sep 17 00:00:00 2001 From: ikifar2012 Date: Thu, 14 Jul 2022 03:35:51 +0000 Subject: [PATCH 08/13] send new bot alert --- index.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 349c8af..d09ceca 100644 --- a/index.js +++ b/index.js @@ -69,6 +69,7 @@ const rest = new REST({ version: '9' }).setToken(env.discord.token); })(); global.client.on('guildMemberAdd', async member => { + // check if member is a bot if (member.user.bot) { botgatestatus = await botgate.status(); @@ -82,13 +83,15 @@ global.client.on('guildMemberAdd', async member => { } else { console.log('Botgate is disabled.'); + const guild = global.client.guilds.cache.get(env.discord.guild); + const members = await guild.members.fetch(); + global.client.user.setActivity(`${members.size} members`, { type: 'WATCHING' }); + return greet.SendNewBotAlert(member); } - } - const guild = global.client.guilds.cache.get(env.discord.guild); - greet.sendNotify(member); // Update presence + const guild = global.client.guilds.cache.get(env.discord.guild); const members = await guild.members.fetch(); global.client.user.setActivity(`${members.size} members`, { type: 'WATCHING' }); }, From 24f9fcce0b5bcc9081f03413c97d14c1a9462cec Mon Sep 17 00:00:00 2001 From: ikifar2012 Date: Thu, 14 Jul 2022 03:36:21 +0000 Subject: [PATCH 09/13] color code and fix messages --- commands/botgate.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/commands/botgate.js b/commands/botgate.js index 89f1a3c..303afa7 100644 --- a/commands/botgate.js +++ b/commands/botgate.js @@ -64,11 +64,12 @@ module.exports = { db = await mariadb.getConnection(); db.query('UPDATE settings SET value = ? WHERE setting = ?', [1, 'botgate']); db.end(); + embedcreator.alert(`Botgate Enabled by ${interaction.member.user}`); return interaction.reply({ embeds: [embedcreator.setembed({ title: 'Botgate Enabled', description: 'Botgate is now enabled.', - color: '#19ebfe', + color: '#2ecc71', })], ephemeral: true, }); } @@ -76,11 +77,12 @@ module.exports = { db = await mariadb.getConnection(); db.query('UPDATE settings SET value = ? WHERE setting = ?', [0, 'botgate']); db.end(); + embedcreator.alert(`Botgate Disabled by ${interaction.member.user}`); return interaction.reply({ embeds: [embedcreator.setembed({ title: 'Botgate Disabled', description: 'Botgate is now disabled.', - color: '#19ebfe', + color: '#e74c3c', })], ephemeral: true, }); } @@ -94,7 +96,7 @@ module.exports = { embeds: [embedcreator.setembed({ title: 'Botgate Status', description: 'Botgate is enabled.', - color: '#19ebfe', + color: '#2ecc71', })], ephemeral: true, }); } @@ -103,7 +105,7 @@ module.exports = { embeds: [embedcreator.setembed({ title: 'Botgate Status', description: 'Botgate is disabled.', - color: '#19ebfe', + color: '#e74c3c', })], ephemeral: true, }); } From 54e7032660e4b8c381f21879ab6f50769b01b975 Mon Sep 17 00:00:00 2001 From: ikifar2012 Date: Thu, 14 Jul 2022 03:37:27 +0000 Subject: [PATCH 10/13] bump version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index b720bff..d2e8a15 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "coda-utilities", - "version": "1.1.0", + "version": "1.2.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "coda-utilities", - "version": "1.1.0", + "version": "1.2.0", "license": "ISC", "dependencies": { "@discordjs/builders": "^0.15.0", diff --git a/package.json b/package.json index 970c443..9e53313 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coda-utilities", - "version": "1.1.0", + "version": "1.2.0", "description": "A general utilities bot for Coda", "main": "index.js", "scripts": { From 96339ff83e0d285aa3c6d1d9e118f9f00e3e4d92 Mon Sep 17 00:00:00 2001 From: ikifar2012 Date: Thu, 14 Jul 2022 03:51:30 +0000 Subject: [PATCH 11/13] update branding --- index.js | 10 ++++++++++ package-lock.json | 14 ++++++++++++++ package.json | 5 +++++ 3 files changed, 29 insertions(+) diff --git a/index.js b/index.js index d09ceca..025d132 100644 --- a/index.js +++ b/index.js @@ -7,12 +7,22 @@ const mariadb = require('./db.js'); const greet = require('./utilities/greet.js'); const embedcreator = require('./embed.js'); const emojiUnicode = require('emoji-unicode'); +const figlet = require('figlet'); const botgate = require('./utilities/botgate.js'); +const pkg = require('./package.json'); global.client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_VOICE_STATES], partials: ['MESSAGE', 'CHANNEL', 'REACTION'], }); global.client.login(env.discord.token); +console.log(figlet.textSync('CODA UTILITIES', { + font: 'Standard', + horizontalLayout: 'default', + verticalLayout: 'default', +})); +console.log(`Version: ${pkg.version}`); +console.log(`Author: ${pkg.author}`); +console.log(`GitHub: ${pkg.repository.url}`); global.client.once('ready', async () => { console.log('Ready!'); // get the number of users in the server diff --git a/package-lock.json b/package-lock.json index d2e8a15..272d3a9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "discord-api-types": "^0.36.1", "discord.js": "^13.8.1", "emoji-unicode": "^2.0.1", + "figlet": "^1.5.2", "lodash": "^4.17.21", "mariadb": "^3.0.0" }, @@ -941,6 +942,14 @@ "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true }, + "node_modules/figlet": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/figlet/-/figlet-1.5.2.tgz", + "integrity": "sha512-WOn21V8AhyE1QqVfPIVxe3tupJacq1xGkPTB4iagT6o+P2cAgEOOwIxMftr4+ZCTI6d551ij9j61DFr0nsP2uQ==", + "engines": { + "node": ">= 0.4.0" + } + }, "node_modules/file-entry-cache": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", @@ -2585,6 +2594,11 @@ "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true }, + "figlet": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/figlet/-/figlet-1.5.2.tgz", + "integrity": "sha512-WOn21V8AhyE1QqVfPIVxe3tupJacq1xGkPTB4iagT6o+P2cAgEOOwIxMftr4+ZCTI6d551ij9j61DFr0nsP2uQ==" + }, "file-entry-cache": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", diff --git a/package.json b/package.json index 9e53313..919a8ea 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,10 @@ }, "author": "ikifar2012", "license": "ISC", + "repository": { + "type": "git", + "url": "https://github.com/Project-Coda/Coda-Utilities.git" + }, "devDependencies": { "eslint": "^8.19.0", "nodemon": "^2.0.19" @@ -20,6 +24,7 @@ "discord-api-types": "^0.36.1", "discord.js": "^13.8.1", "emoji-unicode": "^2.0.1", + "figlet": "^1.5.2", "lodash": "^4.17.21", "mariadb": "^3.0.0" } From 37e94a0169017a2edd5239e71ce8405da4550e34 Mon Sep 17 00:00:00 2001 From: ikifar2012 Date: Thu, 14 Jul 2022 04:00:55 +0000 Subject: [PATCH 12/13] fix loop --- utilities/greet.js | 63 ++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/utilities/greet.js b/utilities/greet.js index 711ee63..fe1e32d 100644 --- a/utilities/greet.js +++ b/utilities/greet.js @@ -53,23 +53,24 @@ async function sendKickAlert(member) { )], }, ); - global.client.users.cache.get(env.discord.logs_channel).send( - { - content: '🚨 Bot Kicked from Server 🚨' + '\n<@&' + env.discord.admin_role + '> <@&' + env.discord.mod_role + '>', - embeds: [ embedcreator.setembed( - { - title: 'Bot Kicked', - description: `${member.user} joined ${global.client.guilds.cache.get(env.discord.guild).name} and was kicked due to botgate being enabled`, - color: '#e74c3c', - image: { - url: `${member.user.avatarURL({ dynamic: true })}`, - }, - }, - )], - }, - ); } + global.client.users.cache.get(env.discord.logs_channel).send( + { + content: '🚨 Bot Kicked from Server 🚨' + '\n<@&' + env.discord.admin_role + '> <@&' + env.discord.mod_role + '>', + embeds: [ embedcreator.setembed( + { + title: 'Bot Kicked', + description: `${member.user} joined ${global.client.guilds.cache.get(env.discord.guild).name} and was kicked due to botgate being enabled`, + color: '#e74c3c', + image: { + url: `${member.user.avatarURL({ dynamic: true })}`, + }, + }, + )], + }, + ); } + async function SendNewBotAlert(member) { const users = await getUsers(); for (userId of users) { @@ -89,22 +90,24 @@ async function SendNewBotAlert(member) { )], }, ); - global.client.channels.cache.get(env.discord.logs_channel).send( - { - content: '🚨 Bot Added to Server 🚨' + '\n<@&' + env.discord.admin_role + '> <@&' + env.discord.mod_role + '>', - embeds: [ embedcreator.setembed( - { - title: '🚨 Bot Added 🚨', - description: `Botgate was disabled and ${member.user} joined ${global.client.guilds.cache.get(env.discord.guild).name}, please re-enable botgate as soon as possible`, - color: '#2ecc71', - image: { - url: `${member.user.avatarURL({ dynamic: true })}`, - }, - }, - )], - }, - ); } + + global.client.channels.cache.get(env.discord.logs_channel).send( + { + content: '🚨 Bot Added to Server 🚨' + '\n<@&' + env.discord.admin_role + '> <@&' + env.discord.mod_role + '>', + embeds: [ embedcreator.setembed( + { + title: '🚨 Bot Added 🚨', + description: `Botgate was disabled and ${member.user} joined ${global.client.guilds.cache.get(env.discord.guild).name}, please re-enable botgate as soon as possible`, + color: '#2ecc71', + image: { + url: `${member.user.avatarURL({ dynamic: true })}`, + }, + }, + )], + }, + ); } + module.exports = { sendNotify, getUsers, sendKickAlert, SendNewBotAlert }; \ No newline at end of file From 9c112283e9f94fee3d73931c53046c5aa1aee12e Mon Sep 17 00:00:00 2001 From: ikifar2012 Date: Thu, 14 Jul 2022 04:03:43 +0000 Subject: [PATCH 13/13] fix typo --- utilities/greet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/greet.js b/utilities/greet.js index fe1e32d..d28568c 100644 --- a/utilities/greet.js +++ b/utilities/greet.js @@ -54,7 +54,7 @@ async function sendKickAlert(member) { }, ); } - global.client.users.cache.get(env.discord.logs_channel).send( + global.client.channels.cache.get(env.discord.logs_channel).send( { content: '🚨 Bot Kicked from Server 🚨' + '\n<@&' + env.discord.admin_role + '> <@&' + env.discord.mod_role + '>', embeds: [ embedcreator.setembed(