From 9f39777642b3f44386df711afeab6490dc508007 Mon Sep 17 00:00:00 2001 From: Alee Date: Sun, 25 Mar 2018 09:36:32 -0400 Subject: Moved all source files --- src/bot_discord.js | 113 ---------------------------------------------- src/commands/ask.js | 30 ------------ src/commands/avatarurl.js | 14 ------ src/commands/ban.js | 23 ---------- src/commands/changelog.js | 23 ---------- src/commands/eval.js | 67 --------------------------- src/commands/git.js | 14 ------ src/commands/help.js | 41 ----------------- src/commands/invitebot.js | 16 ------- src/commands/kick.js | 18 -------- src/commands/ping.js | 14 ------ src/commands/play.js | 71 ----------------------------- src/commands/poweroff.js | 17 ------- src/commands/purge.js | 21 --------- src/commands/say.js | 18 -------- src/commands/uptime.js | 26 ----------- src/music.js | 68 ---------------------------- 17 files changed, 594 deletions(-) delete mode 100644 src/bot_discord.js delete mode 100644 src/commands/ask.js delete mode 100644 src/commands/avatarurl.js delete mode 100644 src/commands/ban.js delete mode 100644 src/commands/changelog.js delete mode 100644 src/commands/eval.js delete mode 100644 src/commands/git.js delete mode 100644 src/commands/help.js delete mode 100644 src/commands/invitebot.js delete mode 100644 src/commands/kick.js delete mode 100644 src/commands/ping.js delete mode 100644 src/commands/play.js delete mode 100644 src/commands/poweroff.js delete mode 100644 src/commands/purge.js delete mode 100644 src/commands/say.js delete mode 100644 src/commands/uptime.js delete mode 100644 src/music.js (limited to 'src') diff --git a/src/bot_discord.js b/src/bot_discord.js deleted file mode 100644 index 1361bdb..0000000 --- a/src/bot_discord.js +++ /dev/null @@ -1,113 +0,0 @@ -/** ******************************************* - * - * AleeBot for Discord servers - * Copyright (C) 2018 AleeCorp - * License: MIT - * - **********************************************/ -const Discord = require('discord.js'); -const client = new Discord.Client(); -const abVersion = '2.3.0'; -const prefix = 'ab:'; -const fs = require('fs'); -const config = require('./absettings.json'); -console.log('Welcome to AleeBot NodeJS Terminal!'); - -client.apikey = config.ytapikey; -client.commands = new Discord.Collection(); -client.aliases = new Discord.Collection(); -client.servers = {}; - -fs.readdir('./commands', (err, files) => { - if (err) console.error(err); - console.log(`Attempting to load a total of ${files.length} commands into the memory.`); - files.forEach(file => { - try { - const command = require(`./commands/${file}`); - console.log(`Attempting to load the command "${command.help.name}".`); - client.commands.set(command.help.name, command); - command.conf.aliases.forEach(alias => { - client.aliases.set(alias, command.help.name); - console.log(`Attempting to load "${alias}" as an alias for "${command.help.name}"`); - }); - } - catch (err) { - console.log('An error has occured trying to load a command. Here is the error.'); - console.log(err.stack); - } - }); - console.log('Command Loading complete!'); - console.log('\n'); -}); - - -client.on('ready', () => { - console.log('[>] AleeBot is now ready!'); - console.log('[i] Running version ' + abVersion + ` and in ${client.guilds.size} guilds`); - - client.setInterval(function() { - const games = [ - 'AleeBot ' + abVersion + ' | ' + config.prefix + 'help', - 'Annoying Alee', - 'Coding stuff', - 'Drawing shapes', - 'Fighting AstralMod', - ]; - - client.user.setPresence({ - status: 'online', - afk: false, - game: { - type: 0, - name: games[Math.floor(Math.random() * games.length)], - }, - }); - }, 200000); - client.user.setStatus('online'); -}); - -client.on('guildCreate', guild => { - - console.log(`[i] New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`); - -}); - - -client.on('guildDelete', guild => { - - console.log(`[i] I have been removed from: ${guild.name} (id: ${guild.id})`); - -}); - - -client.on('message', (msg) => { - if (msg.author.bot) return; - - if (!msg.content.startsWith(prefix)) return; - const args = msg.content.slice(prefix.length).trim().split(/ +/g); - const command = args.shift(); - let cmd; - - if (client.commands.has(command)) { - cmd = client.commands.get(command); - } else if (client.aliases.has(command)) { - cmd = client.commands.get(client.aliases.get(command)); - } - - if (cmd) { - if (cmd.conf.guildOnly == true) { - if (!msg.channel.guild) { - return msg.channel.createMessage('This command can only be ran in a guild.'); - } - } - try { - cmd.run(client, msg, args); - } - catch (e) { - console.error(e); - } - } -}); -client.login(config.abtoken).catch(function() { - console.log('[X] Login failed. Please contact Alee14#9928 or email him at alee14498@gmail.com.'); -}); diff --git a/src/commands/ask.js b/src/commands/ask.js deleted file mode 100644 index d3d0f4a..0000000 --- a/src/commands/ask.js +++ /dev/null @@ -1,30 +0,0 @@ -module.exports.run = async (client, message, args) => { - let abaskanswer = [ - "Yes.", - "Nope. Just kidding :P", - "Definitely!", - "No.", - "Yep. Just kidding :P", - "I doubt it.", - "Maybe?", - "I don't know?", - "Hmm let me think :thinking:" - ]; - if (args[1]) { - message.channel.sendMessage(abaskanswer[Math.floor(Math.random() * abaskanswer.length)]); - } else { - message.channel.sendMessage("Sorry, I don't know what your saying.") - } - }; - - exports.conf = { - aliases: ['8ball'], - guildOnly: false, - }; - exports.help = { - name: 'ask', - description: 'Give AleeBot a question!', - usage: 'ask [args]', - category: '- Fun Commands', - }; - \ No newline at end of file diff --git a/src/commands/avatarurl.js b/src/commands/avatarurl.js deleted file mode 100644 index 87e9321..0000000 --- a/src/commands/avatarurl.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports.run = async (client, message) => { - message.reply(message.author.avatarURL); -}; - -exports.conf = { - aliases: [], - guildOnly: false, -}; -exports.help = { - name: 'avatarurl', - description: 'Sends you your avatar picture.', - usage: 'avatarurl', - category: '- Fun Commands', -}; diff --git a/src/commands/ban.js b/src/commands/ban.js deleted file mode 100644 index a8d5c6a..0000000 --- a/src/commands/ban.js +++ /dev/null @@ -1,23 +0,0 @@ -module.exports.run = async (client, message, args) => { - let mreason = args.join(" ").slice(22); - - if (!message.member.permissions.has('BAN_MEMBERS')) return message.reply("It looks like that you don't have the permissions to ban people.") - const member = message.mentions.members.first(); - if (!member) return message.reply("Uhh... Please mention a member first."); - member.ban({ - days: args[1] || null, - reason: `Banned by ${message.author.tag}` - }); - message.reply("User Banned!"); -}; - -exports.conf = { - aliases: [], - guildOnly: false, -}; -exports.help = { - name: 'ban', - description: 'Bans a member', - usage: 'ban [user] [time]', - category: '- Moderation Commands', -}; diff --git a/src/commands/changelog.js b/src/commands/changelog.js deleted file mode 100644 index 2c69bb0..0000000 --- a/src/commands/changelog.js +++ /dev/null @@ -1,23 +0,0 @@ -module.exports.run = async (client, message) => { - const Discord = require('discord.js'); - const embed = new Discord.RichEmbed() - .setAuthor('AleeBot ' + '2.3.0 ' + 'Changelog', 'https://cdn.discordapp.com/avatars/282547024547545109/6c147a444ae328c38145ef1f74169e38.png?size=2048') - .setDescription('What\'s new in AleeBot 2.3?') - .addField('[>] Purge Command!','Purge command only for moderators!', true) - .addField('[>] Say Command!','Say command is only for the person who created the bot!', true) - .setFooter('AleeCorp Copyright 2017') - .setColor('#1fd619'); - message.channel.sendEmbed(embed); - -}; - -exports.conf = { - aliases: [], - guildOnly: false, -}; -exports.help = { - name: 'changelog', - description: 'What\'s new', - usage: 'changelog', - category: '- General Commands', -}; diff --git a/src/commands/eval.js b/src/commands/eval.js deleted file mode 100644 index a1aae92..0000000 --- a/src/commands/eval.js +++ /dev/null @@ -1,67 +0,0 @@ -module.exports.run = async (client, message, args) => { - if (!['242775871059001344',].includes(message.author.id)) return message.reply('Nope! You need the person who created this bot to use this command.'); - const { RichEmbed } = require('discord.js'); - const code = args.join(' '); - - let evaled; - let remove; - - try { - remove = text => { - if (typeof(text) === 'string') { - return text.replace(/`/g, '`' + String.fromCharCode(8203)).replace(/@/g, '@' + String.fromCharCode(8203)); - } else { - return text; - } - }; - - evaled = eval(code); - - if (typeof evaled !== 'string') { - evaled = require('util').inspect(evaled); - } - - } catch (err) { - const embed = new RichEmbed() - .setAuthor('Eval Error') - .setDescription('Eval\'s result') - .addField(':inbox_tray: Input:', `\`\`\`js\n${code}\n\`\`\``) - .addField(':outbox_tray: Output:', `\`\`\`${err}\`\`\``) - .setFooter('Eval', client.user.avatarURL) - .setColor('RED'); - return message.channel.send({ embed }); - } - - try { - const embed = new RichEmbed() - .setAuthor('Eval Success') - .setDescription('Eval\'s result') - .addField(':inbox_tray: Input:', `\`\`\`js\n${code}\n\`\`\``) - .addField(':outbox_tray: Output:', `\`\`\`js\n${remove(evaled)}\n\`\`\``) - .setFooter('Eval', client.user.avatarURL) - .setColor('GREEN'); - - return message.channel.send({ embed }); - } catch (err) { - const embed = new RichEmbed() - .setAuthor('Eval Error') - .setDescription('Eval\'s result') - .addField(':inbox_tray: Input:', `\`\`\`js\n${code}\n\`\`\``) - .addField(':outbox_tray: Output:', `\`\`\`${err}\`\`\``) - .setFooter('Eval', client.user.avatarURL) - .setColor('RED'); - return message.channel.send({ embed }); - } - }; - - exports.conf = { - aliases: [], - guildOnly: false, - }; - exports.help = { - name: 'eval', - description: 'Evalulates commands.', - usage: '', - category: '- Owners Only', - }; - \ No newline at end of file diff --git a/src/commands/git.js b/src/commands/git.js deleted file mode 100644 index a01d0a3..0000000 --- a/src/commands/git.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports.run = async (client, message) => { - message.author.send('I can see you want to contribute to this project.\nHere\'s the link: https://github.com/AleeCorp/AleeBot'); -}; - -exports.conf = { - aliases: [], - guildOnly: false, -}; -exports.help = { - name: 'git', - description: 'Get the git info.', - usage: 'git', - category: '- General Commands', -}; diff --git a/src/commands/help.js b/src/commands/help.js deleted file mode 100644 index 4033289..0000000 --- a/src/commands/help.js +++ /dev/null @@ -1,41 +0,0 @@ -const Discord = require('discord.js'); -module.exports.run = async (client, message) => { - const categories = []; - const commands = Array.from(client.commands.keys()); - - commands.forEach(function(x) { - if (!categories.includes(client.commands.get(x).help.category)) { - categories.push(client.commands.get(x).help.category); - } - }); - - const embed = new Discord.RichEmbed() - .setTitle('AleeBot Help') - .setAuthor('AleeBot 2.3.0' + ` Help and on ${client.guilds.size} servers`, 'https://cdn.discordapp.com/avatars/282547024547545109/6c147a444ae328c38145ef1f74169e38.png?size=2048') - .setDescription('Every command you input into AleeBot is `' + require('../absettings.json').prefix + '`') - .setColor('#1fd619') - .setFooter('AleeCorp Copyright 2018'); - - categories.forEach(function(x) { - let cat = ''; - commands.forEach(function(command) { - if (client.commands.get(command).help.category == x) { - cat = cat + command + '\n'; - } - }); - embed.addField(x, cat); - }); - - await message.channel.send({ embed }); -}; - -exports.conf = { - aliases: ['h'], - guildOnly: false, -}; -exports.help = { - name: 'help', - description: 'Displays all the commands or a page with information for 1 command.', - usage: 'help (command:command-name)', - category: '- General Commands', -}; diff --git a/src/commands/invitebot.js b/src/commands/invitebot.js deleted file mode 100644 index 2017cf3..0000000 --- a/src/commands/invitebot.js +++ /dev/null @@ -1,16 +0,0 @@ -module.exports.run = async (client, message) => { - message.reply("Continue in DMs.") - message.author.send('Want AleeBot in your server? Here\'s the link: https://discordapp.com/oauth2/authorize?client_id=282547024547545109&permissions=68185158&scope=bot'); - }; - - exports.conf = { - aliases: [], - guildOnly: false, - }; - exports.help = { - name: 'invitebot', - description: 'Invite AleeBot to your server.', - usage: 'invitebot', - category: '- General Commands', - }; - \ No newline at end of file diff --git a/src/commands/kick.js b/src/commands/kick.js deleted file mode 100644 index ffef077..0000000 --- a/src/commands/kick.js +++ /dev/null @@ -1,18 +0,0 @@ -module.exports.run = async (client, message) => { - if (!message.member.permissions.has('KICK_MEMBERS')) return message.reply("It looks like that you don't have the permissions to ban people.") - const member = message.mentions.members.first(); - if (!member) return message.reply("Uhh... Please mention a member first."); - member.kick(`Kicked by: ${message.author.tag}`); - message.reply("User Kicked!"); -}; - -exports.conf = { - aliases: [], - guildOnly: false, -}; -exports.help = { - name: 'kick', - description: 'Kicks a member', - usage: 'kick [user]', - category: '- Moderation Commands', -}; diff --git a/src/commands/ping.js b/src/commands/ping.js deleted file mode 100644 index 5ad8f78..0000000 --- a/src/commands/ping.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports.run = async (client, message) => { - message.reply('**PONG!** :ping_pong: ' + Math.round(client.ping) + ' ms'); -}; - -exports.conf = { - aliases: [], - guildOnly: false, -}; -exports.help = { - name: 'ping', - description: 'Ping the bot.', - usage: 'ping', - category: '- General Commands', -}; diff --git a/src/commands/play.js b/src/commands/play.js deleted file mode 100644 index d94572e..0000000 --- a/src/commands/play.js +++ /dev/null @@ -1,71 +0,0 @@ -module.exports.run = async (client, message, args) => { - if (!args[0]) return await message.channel.send('A name of the song of a link is needed.'); - if (!message.member.voiceChannelID) return await message.channel.send('You are not in a voice channel'); - const YouTube = require('simple-youtube-api'); - const moment = require('moment'); - const youtube = new YouTube(client.apikey); - const url = args.join(' ').replace(/<(.+)>/g, '$1'); - if (!url) return; - await youtube.getVideo(url) - .then(results => { - YTVideo(results); - }) - .catch(() => { - youtube.searchVideos(args.join(' '), 1) - .then(results => { - youtube.getVideo(results[0].url) - .then(vid => { - YTVideo(vid); - }); - }); - }); - - const music = require('../music.js'); - async function YTVideo(video) { - if (video.durationSeconds === 0) { - return message.channel.send('Live streams are not available'); - } - const d = moment.duration({ - s: video.durationSeconds - }); - - const server = music.MusicVariables(client, message.member.guild.id); - const time = moment().startOf('day').add(d).format('HH:mm:ss'); - server.queue.push({ - url: video.url, - title: video.title, - thumbnail: video.thumbnails.high.url, - duration: video.durationSeconds, - requested: message.author.mention, - playing: false - }); - const { RichEmbed } = require('discord.js'); - - const embed = new RichEmbed() - .setTitle('A song has been queued') - .setAuthor(video.title, video.thumbnails.high.url) - .setColor(0x00afff) - .setTimestamp() - .addField('Title', video.title) - .addField('Link', video.url) - .addField('Duration', time) - .setThumbnail(video.thumbnails.high.url) - .setFooter('AleeBot Music Player'); - await message.channel.send({embed}); - if (!client.voiceConnections.get(message.member.guild.id)) - message.member.voiceChannel.join().then(function(connection) { - music.playYT(client, connection, message); - }); - return null; - }}; - -exports.conf = { - aliases: [], - guildOnly: false, -}; -exports.help = { - name: 'play', - description: 'Plays music', - usage: 'play [args]', - category: '- Music Commands', -}; diff --git a/src/commands/poweroff.js b/src/commands/poweroff.js deleted file mode 100644 index 8016726..0000000 --- a/src/commands/poweroff.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports.run = async (client, message, args) => { - if (!['242775871059001344',].includes(message.author.id)) return message.reply('Nope! You need the person who created this bot to use this command.'); - await message.reply(':warning: AleeBot will now exit!'); - process.exit(0); - }; - - exports.conf = { - aliases: ['reboot'], - guildOnly: false, - }; - exports.help = { - name: 'poweroff', - description: 'Turns off AleeBot.', - usage: 'poweroff', - category: '- Owners Only', - }; - \ No newline at end of file diff --git a/src/commands/purge.js b/src/commands/purge.js deleted file mode 100644 index 36a0803..0000000 --- a/src/commands/purge.js +++ /dev/null @@ -1,21 +0,0 @@ -module.exports.run = async (client, message, args) => { - if (!message.member.permissions.has('MANAGE_MESSAGES')) return message.reply("It looks like that you don't have the permissions to delete messages.") - if (isNaN(args[0])) return message.reply("Please put the valid number of messages to purge."); - - if (args[0] > 100) return message.channel.send("Please put a number less than 100."); - - message.channel.bulkDelete(args[0]) - .then( messages => message.channel.send(`Successfully deleted ${messages.size} messages.`)) - }; - - exports.conf = { - aliases: ['rm'], - guildOnly: false, - }; - exports.help = { - name: 'purge', - description: 'Removes messages in a bulk.', - usage: 'purge [number]', - category: '- Moderation Commands', - }; - \ No newline at end of file diff --git a/src/commands/say.js b/src/commands/say.js deleted file mode 100644 index dfa2323..0000000 --- a/src/commands/say.js +++ /dev/null @@ -1,18 +0,0 @@ -module.exports.run = async (client, message, args) => { - if (!['242775871059001344',].includes(message.author.id)) return message.reply('Nope! You need the person who created this bot to use this command.'); - let absay = args.join(" "); - message.delete().catch(); - message.channel.send(absay); - }; - - exports.conf = { - aliases: [], - guildOnly: false, - }; - exports.help = { - name: 'say', - description: 'You can control AleeBot now!', - usage: 'say [context]', - category: '- Owners Only', - }; - \ No newline at end of file diff --git a/src/commands/uptime.js b/src/commands/uptime.js deleted file mode 100644 index c1c3ad7..0000000 --- a/src/commands/uptime.js +++ /dev/null @@ -1,26 +0,0 @@ -module.exports.run = async (client, message) => { - - let uptime = parseInt(client.uptime); - uptime = Math.floor(uptime / 1000); - let uptimeMinutes = Math.floor(uptime / 60); - const minutes = uptime % 60; - let hours = 0; - while (uptimeMinutes >= 60) { - hours++; - uptimeMinutes = uptimeMinutes - 60; - } - const uptimeSeconds = minutes % 60; - message.channel.send(':clock3: AleeBot has been up for ' + hours + ' hours, ' + uptimeMinutes + ' minutes, and ' + uptimeSeconds + ' seconds.'); - -}; - -exports.conf = { - aliases: [], - guildOnly: false, -}; -exports.help = { - name: 'uptime', - description: 'Displays Uptime.', - usage: 'uptime', - category: '- General Commands', -}; diff --git a/src/music.js b/src/music.js deleted file mode 100644 index b2df43d..0000000 --- a/src/music.js +++ /dev/null @@ -1,68 +0,0 @@ -// Created by jtsshieh#6434 in the BonGon project: https://github.com/jtsshieh/BonGon - -const YTDL = require('ytdl-core'); -module.exports.playYT = async (bot, connection, msg) => { - const EventEmitter = require('events'); - class MyEmitter extends EventEmitter {} - bot.musicEmit = new MyEmitter(); - - const musicvariables = require('./music.js').MusicVariables; - const server = musicvariables(bot, msg.member.guild.id); - - server.dispatcher = connection; - - connection.playStream(YTDL(server.queue[0].url, { - filter: 'audioonly' - })); - - server.nowPlaying = server.queue[0]; - server.beforeNowPlaying = server.nowPlaying; - - - server.queue.shift(); - - server.nowPlaying.playing = true; - - let time = 0; - let counter = setInterval( - function() { - time = time + 1; - server.dispatcher.time = time; - }, 1000); - - bot.musicEmit.on('paused', () => { - clearInterval(counter); - }); - - bot.musicEmit.on('resumed',() =>{ - counter = setInterval( - function() { - time = time + 1; - server.dispatcher.time = time; - }, 1000); - }); - - connection.once('end', function() { - clearInterval(counter); - - if (server.queue[0] || server.beforeNowPlaying) { - if (server.repeat) { - server.queue.push(server.beforeNowPlaying); - } - - server.nowPlaying = null; - bot.playYT(connection, msg); - } - - else { - bot.leaveVoiceChannel(connection.channelID); - bot.servers[msg.member.guild.id] = null; - } - }); -}; -module.exports.MusicVariables = (bot, guildID) => { - if (!bot.servers[guildID]) { - bot.servers[guildID] = {'queue' : [], 'dispatcher': null, 'repeat': false}; - } - return bot.servers[guildID]; -}; -- cgit v1.2.3