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/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)) 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 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 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; diff --git a/package-lock.json b/package-lock.json index 077e23f..b615dbd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "neb-dispenser", - "version": "1.0.0", + "version": "2.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "neb-dispenser", - "version": "1.0.0", + "version": "2.3.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", 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": {