This commit is contained in:
hackermon 2022-11-16 21:37:22 -05:00 committed by GitHub
parent abb0664593
commit ac9dd3cede
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

21
app.js
View File

@ -2,11 +2,13 @@ const { createInterface } = require('node:readline');
const { execSync } = require('child_process'); const { execSync } = require('child_process');
const fetch = require('node-fetch'); const fetch = require('node-fetch');
const { Client, Routes } = require('discord.js'); const { Client, Routes } = require('discord.js');
//Pre-built AND changeable command
var ping = { const ping = {
name: 'ping', name: 'ping',
description: 'yes' description: 'yes'
} };
// Command Example // Command Example
var command2 = { var command2 = {
name:'command2', name:'command2',
@ -14,21 +16,19 @@ var command2 = {
} }
const commands = [ping, command2]; // Add your commands with commas to add them to the bot! 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 // Join the Discord for support: https://discord.gg/M5MSE9CvNM
const client = new Client({ intents: [] }); const client = new Client({ intents: [] });
const rl = createInterface({ input: process.stdin, output: process.stdout }); const rl = createInterface({ input: process.stdin, output: process.stdout });
client.on('interactionCreate', (interaction) => { //This is when the / command is used! client.on('interactionCreate', (interaction) => {
//This 'if'/'else if'/'else' statement allows you to add commands! if (interaction.commandName === 'ping') {
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'); interaction.reply('yes');
} else if(interaction.commandName === 'command2') { // This is the example command's name! } else if(interaction.commandName === 'command2') { // This is the example command's name!
interaction.reply("Example Command!"); 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 respone hasnt been added yet!"); 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! 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.'); 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!
})(); })();