diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1ee35b2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,171 @@ + +# Created by https://www.toptal.com/developers/gitignore/api/node,windows +# Edit at https://www.toptal.com/developers/gitignore?templates=node,windows + +### Node ### +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +### Node Patch ### +# Serverless Webpack directories +.webpack/ + +# Optional stylelint cache + +# SvelteKit build / generate output +.svelte-kit + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/node,windows \ No newline at end of file diff --git a/Discord-Faucet-Bot.code-workspace b/Discord-Faucet-Bot.code-workspace new file mode 100644 index 0000000..03d7e42 --- /dev/null +++ b/Discord-Faucet-Bot.code-workspace @@ -0,0 +1,30 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": { + "workbench.colorCustomizations": { + "activityBar.activeBackground": "#8a8dc4", + "activityBar.activeBorder": "#ead5d6", + "activityBar.background": "#8a8dc4", + "activityBar.foreground": "#15202b", + "activityBar.inactiveForeground": "#15202b99", + "activityBarBadge.background": "#ead5d6", + "activityBarBadge.foreground": "#15202b", + "sash.hoverBorder": "#8a8dc4", + "statusBar.background": "#686cb3", + "statusBar.foreground": "#e7e7e7", + "statusBarItem.hoverBackground": "#8a8dc4", + "statusBarItem.remoteBackground": "#686cb3", + "statusBarItem.remoteForeground": "#e7e7e7", + "titleBar.activeBackground": "#686cb3", + "titleBar.activeForeground": "#e7e7e7", + "titleBar.inactiveBackground": "#686cb399", + "titleBar.inactiveForeground": "#e7e7e799", + "commandCenter.border": "#e7e7e799" + }, + "peacock.color": "#686cb3" + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..c0aaf59 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +# Discord Bot Faucet + +This is a Discord Bot that dispenses Testnet ETH. + +## Setup + +Create a `.env` file and fill in the following info + +``` +# Discord Bot Token +DCB_TOKEN="aaaaaaaaaaaaaa.aaaaaaaaa" +# Discord Bot Client ID +DCB_CLIENT_ID="00000000000" +# Discord Server ID +DCB_GUILD_ID="00000000000" +# Discord Channel ID to post log +DCB_BOT_LOG_CHANNEL="000000000" +``` diff --git a/client.js b/client.js new file mode 100644 index 0000000..4767c3a --- /dev/null +++ b/client.js @@ -0,0 +1,8 @@ +// Exporting the Client + +const { Client, Intents } = require("discord.js"); + +// Create a new Client with these permissions +const client = new Client({ intents: [Intents.FLAGS.GUILDS] }); + +module.exports = client; diff --git a/commands/beep.js b/commands/beep.js new file mode 100644 index 0000000..52b5cc0 --- /dev/null +++ b/commands/beep.js @@ -0,0 +1,9 @@ +// Respond user beep with Boop + +const { SlashCommandBuilder } = require("@discordjs/builders"); + +module.exports = { + data: new SlashCommandBuilder() + .setName("beep") + .setDescription("Replies with boop!"), +}; diff --git a/commands/echo.js b/commands/echo.js new file mode 100644 index 0000000..66fa5dd --- /dev/null +++ b/commands/echo.js @@ -0,0 +1,15 @@ +// Replying the User with what the user typed + +const { SlashCommandBuilder } = require("@discordjs/builders"); + +module.exports = { + data: new SlashCommandBuilder() + .setName("echo") + .setDescription("Replies with your input!") + .addStringOption((option) => + option + .setName("input") + .setDescription("The input to echo back") + .setRequired(true) + ), +}; diff --git a/commands/info.js b/commands/info.js new file mode 100644 index 0000000..58b52dc --- /dev/null +++ b/commands/info.js @@ -0,0 +1,22 @@ +// Replies user with user info or server info + +const { SlashCommandBuilder } = require("@discordjs/builders"); + +module.exports = { + data: new SlashCommandBuilder() + .setName("info") + .setDescription("Get info about a user or a server!") + .addSubcommand((subcommand) => + subcommand + .setName("user") + .setDescription("Info about a user") + .addUserOption((option) => + option.setName("target").setDescription("The user") + ) + ) + .addSubcommand((subcommand) => + subcommand + .setName("server") + .setDescription("Info about the server") + ), +}; diff --git a/commands/ping.js b/commands/ping.js new file mode 100644 index 0000000..7401165 --- /dev/null +++ b/commands/ping.js @@ -0,0 +1,9 @@ +// Respond the user with the bot's ping + +const { SlashCommandBuilder } = require("@discordjs/builders"); + +module.exports = { + data: new SlashCommandBuilder() + .setName("ping") + .setDescription("Check the ping of the bot (for admins only)"), +}; diff --git a/deploy-commands.js b/deploy-commands.js new file mode 100644 index 0000000..636c268 --- /dev/null +++ b/deploy-commands.js @@ -0,0 +1,28 @@ +const fs = require("fs"); +const { REST } = require("@discordjs/rest"); +const { Routes } = require("discord-api-types/v9"); +require("dotenv").config({ path: ".env" }); + +const commands = []; +const commandFiles = fs + .readdirSync("./commands") + .filter((file) => file.endsWith(".js")); + +for (const file of commandFiles) { + const command = require(`./commands/${file}`); + commands.push(command.data.toJSON()); +} + +const rest = new REST({ version: "9" }).setToken(process.env.DCB_TOKEN); + +rest + .put( + Routes.applicationGuildCommands( + process.env.DCB_CLIENT_ID, + process.env.DCB_GUILD_ID + ), //* Use for Production + //Routes.applicationCommands(process.env.DBC_CLIENT_ID) //* Use for Development as its updated instantly (no cache) + { body: commands } + ) + .then(() => console.log("Successfully registered application commands")) + .catch(console.error); diff --git a/events/interactionCreate.js b/events/interactionCreate.js new file mode 100644 index 0000000..d59c3c5 --- /dev/null +++ b/events/interactionCreate.js @@ -0,0 +1,25 @@ +// For all the Interactions + +module.exports = { + name: "interactionCreate", + async execute(interaction) { + if (!interaction.isCommand()) return; + + if (interaction.commandName === "beep") { + await require("../responses/beep_response")(interaction); + } else if (interaction.commandName === "echo") { + await require("../responses/echo_response")(interaction); + } else if (interaction.commandName === "info") { + await require("../responses/info_response")(interaction); + } else if (interaction.commandName === "ping") { + await require("../responses/ping_response")(interaction); + } + // Final Reply if non exists + else { + await interaction.reply({ + content: "This Command is either Deleted or Work in Progress!", + ephemeral: true, + }); + } + }, +}; diff --git a/events/ready.js b/events/ready.js new file mode 100644 index 0000000..0e0c8bd --- /dev/null +++ b/events/ready.js @@ -0,0 +1,26 @@ +// When the Bot Launches + +require("dotenv").config({ path: "../.env" }); + +module.exports = { + name: "ready", + once: true, + async execute(client) { + console.log(`Ready! Logged in as ${client.user.tag}`); + + const logchannel = await client.channels.cache.get( + process.env.DCB_BOT_LOG_CHANNEL + ); + logchannel.send( + `${new Date( + Date.now() + ).toUTCString()} | Faucet Bot | Restarted, and set activity` + ); + + // Setting Status of Bot + await client.user.setActivity("a tutorial on how to be a good bot", { + type: "WATCHING", + }); + await client.user.setStatus("online"); + }, +}; diff --git a/index.js b/index.js new file mode 100644 index 0000000..b7f1679 --- /dev/null +++ b/index.js @@ -0,0 +1,45 @@ +//* Run node deploy-commands to register the commands added + +// Requires +const fs = require("fs"); +const { Collection } = require("discord.js"); +require("dotenv").config({ path: ".env" }); +const client = require("./client"); // Get Client + +// Get the Events +const eventFiles = fs + .readdirSync("./events") + .filter((file) => file.endsWith(".js")); + +// Run the Events depending on whether it's once or on. +for (const file of eventFiles) { + const event = require(`./events/${file}`); + if (event.once) { + client.once(event.name, (...args) => event.execute(...args)); + } else { + client.on(event.name, (...args) => event.execute(...args)); + } +} + +// Setting Commands +client.commands = new Collection(); + +// Gets all command files +const commandFiles = fs + .readdirSync("./commands") + .filter((file) => file.endsWith(".js")); + +// Setting the command for every file +for (const file of commandFiles) { + const command = require(`./commands/${file}`); + //Set a new item in the Collection + // With the key as the command name and the value as the exported module + client.commands.set(command.data.name, command); +} + +// Login to the Bot +try { + client.login(process.env.DCB_TOKEN); +} catch (error) { + console.error(error); +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..5612812 --- /dev/null +++ b/package.json @@ -0,0 +1,24 @@ +{ + "name": "discord-faucet-bot", + "version": "1.0.0", + "description": "Discord Faucet Bot to let people collect testnet currency tokens.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "dev_local": "set NODE_ENV=development && nodemon index.js", + "dev": "NODE_ENV=development node index.js", + "prod": "NODE_ENV=production node index.js" + }, + "author": "Yanuka Deneth", + "license": "MIT", + "dependencies": { + "@discordjs/builders": "^0.12.0", + "@discordjs/rest": "^0.3.0", + "axios": "^0.26.1", + "discord-api-types": "^0.27.1", + "discord-rpc": "^4.0.1", + "discord.js": "^13.6.0", + "discordbot": "^0.0.21", + "dotenv": "^16.0.1" + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..74bacb4 --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,476 @@ +lockfileVersion: 5.4 + +specifiers: + '@discordjs/builders': ^0.12.0 + '@discordjs/rest': ^0.3.0 + axios: ^0.26.1 + discord-api-types: ^0.27.1 + discord-rpc: ^4.0.1 + discord.js: ^13.6.0 + discordbot: ^0.0.21 + dotenv: ^16.0.1 + +dependencies: + '@discordjs/builders': 0.12.0 + '@discordjs/rest': 0.3.0 + axios: 0.26.1 + discord-api-types: 0.27.3 + discord-rpc: 4.0.1 + discord.js: 13.7.0 + discordbot: 0.0.21 + dotenv: 16.0.1 + +packages: + + /@discordjs/builders/0.12.0: + resolution: {integrity: sha512-Vx2MjUZd6QVo1uS2uWt708Fd6cHWGFblAvbpL5EBO+kLl0BADmPwwvts+YJ/VfSywed6Vsk6K2cEooR/Ytjhjw==} + engines: {node: '>=16.9.0'} + dependencies: + '@sindresorhus/is': 4.6.0 + discord-api-types: 0.26.1 + ts-mixer: 6.0.1 + tslib: 2.4.0 + zod: 3.17.3 + dev: false + + /@discordjs/builders/0.13.0: + resolution: {integrity: sha512-4L9y26KRNNU8Y7J78SRUN1Uhava9D8jfit/YqEaKi8gQRc7PdqKqk2poybo6RXaiyt/BgKYPfcjxT7WvzGfYCA==} + engines: {node: '>=16.9.0'} + dependencies: + '@sapphire/shapeshift': 2.2.0 + '@sindresorhus/is': 4.6.0 + discord-api-types: 0.31.2 + fast-deep-equal: 3.1.3 + ts-mixer: 6.0.1 + tslib: 2.4.0 + dev: false + + /@discordjs/collection/0.4.0: + resolution: {integrity: sha512-zmjq+l/rV35kE6zRrwe8BHqV78JvIh2ybJeZavBi5NySjWXqN3hmmAKg7kYMMXSeiWtSsMoZ/+MQi0DiQWy2lw==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dev: false + + /@discordjs/collection/0.6.0: + resolution: {integrity: sha512-Ieaetb36l0nmAS5X9Upqk4W7euAO6FdXPxn3I8vBAKEcoIzEZI1mcVcPfCfagGJZSgBKpENnAnKkP4GAn+MV8w==} + engines: {node: '>=16.9.0'} + dev: false + + /@discordjs/rest/0.3.0: + resolution: {integrity: sha512-F9aeP3odlAlllM1ciBZLdd+adiAyBj4VaZBejj4UMj4afE2wfCkNTGvYYiRxrXUE9fN7e/BuDP2ePl0tVA2m7Q==} + engines: {node: '>=16.9.0'} + dependencies: + '@discordjs/collection': 0.4.0 + '@sapphire/async-queue': 1.3.1 + '@sapphire/snowflake': 3.2.2 + discord-api-types: 0.26.1 + form-data: 4.0.0 + node-fetch: 2.6.7 + tslib: 2.4.0 + transitivePeerDependencies: + - encoding + dev: false + + /@sapphire/async-queue/1.3.1: + resolution: {integrity: sha512-FFTlPOWZX1kDj9xCAsRzH5xEJfawg1lNoYAA+ecOWJMHOfiZYb1uXOI3ne9U4UILSEPwfE68p3T9wUHwIQfR0g==} + engines: {node: '>=v14.0.0', npm: '>=7.0.0'} + dev: false + + /@sapphire/shapeshift/2.2.0: + resolution: {integrity: sha512-UEnKgMlQyI0yY/q+lCMX0VJft9y86IsesgbIQj6e62FBYSaMVr+IaMNpi4z45Q14VnuMACbK0yrbHISNqgUYcQ==} + engines: {node: '>=v15.0.0', npm: '>=7.0.0'} + dev: false + + /@sapphire/snowflake/3.2.2: + resolution: {integrity: sha512-ula2O0kpSZtX9rKXNeQMrHwNd7E4jPDJYUXmEGTFdMRfyfMw+FPyh04oKMjAiDuOi64bYgVkOV3MjK+loImFhQ==} + engines: {node: '>=v14.0.0', npm: '>=7.0.0'} + dev: false + + /@sindresorhus/is/4.6.0: + resolution: {integrity: sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==} + engines: {node: '>=10'} + dev: false + + /@types/node-fetch/2.6.1: + resolution: {integrity: sha512-oMqjURCaxoSIsHSr1E47QHzbmzNR5rK8McHuNb11BOM9cHcIK3Avy0s/b2JlXHoQGTYS3NsvWzV1M0iK7l0wbA==} + dependencies: + '@types/node': 17.0.35 + form-data: 3.0.1 + dev: false + + /@types/node/17.0.35: + resolution: {integrity: sha512-vu1SrqBjbbZ3J6vwY17jBs8Sr/BKA+/a/WtjRG+whKg1iuLFOosq872EXS0eXWILdO36DHQQeku/ZcL6hz2fpg==} + dev: false + + /@types/ws/8.5.3: + resolution: {integrity: sha512-6YOoWjruKj1uLf3INHH7D3qTXwFfEsg1kf3c0uDdSBJwfa/llkwIjrAGV7j7mVgGNbzTQ3HiHKKDXl6bJPD97w==} + dependencies: + '@types/node': 17.0.35 + dev: false + + /asynckit/0.4.0: + resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} + dev: false + + /axios/0.26.1: + resolution: {integrity: sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==} + dependencies: + follow-redirects: 1.15.0 + transitivePeerDependencies: + - debug + dev: false + + /bindings/1.5.0: + resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==} + dependencies: + file-uri-to-path: 1.0.0 + dev: false + optional: true + + /bufferutil/4.0.6: + resolution: {integrity: sha512-jduaYOYtnio4aIAyc6UbvPCVcgq7nYpVnucyxr6eCYg/Woad9Hf/oxxBRDnGGjPfjUm6j5O/uBWhIu4iLebFaw==} + engines: {node: '>=6.14.2'} + requiresBuild: true + dependencies: + node-gyp-build: 4.4.0 + dev: false + + /combined-stream/1.0.8: + resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==} + engines: {node: '>= 0.8'} + dependencies: + delayed-stream: 1.0.0 + dev: false + + /d/1.0.1: + resolution: {integrity: sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==} + dependencies: + es5-ext: 0.10.61 + type: 1.2.0 + dev: false + + /debug/2.6.9: + resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + dependencies: + ms: 2.0.0 + dev: false + + /delayed-stream/1.0.0: + resolution: {integrity: sha1-3zrhmayt+31ECqrgsp4icrJOxhk=} + engines: {node: '>=0.4.0'} + dev: false + + /discord-api-types/0.26.1: + resolution: {integrity: sha512-T5PdMQ+Y1MEECYMV5wmyi9VEYPagEDEi4S0amgsszpWY0VB9JJ/hEvM6BgLhbdnKky4gfmZEXtEEtojN8ZKJQQ==} + engines: {node: '>=12'} + dev: false + + /discord-api-types/0.27.3: + resolution: {integrity: sha512-HOG64DTpZ7CB5EU9eKbjHD50H5qG1pxKG8pmFfHUMKjKvEWeLBHfw0c9xF1cruiYLnBb3+n7m3jBWxZ3H1hcgQ==} + dev: false + + /discord-api-types/0.30.0: + resolution: {integrity: sha512-wYst0jrT8EJs2tVlwUTQ2xT0oWMjUrRMpFTkNY3NMleWyQNHgWaKhqFfxdLPdC2im9IuR5EsxcEgjhf/npeftw==} + dev: false + + /discord-api-types/0.31.2: + resolution: {integrity: sha512-gpzXTvFVg7AjKVVJFH0oJGC0q0tO34iJGSHZNz9u3aqLxlD6LfxEs9wWVVikJqn9gra940oUTaPFizCkRDcEiA==} + dev: false + + /discord-rpc/4.0.1: + resolution: {integrity: sha512-HOvHpbq5STRZJjQIBzwoKnQ0jHplbEWFWlPDwXXKm/bILh4nzjcg7mNqll0UY7RsjFoaXA7e/oYb/4lvpda2zA==} + dependencies: + node-fetch: 2.6.7 + ws: 7.5.7 + optionalDependencies: + register-scheme: github.com/devsnek/node-register-scheme/e7cc9a63a1f512565da44cb57316d9fb10750e17 + transitivePeerDependencies: + - bufferutil + - encoding + - utf-8-validate + dev: false + + /discord.js/13.7.0: + resolution: {integrity: sha512-iV/An3FEB/CiBGdjWHRtgskM4UuWPq5vjhjKsrQhdVU16dbKrBxA+eIV2HWA07B3tXUGM6eco1wkr42gxxV1BA==} + engines: {node: '>=16.6.0', npm: '>=7.0.0'} + dependencies: + '@discordjs/builders': 0.13.0 + '@discordjs/collection': 0.6.0 + '@sapphire/async-queue': 1.3.1 + '@types/node-fetch': 2.6.1 + '@types/ws': 8.5.3 + discord-api-types: 0.30.0 + form-data: 4.0.0 + node-fetch: 2.6.7 + ws: 8.6.0 + transitivePeerDependencies: + - bufferutil + - encoding + - utf-8-validate + dev: false + + /discordbot/0.0.21: + resolution: {integrity: sha1-W6rlGWK2ATwY3a91rqPpDCI+eFY=} + dependencies: + mime: 1.6.0 + needle: 0.10.0 + websocket: 1.0.34 + transitivePeerDependencies: + - supports-color + dev: false + + /dotenv/16.0.1: + resolution: {integrity: sha512-1K6hR6wtk2FviQ4kEiSjFiH5rpzEVi8WW0x96aztHVMhEspNpc4DVOUTEHtEva5VThQ8IaBX1Pe4gSzpVVUsKQ==} + engines: {node: '>=12'} + dev: false + + /es5-ext/0.10.61: + resolution: {integrity: sha512-yFhIqQAzu2Ca2I4SE2Au3rxVfmohU9Y7wqGR+s7+H7krk26NXhIRAZDgqd6xqjCEFUomDEA3/Bo/7fKmIkW1kA==} + engines: {node: '>=0.10'} + requiresBuild: true + dependencies: + es6-iterator: 2.0.3 + es6-symbol: 3.1.3 + next-tick: 1.1.0 + dev: false + + /es6-iterator/2.0.3: + resolution: {integrity: sha1-p96IkUGgWpSwhUQDstCg+/qY87c=} + dependencies: + d: 1.0.1 + es5-ext: 0.10.61 + es6-symbol: 3.1.3 + dev: false + + /es6-symbol/3.1.3: + resolution: {integrity: sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==} + dependencies: + d: 1.0.1 + ext: 1.6.0 + dev: false + + /ext/1.6.0: + resolution: {integrity: sha512-sdBImtzkq2HpkdRLtlLWDa6w4DX22ijZLKx8BMPUuKe1c5lbN6xwQDQCxSfxBQnHZ13ls/FH0MQZx/q/gr6FQg==} + dependencies: + type: 2.6.0 + dev: false + + /fast-deep-equal/3.1.3: + resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} + dev: false + + /file-uri-to-path/1.0.0: + resolution: {integrity: sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==} + dev: false + optional: true + + /follow-redirects/1.15.0: + resolution: {integrity: sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ==} + engines: {node: '>=4.0'} + peerDependencies: + debug: '*' + peerDependenciesMeta: + debug: + optional: true + dev: false + + /form-data/3.0.1: + resolution: {integrity: sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==} + engines: {node: '>= 6'} + dependencies: + asynckit: 0.4.0 + combined-stream: 1.0.8 + mime-types: 2.1.35 + dev: false + + /form-data/4.0.0: + resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==} + engines: {node: '>= 6'} + dependencies: + asynckit: 0.4.0 + combined-stream: 1.0.8 + mime-types: 2.1.35 + dev: false + + /iconv-lite/0.4.24: + resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==} + engines: {node: '>=0.10.0'} + dependencies: + safer-buffer: 2.1.2 + dev: false + + /is-typedarray/1.0.0: + resolution: {integrity: sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=} + dev: false + + /mime-db/1.52.0: + resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} + engines: {node: '>= 0.6'} + dev: false + + /mime-types/2.1.35: + resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==} + engines: {node: '>= 0.6'} + dependencies: + mime-db: 1.52.0 + dev: false + + /mime/1.6.0: + resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==} + engines: {node: '>=4'} + hasBin: true + dev: false + + /ms/2.0.0: + resolution: {integrity: sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=} + dev: false + + /needle/0.10.0: + resolution: {integrity: sha1-FqJNY/KmEVLrdMzh0Sr4XFB1d9Q=} + engines: {node: '>= 0.10.x'} + hasBin: true + dependencies: + debug: 2.6.9 + iconv-lite: 0.4.24 + transitivePeerDependencies: + - supports-color + dev: false + + /next-tick/1.1.0: + resolution: {integrity: sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==} + dev: false + + /node-addon-api/1.7.2: + resolution: {integrity: sha512-ibPK3iA+vaY1eEjESkQkM0BbCqFOaZMiXRTtdB0u7b4djtY6JnsjvPdUHVMg6xQt3B8fpTTWHI9A+ADjM9frzg==} + dev: false + optional: true + + /node-fetch/2.6.7: + resolution: {integrity: sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==} + engines: {node: 4.x || >=6.0.0} + peerDependencies: + encoding: ^0.1.0 + peerDependenciesMeta: + encoding: + optional: true + dependencies: + whatwg-url: 5.0.0 + dev: false + + /node-gyp-build/4.4.0: + resolution: {integrity: sha512-amJnQCcgtRVw9SvoebO3BKGESClrfXGCUTX9hSn1OuGQTQBOZmVd0Z0OlecpuRksKvbsUqALE8jls/ErClAPuQ==} + hasBin: true + dev: false + + /safer-buffer/2.1.2: + resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} + dev: false + + /tr46/0.0.3: + resolution: {integrity: sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=} + dev: false + + /ts-mixer/6.0.1: + resolution: {integrity: sha512-hvE+ZYXuINrx6Ei6D6hz+PTim0Uf++dYbK9FFifLNwQj+RwKquhQpn868yZsCtJYiclZF1u8l6WZxxKi+vv7Rg==} + dev: false + + /tslib/2.4.0: + resolution: {integrity: sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==} + dev: false + + /type/1.2.0: + resolution: {integrity: sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==} + dev: false + + /type/2.6.0: + resolution: {integrity: sha512-eiDBDOmkih5pMbo9OqsqPRGMljLodLcwd5XD5JbtNB0o89xZAwynY9EdCDsJU7LtcVCClu9DvM7/0Ep1hYX3EQ==} + dev: false + + /typedarray-to-buffer/3.1.5: + resolution: {integrity: sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==} + dependencies: + is-typedarray: 1.0.0 + dev: false + + /utf-8-validate/5.0.9: + resolution: {integrity: sha512-Yek7dAy0v3Kl0orwMlvi7TPtiCNrdfHNd7Gcc/pLq4BLXqfAmd0J7OWMizUQnTTJsyjKn02mU7anqwfmUP4J8Q==} + engines: {node: '>=6.14.2'} + requiresBuild: true + dependencies: + node-gyp-build: 4.4.0 + dev: false + + /webidl-conversions/3.0.1: + resolution: {integrity: sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=} + dev: false + + /websocket/1.0.34: + resolution: {integrity: sha512-PRDso2sGwF6kM75QykIesBijKSVceR6jL2G8NGYyq2XrItNC2P5/qL5XeR056GhA+Ly7JMFvJb9I312mJfmqnQ==} + engines: {node: '>=4.0.0'} + dependencies: + bufferutil: 4.0.6 + debug: 2.6.9 + es5-ext: 0.10.61 + typedarray-to-buffer: 3.1.5 + utf-8-validate: 5.0.9 + yaeti: 0.0.6 + transitivePeerDependencies: + - supports-color + dev: false + + /whatwg-url/5.0.0: + resolution: {integrity: sha1-lmRU6HZUYuN2RNNib2dCzotwll0=} + dependencies: + tr46: 0.0.3 + webidl-conversions: 3.0.1 + dev: false + + /ws/7.5.7: + resolution: {integrity: sha512-KMvVuFzpKBuiIXW3E4u3mySRO2/mCHSyZDJQM5NQ9Q9KHWHWh0NHgfbRMLLrceUK5qAL4ytALJbpRMjixFZh8A==} + engines: {node: '>=8.3.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ^5.0.2 + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + dev: false + + /ws/8.6.0: + resolution: {integrity: sha512-AzmM3aH3gk0aX7/rZLYvjdvZooofDu3fFOzGqcSnQ1tOcTWwhM/o+q++E8mAyVVIyUdajrkzWUGftaVSDLn1bw==} + engines: {node: '>=10.0.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ^5.0.2 + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + dev: false + + /yaeti/0.0.6: + resolution: {integrity: sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc=} + engines: {node: '>=0.10.32'} + dev: false + + /zod/3.17.3: + resolution: {integrity: sha512-4oKP5zvG6GGbMlqBkI5FESOAweldEhSOZ6LI6cG+JzUT7ofj1ZOC0PJudpQOpT1iqOFpYYtX5Pw0+o403y4bcg==} + dev: false + + github.com/devsnek/node-register-scheme/e7cc9a63a1f512565da44cb57316d9fb10750e17: + resolution: {tarball: https://codeload.github.com/devsnek/node-register-scheme/tar.gz/e7cc9a63a1f512565da44cb57316d9fb10750e17} + name: register-scheme + version: 0.0.2 + requiresBuild: true + dependencies: + bindings: 1.5.0 + node-addon-api: 1.7.2 + dev: false + optional: true diff --git a/responses/beep_response.js b/responses/beep_response.js new file mode 100644 index 0000000..4acc468 --- /dev/null +++ b/responses/beep_response.js @@ -0,0 +1,16 @@ +// Reply beep with boop + +// console.log(await interaction.fetchReply()); +// await interaction.deleteReply(); + +const wait = require("timers/promises").setTimeout; + +module.exports = async (interaction) => { + await interaction.reply("Boop!"); + + await wait(10000); + await interaction.followUp({ + content: "You saw the boop right?", + ephemeral: true, + }); +}; diff --git a/responses/echo_response.js b/responses/echo_response.js new file mode 100644 index 0000000..403b80c --- /dev/null +++ b/responses/echo_response.js @@ -0,0 +1,5 @@ +// Responds user with what he typed + +module.exports = async (interaction) => { + await interaction.reply(`You typed : ${interaction.options.getString("input")}`); +}; diff --git a/responses/info_response.js b/responses/info_response.js new file mode 100644 index 0000000..9992750 --- /dev/null +++ b/responses/info_response.js @@ -0,0 +1,21 @@ +module.exports = async (interaction) => { + if (interaction.options.getSubcommand() === "user") { + const user = interaction.options.getUser("target"); + + if (user) { + await interaction.reply(`Username: ${user.username}\nID: ${user.id}`); + } else { + await interaction.reply( + `Your username: ${interaction.user.username}\nYour ID: ${interaction.user.id}` + ); + } + } else if (interaction.options.getSubcommand() === "server") { + if (interaction.guild) { + await interaction.reply( + `Server name: ${interaction.guild.name}\nTotal members: ${interaction.guild.memberCount}` + ); + } else { + await interaction.reply("You need to be in a server!"); + } + } +}; diff --git a/responses/ping_response.js b/responses/ping_response.js new file mode 100644 index 0000000..7b520fc --- /dev/null +++ b/responses/ping_response.js @@ -0,0 +1,21 @@ +// Responds user with the ping of the bot +require("dotenv").config({ path: "../.env" }); + +module.exports = async (interaction) => { + if (interaction.guild && interaction.member.roles.cache.some((r) => r.id === process.env.AIDB_ADMIN_ROLE_ID)) { + const sent = await interaction.reply({ + content: "Pinging...", + fetchReply: true, + }); + + await interaction.editReply( + `Roundtrip latency: ${ + sent.createdTimestamp - interaction.createdTimestamp + }ms | Websocket heartbeat: ${interaction.client.ws.ping}ms.` + ); + + } else { + + await interaction.reply("You do not have permissions for this action"); + } +};