From 9b5dad37208b49e26854f8f518ecb1316d88ca77 Mon Sep 17 00:00:00 2001 From: joebobbio Date: Fri, 26 Aug 2022 19:09:53 -0400 Subject: [PATCH 1/6] bump insecure undici --- package-lock.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 077e23f..c610834 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "neb-dispenser", - "version": "1.0.0", + "version": "2.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "neb-dispenser", - "version": "1.0.0", + "version": "2.1.0", "license": "ISC", "dependencies": { "@discordjs/rest": "^0.5.0", @@ -1920,9 +1920,9 @@ "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==" }, "node_modules/undici": { - "version": "5.8.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-5.8.0.tgz", - "integrity": "sha512-1F7Vtcez5w/LwH2G2tGnFIihuWUlc58YidwLiCv+jR2Z50x0tNXpRRw7eOIJ+GvqCqIkg9SB7NWAJ/T9TLfv8Q==", + "version": "5.10.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.10.0.tgz", + "integrity": "sha512-c8HsD3IbwmjjbLvoZuRI26TZic+TSEe8FPMLLOkN1AfYRhdjnKBU6yL+IwcSCbdZiX4e5t0lfMDLDCqj4Sq70g==", "engines": { "node": ">=12.18" } @@ -3452,9 +3452,9 @@ "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==" }, "undici": { - "version": "5.8.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-5.8.0.tgz", - "integrity": "sha512-1F7Vtcez5w/LwH2G2tGnFIihuWUlc58YidwLiCv+jR2Z50x0tNXpRRw7eOIJ+GvqCqIkg9SB7NWAJ/T9TLfv8Q==" + "version": "5.10.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.10.0.tgz", + "integrity": "sha512-c8HsD3IbwmjjbLvoZuRI26TZic+TSEe8FPMLLOkN1AfYRhdjnKBU6yL+IwcSCbdZiX4e5t0lfMDLDCqj4Sq70g==" }, "unique-filename": { "version": "1.1.1", From b8eeee854512965b252f937010d8aed31863284d Mon Sep 17 00:00:00 2001 From: joebobbio Date: Fri, 26 Aug 2022 19:46:47 -0400 Subject: [PATCH 2/6] Use env variables instead --- .env.example | 22 ++++++++++++++++++++++ .gitignore | 3 ++- deploy-commands.js | 5 ++++- index.js | 3 ++- 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..e8a3352 --- /dev/null +++ b/.env.example @@ -0,0 +1,22 @@ +# Your bot token +TOKEN= + +# The ID of the server you are going to add the bot to. +GUILDID= + +# The ID of the bot profile +CLIENTID= + +# An array of bot owner IDs +OWNERID= + +# The text you see in the embeds of footers - i.e. "A Nebula service" +EMBEDFOOTERTEXT= + +# These next few values are about reporting. If you leave them blank, the report feature will be disabled. +REPORTWEBHOOK= +REPORTUSERNAME= +REPORTAVATAR= + +# The status displayed on your bot profile +STATUS= \ No newline at end of file diff --git a/.gitignore b/.gitignore index ab8bece..2771a5d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules config.json -database.sqlite \ No newline at end of file +database.sqlite +.env \ No newline at end of file diff --git a/deploy-commands.js b/deploy-commands.js index 9372b3b..11e7b78 100644 --- a/deploy-commands.js +++ b/deploy-commands.js @@ -1,8 +1,11 @@ +require("dotenv").config(); const fs = require('node:fs'); const path = require('node:path'); const { REST } = require('@discordjs/rest'); const { Routes } = require('discord-api-types/v9'); -const { clientID, guildID, token } = require('./config.json'); +const clientID = process.env.CLIENTID; +const guildID = process.env.guildID; +const token = process.env.TOKEN; const { colors } = require('./colors'); const commands = []; const commandsPath = path.join(__dirname, 'commands'); diff --git a/index.js b/index.js index 36053ca..3ee0c17 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,4 @@ +require("dotenv").config(); const { Client, Collection, Intents } = require('discord.js'); const fs = require('node:fs'); const path = require('node:path'); @@ -9,7 +10,7 @@ const { loadEvents, loadCommands } = require('./Handler'); // global sexy variables module.exports = client; -client.config = require('./config.json'); +client.config = process.env; client.Discord = Discord; client.commands = new Collection(); client.colors = colors; From 00488a0d0cde61deabb32576adb3843a738b2b71 Mon Sep 17 00:00:00 2001 From: joebobbio Date: Fri, 26 Aug 2022 21:04:00 -0400 Subject: [PATCH 3/6] Individual user reset --- README.md | 13 +++++++++---- commands/reset-all.js | 21 +++++++++++++++++++++ commands/reset.js | 15 ++++++++------- 3 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 commands/reset-all.js diff --git a/README.md b/README.md index 98d4eee..7f87ffb 100644 --- a/README.md +++ b/README.md @@ -43,10 +43,15 @@ /list -/reset +/reset-all Resets all users in the database /reset + +/reset +Reset a user +/reset [user] + @@ -60,10 +65,10 @@ Installation instructions can be found on the [wiki](https://github.com/NebulaSe ## Credits -Written by [Phene](https://github.com/joebobbio) and [illusions](https://github.com/illusionTBA) for Nebula Services +See our [contributors](https://github.com/NebulaServices/Dispenser/graphs/contributors) Dispenser is a product of Nebula Services | Copyright Nebula Services 2022
-Copyright Questions ----> accounts-management@nebula.bio +Copyright questions ----> accounts-management@nebula.bio
-Need Help? Open a ticket -> https://discord.nebula.bio +Need help or want to contribute? Open a ticket -> https://discord.nebula.bio diff --git a/commands/reset-all.js b/commands/reset-all.js new file mode 100644 index 0000000..0bbc3bc --- /dev/null +++ b/commands/reset-all.js @@ -0,0 +1,21 @@ +const {SlashCommandBuilder} = require('@discordjs/builders') +const {Users} = require('../db') +module.exports = { + data: new SlashCommandBuilder() + .setName('reset-all') + .setDescription('Reset ALL USERS'), + ownerOnly: true, + async execute(interaction){ + try{ + Users.destroy({ + where: {} + }) + return interaction.reply('All users have been reset.') + } + catch(err){ + interaction.reply('Something went wrong. Check the log!') + console.log(client.colors.error(err)) + } + + } +} \ No newline at end of file diff --git a/commands/reset.js b/commands/reset.js index 8bd68ff..352eba6 100644 --- a/commands/reset.js +++ b/commands/reset.js @@ -3,19 +3,20 @@ const {Users} = require('../db') module.exports = { data: new SlashCommandBuilder() .setName('reset') - .setDescription('Reset ALL USERS'), + .setDescription('Reset a user\'s monthly count') + .addUserOption(option => option.setName('user').setDescription('The user to reset').setRequired(true)), ownerOnly: true, async execute(interaction){ - try{ + const user = interaction.options.getMember('user') + try { Users.destroy({ - where: {} - }) - return interaction.reply('All users have been reset.') + where: {id:user.id} + }) + return interaction.reply(`Reset user ${user.user.tag}`) } catch(err){ - interaction.reply('Something went wrong. Check the log!') + interaction.reply('User either does not exist or an unknown error occurred.') console.log(client.colors.error(err)) } - } } \ No newline at end of file From 898fe0bc6b6d78cd2582b3378d4d6d29e1aa66f8 Mon Sep 17 00:00:00 2001 From: joebobbio Date: Fri, 26 Aug 2022 21:04:43 -0400 Subject: [PATCH 4/6] 2.3 --- 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 c610834..b615dbd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "neb-dispenser", - "version": "2.1.0", + "version": "2.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "neb-dispenser", - "version": "2.1.0", + "version": "2.3.0", "license": "ISC", "dependencies": { "@discordjs/rest": "^0.5.0", diff --git a/package.json b/package.json index 4c04559..f053f67 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "neb-dispenser", - "version": "2.1.0", + "version": "2.3.0", "description": "Distribute domains to a Discord server", "main": "index.js", "scripts": { From 52c63288de7a71b4475c6de60eca1f30d9d746d4 Mon Sep 17 00:00:00 2001 From: Joey <69287308+Joey0980@users.noreply.github.com> Date: Fri, 26 Aug 2022 22:31:57 -0400 Subject: [PATCH 5/6] Remove "User added to DB" message --- Handler/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Handler/index.js b/Handler/index.js index 6e988a8..e1da3f7 100644 --- a/Handler/index.js +++ b/Handler/index.js @@ -13,7 +13,8 @@ const dispense = async (client, interaction) => { usage_count: 0 }) console.log(client.colors.warn('[DB]'), `User ${interaction.user.tag} added to db`) - return interaction.reply({ content: 'You have been added to the database - click the button again.', ephemeral: true }) + // return interaction.reply({ content: 'You have been added to the database - click the button again.', ephemeral: true }) + return dispense(client, interaction); } } catch (err) { console.log(client.colors.error(err)) From a067012d6e50704e8660a6dc0d7fd9206d1b0d03 Mon Sep 17 00:00:00 2001 From: phene <60532517+joebobbio@users.noreply.github.com> Date: Fri, 26 Aug 2022 22:42:35 -0400 Subject: [PATCH 6/6] Delete config-example.json No longer needed --- config-example.json | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 config-example.json diff --git a/config-example.json b/config-example.json deleted file mode 100644 index f302e75..0000000 --- a/config-example.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "token": "The bot token", - "clientID": "The bot's ID", - "guildID": "The ID of the server you are deploying to", - "ownerID": [ - "An array of owner user IDs, separated by commas" - ], - "embedfooterText": "Embed footer text", - "reportWebhook": "The webhook URL for reporting domains", - "reportUsername": "The username to use for the webhook", - "reportAvatar": "The avatar URL to use for the webhook", - "status": "The custom status displayed on the bot profile" - } - \ No newline at end of file