Files
archivebot/index.js
T

107 lines
2.7 KiB
JavaScript
Raw Normal View History

2022-08-19 18:16:47 +00:00
//Server stuff
const express = require('express');
const app = express();
app.get("/", (req, res) => {
res.send("Hello World, it's me, Archive Bot!")
})
app.listen(3000, () => {
console.log('Archive Bot online!');
})
//Server stuff end
const { Client, Intents } = require('discord.js');
const Discord = require('discord.js');
const token = process.env['token'];
const inst = process.env['instagram'];
const twit = process.env['twitter'];
const redd = process.env['reddit'];
const you = process.env['youtube'];
const oth = process.env['other'];
const nsfw = process.env['nsfw'];
const list = [inst, twit, redd, you, oth, nsfw]
const bot = new Client({
2022-08-19 18:16:47 +00:00
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS
],
});
const prefix = '/';
const emojiPrefix = "<:archive:";
const fs = require('fs');
// client.commands = new Discord.Collection();
// client.commNames = new Discord.Collection();
2022-08-19 18:16:47 +00:00
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
let i = 0;
const commands = bot.application.commands;
2022-08-19 18:16:47 +00:00
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
commands.create({
name: command.name,
description: command.description,
options: command.options,
dm_permission: false,
});
2022-08-19 18:16:47 +00:00
i ++;
}
client.on('interactionCreate', async interaction => {
const { commandName } = interaction;
2022-08-19 18:16:47 +00:00
if (commandName == 'archive') {
const arch = require('./commands/archive.js');
arch.execute(interaction, list, bot, Discord);
} else {
interaction.reply("Invalid Command!");
}
});
2022-08-19 18:16:47 +00:00
// client.on('ready', () => {
// console.log('Archive Bot online!');
// });
/*
2022-08-19 18:16:47 +00:00
client.on('messageCreate', (message) => {
//COMMAND AREA
//Check if the prefix exists
let args;
let command;
if (message.content.startsWith(emojiPrefix)) {
args = message.content.slice(30).split(' ');
// args.splice(args.indexOf(''), 1);
command = 'archive';
} else if (!message.content.startsWith(prefix) || message.author.bot) return;
else {
args = message.content.slice(prefix.length).split(' ');
command = args.shift().toLowerCase();
}
//Check if the user has sufficient permission
//Performes the command
switch(command) {
case 'test': client.commands.get('Hello World').execute(message, args);
break;
case 'archive': client.commands.get('archive').execute(message, args, list, client, Discord);
break;
default: message.channel.send("'" + message.content + "' is not a command!");
}
})
*/
2022-08-19 18:16:47 +00:00
//Last Line
bot.login(token);