Add Discord.js stuff
This commit is contained in:
parent
1d7c16eea3
commit
f67ddacb88
10
commands/fetch/fetch.js
Normal file
10
commands/fetch/fetch.js
Normal file
@ -0,0 +1,10 @@
|
||||
const { SlashCommandBuilder } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('fetch')
|
||||
.setDescription('Fetch\'s All Youre Data\'s !! :3'),
|
||||
async execute(interaction) {
|
||||
await interaction.reply('fuck yoy');
|
||||
},
|
||||
};
|
43
deploy-dev.js
Normal file
43
deploy-dev.js
Normal file
@ -0,0 +1,43 @@
|
||||
const { REST, Routes } = require('discord.js');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const dotenv = require('dotenv');
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const commands = [];
|
||||
const foldersPath = path.join(__dirname, 'commands');
|
||||
const commandFolders = fs.readdirSync(foldersPath);
|
||||
|
||||
for (const folder of commandFolders) {
|
||||
const commandsPath = path.join(foldersPath, folder);
|
||||
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
|
||||
for (const file of commandFiles) {
|
||||
const filePath = path.join(commandsPath, file);
|
||||
const command = require(filePath);
|
||||
if ('data' in command && 'execute' in command) {
|
||||
commands.push(command.data.toJSON());
|
||||
}
|
||||
else {
|
||||
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const rest = new REST().setToken(process.env.TOKEN);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
console.log(`Started refreshing ${commands.length} application (/) commands.`);
|
||||
|
||||
const data = await rest.put(
|
||||
Routes.applicationGuildCommands(process.env.CLIENT, process.env.GUILD),
|
||||
{ body: commands },
|
||||
);
|
||||
|
||||
console.log(`Successfully reloaded ${data.length} application (/) commands.`);
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
})();
|
43
deploy.js
Normal file
43
deploy.js
Normal file
@ -0,0 +1,43 @@
|
||||
const { REST, Routes } = require('discord.js');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const dotenv = require('dotenv');
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const commands = [];
|
||||
const foldersPath = path.join(__dirname, 'commands');
|
||||
const commandFolders = fs.readdirSync(foldersPath);
|
||||
|
||||
for (const folder of commandFolders) {
|
||||
const commandsPath = path.join(foldersPath, folder);
|
||||
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
|
||||
for (const file of commandFiles) {
|
||||
const filePath = path.join(commandsPath, file);
|
||||
const command = require(filePath);
|
||||
if ('data' in command && 'execute' in command) {
|
||||
commands.push(command.data.toJSON());
|
||||
}
|
||||
else {
|
||||
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const rest = new REST().setToken(process.env.TOKEN);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
console.log(`Started refreshing ${commands.length} application (/) commands.`);
|
||||
|
||||
const data = await rest.put(
|
||||
Routes.applicationCommands(process.env.CLIENT),
|
||||
{ body: commands },
|
||||
);
|
||||
|
||||
console.log(`Successfully reloaded ${data.length} application (/) commands.`);
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
})();
|
50
eslint.config.js
Normal file
50
eslint.config.js
Normal file
@ -0,0 +1,50 @@
|
||||
const js = require('@eslint/js');
|
||||
|
||||
module.exports = [
|
||||
js.configs.recommended,
|
||||
{
|
||||
languageOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
},
|
||||
rules: {
|
||||
'arrow-spacing': ['warn', { before: true, after: true }],
|
||||
'brace-style': ['error', 'stroustrup', { allowSingleLine: true }],
|
||||
'comma-dangle': ['error', 'always-multiline'],
|
||||
'comma-spacing': 'error',
|
||||
'comma-style': 'error',
|
||||
curly: ['error', 'multi-line', 'consistent'],
|
||||
'dot-location': ['error', 'property'],
|
||||
'handle-callback-err': 'off',
|
||||
indent: ['error', 'tab'],
|
||||
'keyword-spacing': 'error',
|
||||
'max-nested-callbacks': ['error', { max: 4 }],
|
||||
'max-statements-per-line': ['error', { max: 2 }],
|
||||
'no-console': 'off',
|
||||
'no-empty-function': 'error',
|
||||
'no-floating-decimal': 'error',
|
||||
'no-inline-comments': 'error',
|
||||
'no-lonely-if': 'error',
|
||||
'no-multi-spaces': 'error',
|
||||
'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1, maxBOF: 0 }],
|
||||
'no-shadow': ['error', { allow: ['err', 'resolve', 'reject'] }],
|
||||
'no-trailing-spaces': ['error'],
|
||||
'no-var': 'error',
|
||||
'no-undef': 'off',
|
||||
'object-curly-spacing': ['error', 'always'],
|
||||
'prefer-const': 'error',
|
||||
quotes: ['error', 'single'],
|
||||
semi: ['error', 'always'],
|
||||
'space-before-blocks': 'error',
|
||||
'space-before-function-paren': ['error', {
|
||||
anonymous: 'never',
|
||||
named: 'never',
|
||||
asyncArrow: 'always',
|
||||
}],
|
||||
'space-in-parens': 'error',
|
||||
'space-infix-ops': 'error',
|
||||
'space-unary-ops': 'error',
|
||||
'spaced-comment': 'error',
|
||||
yoda: 'error',
|
||||
},
|
||||
},
|
||||
];
|
28
events/interactionCreate.js
Normal file
28
events/interactionCreate.js
Normal file
@ -0,0 +1,28 @@
|
||||
const { Events, MessageFlags } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
name: Events.InteractionCreate,
|
||||
async execute(interaction) {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
const command = interaction.client.commands.get(interaction.commandName);
|
||||
|
||||
if (!command) {
|
||||
console.error(`No command matching ${interaction.commandName} was found.`);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await command.execute(interaction);
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error);
|
||||
if (interaction.replied || interaction.deferred) {
|
||||
await interaction.followUp({ content: 'There was an error while executing this command!', flags: MessageFlags.Ephemeral });
|
||||
}
|
||||
else {
|
||||
await interaction.reply({ content: 'There was an error while executing this command!', flags: MessageFlags.Ephemeral });
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
17
events/ready.js
Normal file
17
events/ready.js
Normal file
@ -0,0 +1,17 @@
|
||||
const { Events, ActivityType } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
name: Events.ClientReady,
|
||||
once: true,
|
||||
execute(client) {
|
||||
console.log(`Ready! Logged in as ${client.user.tag}`);
|
||||
client.user.setPresence({
|
||||
activities: [{
|
||||
name: 'with bnuuys',
|
||||
state: 'bnuy bnuy bnuy bnuy bnuy',
|
||||
type: ActivityType.Playing,
|
||||
}],
|
||||
status: 'online',
|
||||
});
|
||||
},
|
||||
};
|
49
index.js
Normal file
49
index.js
Normal file
@ -0,0 +1,49 @@
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const { Client, Collection, GatewayIntentBits } = require('discord.js');
|
||||
const dotenv = require('dotenv');
|
||||
const ON_DEATH = require('death');
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.MessageContent] });
|
||||
|
||||
ON_DEATH(function(signal, err) {
|
||||
console.log(`Bot exit signal:${signal} Err:${err}`);
|
||||
client.destroy();
|
||||
});
|
||||
|
||||
client.commands = new Collection();
|
||||
const foldersPath = path.join(__dirname, 'commands');
|
||||
const commandFolders = fs.readdirSync(foldersPath);
|
||||
|
||||
for (const folder of commandFolders) {
|
||||
const commandsPath = path.join(foldersPath, folder);
|
||||
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
|
||||
for (const file of commandFiles) {
|
||||
const filePath = path.join(commandsPath, file);
|
||||
const command = require(filePath);
|
||||
if ('data' in command && 'execute' in command) {
|
||||
client.commands.set(command.data.name, command);
|
||||
}
|
||||
else {
|
||||
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const eventsPath = path.join(__dirname, 'events');
|
||||
const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));
|
||||
|
||||
for (const file of eventFiles) {
|
||||
const filePath = path.join(eventsPath, file);
|
||||
const event = require(filePath);
|
||||
if (event.once) {
|
||||
client.once(event.name, (...args) => event.execute(...args));
|
||||
}
|
||||
else {
|
||||
client.on(event.name, (...args) => event.execute(...args));
|
||||
}
|
||||
}
|
||||
|
||||
client.login(process.env.TOKEN);
|
1399
package-lock.json
generated
Normal file
1399
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
20
package.json
Normal file
20
package.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "bnuuy-mc-search",
|
||||
"version": "1.0.0",
|
||||
"description": "bnuuuuuuuuy",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "jaezu",
|
||||
"license": "WTFPL",
|
||||
"dependencies": {
|
||||
"death": "^1.1.0",
|
||||
"discord.js": "^14.21.0",
|
||||
"dotenv": "^17.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.32.0",
|
||||
"eslint": "^9.32.0"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user