From abb0664593833898bbd851429e97607c43d44333 Mon Sep 17 00:00:00 2001 From: Arch881010 <111789310+Arch881010@users.noreply.github.com> Date: Wed, 16 Nov 2022 17:08:51 -0600 Subject: [PATCH 1/3] Command tutorial, assistance by me, and command examples. --- app.js | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/app.js b/app.js index 7fbfd7e..10f6829 100644 --- a/app.js +++ b/app.js @@ -2,13 +2,34 @@ const { createInterface } = require('node:readline'); const { execSync } = require('child_process'); const fetch = require('node-fetch'); const { Client, Routes } = require('discord.js'); +//Pre-built AND changeable command +var ping = { + name: 'ping', + description: 'yes' +} +//Command Example +var command2 = { + name:'command2', + description:'yes' +} + +const commands = [ping, command2]; //Add your commands with commas to add them to the bot! +//Feel free to ask for help! I (Arch1010#4338) would love to help! Or ping me in hackermon's discord! https://discord.gg/M5MSE9CvNM const client = new Client({ intents: [] }); const rl = createInterface({ input: process.stdin, output: process.stdout }); -client.on('interactionCreate', (interaction) => { +client.on('interactionCreate', (interaction) => { //This is when the / command is used! + //This 'if'/'else if'/'else' statement allows you to add commands! + if (interaction.commandName === 'ping') { //commandName is auto generator by the interaction! Please change the text inside + //to a command that you are using. interaction.reply('yes'); + } else if(interaction.commandName === 'command2') { //This is the example command's name! + interaction.reply("Example Command!"); + } else { //A response if you forget to add the command here! + interaction.reply("This command's respone hasnt been added yet!"); + } }); const question = (q) => new Promise((resolve) => rl.question(q, resolve)); @@ -22,6 +43,7 @@ const question = (q) => new Promise((resolve) => rl.question(q, resolve)); await question(`Uh oh, looks like the node you're on is currently being blocked by Discord. Press the "Enter" button on your keyboard to be reassigned to a new node. (you'll need to rerun the program once you reconnect)`) // This kills the container manager on the repl forcing Replit to assign the repl to another node with another IP address (if the ip is globally rate limited) + //^ in short: Restarts the bot to be used again/attempted to start up again! execSync('kill 1'); return; }; @@ -30,12 +52,8 @@ const question = (q) => new Promise((resolve) => rl.question(q, resolve)); throw err }); - await client.rest.put(Routes.applicationCommands(client.user.id), { body: [ - { - name: 'ping', - description: 'yes' - } - ] }); + await client.rest.put(Routes.applicationCommands(client.user.id), { body: commands }); //commands added to the variable will auto update! console.log('DONE | Application/Bot is up and running. DO NOT CLOSE THIS TAB UNLESS YOU ARE FINISHED USING THE BOT, IT WILL PUT THE BOT OFFLINE.'); + //Do NOT disregard this message. Doing the opposite WILL turn the bot off and unresponsive to /commands! })(); From ac9dd3cede63a8f8ce533d13ea385fd0b35f3c51 Mon Sep 17 00:00:00 2001 From: hackermon Date: Wed, 16 Nov 2022 21:37:22 -0500 Subject: [PATCH 2/3] cleanup --- app.js | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/app.js b/app.js index 10f6829..993c5ce 100644 --- a/app.js +++ b/app.js @@ -2,33 +2,33 @@ const { createInterface } = require('node:readline'); const { execSync } = require('child_process'); const fetch = require('node-fetch'); const { Client, Routes } = require('discord.js'); -//Pre-built AND changeable command -var ping = { + +const ping = { name: 'ping', description: 'yes' -} -//Command Example +}; + + +// Command Example var command2 = { name:'command2', description:'yes' } -const commands = [ping, command2]; //Add your commands with commas to add them to the bot! -//Feel free to ask for help! I (Arch1010#4338) would love to help! Or ping me in hackermon's discord! https://discord.gg/M5MSE9CvNM +const commands = [ping, command2]; // Add your commands with commas to add them to the bot! +// Join the Discord for support: https://discord.gg/M5MSE9CvNM const client = new Client({ intents: [] }); const rl = createInterface({ input: process.stdin, output: process.stdout }); -client.on('interactionCreate', (interaction) => { //This is when the / command is used! - //This 'if'/'else if'/'else' statement allows you to add commands! - if (interaction.commandName === 'ping') { //commandName is auto generator by the interaction! Please change the text inside - //to a command that you are using. - interaction.reply('yes'); - } else if(interaction.commandName === 'command2') { //This is the example command's name! - interaction.reply("Example Command!"); - } else { //A response if you forget to add the command here! - interaction.reply("This command's respone hasnt been added yet!"); +client.on('interactionCreate', (interaction) => { + if (interaction.commandName === 'ping') { + interaction.reply('yes'); + } else if(interaction.commandName === 'command2') { // This is the example command's name! + interaction.reply('example command'); + } else { //A response if you forget to add the command here! + interaction.reply('this command\'s response has not been added yet!'); } }); @@ -55,5 +55,4 @@ const question = (q) => new Promise((resolve) => rl.question(q, resolve)); await client.rest.put(Routes.applicationCommands(client.user.id), { body: commands }); //commands added to the variable will auto update! console.log('DONE | Application/Bot is up and running. DO NOT CLOSE THIS TAB UNLESS YOU ARE FINISHED USING THE BOT, IT WILL PUT THE BOT OFFLINE.'); - //Do NOT disregard this message. Doing the opposite WILL turn the bot off and unresponsive to /commands! })(); From 02eb522a059c7258d94fef3e653e7f5d991625e0 Mon Sep 17 00:00:00 2001 From: hackermon Date: Wed, 16 Nov 2022 21:38:47 -0500 Subject: [PATCH 3/3] Update app.js --- app.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index 993c5ce..bd9717f 100644 --- a/app.js +++ b/app.js @@ -10,7 +10,7 @@ const ping = { // Command Example -var command2 = { +const command2 = { name:'command2', description:'yes' } @@ -27,7 +27,7 @@ client.on('interactionCreate', (interaction) => { interaction.reply('yes'); } else if(interaction.commandName === 'command2') { // This is the example command's name! interaction.reply('example command'); - } else { //A response if you forget to add the command here! + } else { // a response if you forget to add the command here interaction.reply('this command\'s response has not been added yet!'); } }); @@ -52,7 +52,7 @@ const question = (q) => new Promise((resolve) => rl.question(q, resolve)); throw err }); - await client.rest.put(Routes.applicationCommands(client.user.id), { body: commands }); //commands added to the variable will auto update! + await client.rest.put(Routes.applicationCommands(client.user.id), { body: commands }); console.log('DONE | Application/Bot is up and running. DO NOT CLOSE THIS TAB UNLESS YOU ARE FINISHED USING THE BOT, IT WILL PUT THE BOT OFFLINE.'); })();