mirror of
https://github.com/gabrielkheisa/discord-active-developer-badge.git
synced 2024-11-22 19:41:55 +07:00
Merge pull request #13 from Arch881010/main
Command tutorial, assistance by me, and command examples.
This commit is contained in:
commit
0e61652e1f
31
app.js
31
app.js
@ -3,12 +3,33 @@ 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');
|
||||||
|
|
||||||
|
const ping = {
|
||||||
|
name: 'ping',
|
||||||
|
description: 'yes'
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Command Example
|
||||||
|
const command2 = {
|
||||||
|
name:'command2',
|
||||||
|
description:'yes'
|
||||||
|
}
|
||||||
|
|
||||||
|
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 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) => {
|
client.on('interactionCreate', (interaction) => {
|
||||||
interaction.reply('yes');
|
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!');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const question = (q) => new Promise((resolve) => rl.question(q, resolve));
|
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)`)
|
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)
|
// 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');
|
execSync('kill 1');
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
@ -30,12 +52,7 @@ const question = (q) => new Promise((resolve) => rl.question(q, resolve));
|
|||||||
throw err
|
throw err
|
||||||
});
|
});
|
||||||
|
|
||||||
await client.rest.put(Routes.applicationCommands(client.user.id), { body: [
|
await client.rest.put(Routes.applicationCommands(client.user.id), { body: commands });
|
||||||
{
|
|
||||||
name: 'ping',
|
|
||||||
description: 'yes'
|
|
||||||
}
|
|
||||||
] });
|
|
||||||
|
|
||||||
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.');
|
||||||
})();
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user