summaryrefslogtreecommitdiff
path: root/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'app.js')
-rw-r--r--app.js177
1 files changed, 53 insertions, 124 deletions
diff --git a/app.js b/app.js
index 9409ed7..697a3b6 100644
--- a/app.js
+++ b/app.js
@@ -1,137 +1,66 @@
-// TODO: add pause, resume and volume
-
-const fs = require('fs');
-const Discord = require('discord.js');
const config = require('./config.json');
-const bot = new Discord.Client();
-bot.commands = new Discord.Collection();
-bot.utils = new Discord.Collection();
-const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
-for (const file of commandFiles) {
- const command = require(`./commands/${file}`);
-
- bot.commands.set(command.name, command);
-}
-const utilFiles = fs.readdirSync('./utils').filter(file => file.endsWith('.js'));
-for (const file of utilFiles) {
- const util = require(`./utils/${file}`);
+const { CommandoClient } = require('discord.js-commando');
+const path = require('path');
+const { Structures } = require('discord.js');
+Structures.extend('Guild', Guild => {
+ class MusicGuild extends Guild {
+ constructor(client, data) {
+ super(client, data);
+ this.musicData = {
+ queue: [],
+ isPlaying: false,
+ volume: 1,
+ songDispatcher: null
+ };
+ }
+ }
+ return MusicGuild;
+});
- bot.utils.set(util.name, util);
-}
+const client = new CommandoClient({
+ commandPrefix: 's5n!',
+ owner: '217348698294714370'
+});
-bot.on('ready', () => {
- console.log(`Started bot: ${bot.user.tag} (ID: ${bot.user.id})\nCurrently running on ${bot.guilds.size} server(s).`); // Startup dialouge in output console
- bot.user.setActivity('psycho~ uwu', {
+client.registry
+ .registerDefaultTypes()
+ .registerGroups([
+ ['fun', 'fun command group'],
+ ['moderation', 'moderation command group'],
+ ['utility', 'utility command group'],
+ ['voice', 'voice command group']
+ ])
+ .registerDefaultGroups()
+ .registerDefaultCommands({
+ help: false
+ })
+ .registerCommandsIn(path.join(__dirname, 'commands'));
+
+client.once('ready', () => {
+ console.log(`Started bot: ${client.user.tag} (ID: ${client.user.id})\nCurrently running on ${client.guilds.cache.size} server(s).`);
+ client.user.setActivity('psycho~ uwu', {
type: 'LISTENING'
});
});
-bot.on('error', console.error);
-
-bot.on('message', async msg => {
- //if (msg.channel.name === 'bots' || msg.channel.name === 'bot-commands' || msg.member.hasPermission('KICK_MEMBERS')) {
- if (msg.author.bot) {
- // Debugging to see if the bot has an influence on the commands having an error
- //console.log('bot message picked up');
- return;
- } else {
- // Constants for uptime command
- const upTime = require('moment');
- require('moment-duration-format');
- const duration = upTime.duration(bot.uptime).format(" D [days], H [hrs], m [mins], s [secs]");
+client.on('error', console.error);
- // Command usage info for logs
- var msgContent = msg.content.toLowerCase();
- if (prefixCheck()) {
- console.log(msg.member.user.tag, 'says', msgContent, 'in #' + msg.channel.name);
+client.on('message', async msg => {
+ // When someone uses a command, it console.log's it
+ function prefixCheck() {
+ if (msgContent.startsWith('s5n!')) {
+ return true;
}
+ }
+ var msgContent = msg.content.toLowerCase();
+ if (prefixCheck()) {
+ console.log(msg.member.user.tag, 'says', msgContent, 'in #' + msg.channel.name);
+ }
- // Check if message has a prefix in it from config.json
- function prefixCheck() {
- if (msgContent.startsWith(config.prefixes.main)) {
- return "main";
- } else if (msgContent.startsWith(config.prefixes.alt)) {
- return "alt1";
- } else if (msgContent.startsWith(config.prefixes.alt2)) {
- return "alt2";
- } else if (msgContent.startsWith(config.prefixes.alt3)) {
- return "alt3";
- } else if (msgContent.startsWith(config.prefixes.alt4)) {
- return "alt4";
- } else if (msgContent.startsWith(config.prefixes.alt5)) {
- return "alt5";
- } else if (msgContent.startsWith(config.prefixes.alt6)) {
- return "alt6";
- } else if (msgContent.startsWith(config.prefixes.alt6b)) {
- return "alt6b";
- }
- }
-
- if (prefixCheck() == "main") {
- var args = msg.content.slice(config.prefixes.main.length).split(/ +/);
- var command = args.shift().toLowerCase();
-
- if (msg.author.bot || !msg.content.startsWith(config.prefixes.main)) return;
- } else if (prefixCheck() == "alt1") {
- var args = msg.content.slice(config.prefixes.alt.length).split(/ +/);
- var command = args.shift().toLowerCase();
-
- if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt)) return;
- } else if (prefixCheck() == "alt2") {
- var args = msg.content.slice(config.prefixes.alt2.length).split(/ +/);
- var command = args.shift().toLocaleLowerCase();
-
- if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt2)) return;
- } else if (prefixCheck() == "alt3") {
- var args = msg.content.slice(config.prefixes.alt3.length).split(/ +/);
- var command = args.shift().toLocaleLowerCase();
-
- if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt3)) return;
- } else if (prefixCheck() == "alt4") {
- var args = msg.content.slice(config.prefixes.alt4.length).split(/ +/);
- var command = args.shift().toLocaleLowerCase();
-
- if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt4)) return;
- } else if (prefixCheck() == "alt5") {
- var args = msg.content.slice(config.prefixes.alt4.length).split(/ +/);
- var command = args.shift().toLocaleLowerCase();
-
- if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt4)) return;
- } else if (prefixCheck() == "alt6") {
- var args = msg.content.slice(config.prefixes.alt4.length).split(/ +/);
- var command = args.shift().toLocaleLowerCase();
-
- if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt4)) return;
- } else if (prefixCheck() == "alt6b") {
- var args = msg.content.slice(config.prefixes.alt4b.length).split(/ +/);
- var command = args.shift().toLocaleLowerCase();
-
- if (msg.author.bot || !msg.content.startsWith(config.prefixes.alt4b)) return;
- }
-
- // Reacts with ping emoji when @everyone
- if (msg.mentions.everyone) {
- msg.react(':ArisaPing:695887537390223402');
- }
-
- // Cooldown check
- // TODO: implament cooldowns when needed https://discordjs.guide/command-handling/adding-features.html#cooldowns
-
- // Main commands try/ catch
- try {
- const cmd = bot.commands.get(command) || bot.commands.find(c => c.aliases && c.aliases.includes(command));
-
- if (!cmd) return;
- cmd.execute(msg, args, bot, duration);
- return;
- } catch (error) {
- console.error(error);
- msg.reply('command error\'d out, check logs. also, how did u manage to break it lol');
- return;
- }
- //} else if (msg.channel.name !== 'bots' && msg.content.startsWith(`${config.prefixes.main}`) && !msg.member.hasPermission('KICK_MEMBERS')) return;
+ // Reacts with ping emoji when @everyone
+ if (msg.mentions.everyone) {
+ msg.react(':ArisaPing:695887537390223402');
}
});
-// Get bot token
-bot.login(config['secret']); \ No newline at end of file
+client.login(config['secret']); \ No newline at end of file