From cc3bcfa137fcab337e509b380784fbe7ed6bb240 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Fri, 3 Jan 2020 14:44:02 -0500 Subject: added eslint --- storage/settings.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'storage') diff --git a/storage/settings.json b/storage/settings.json index 05117e9..83932cc 100644 --- a/storage/settings.json +++ b/storage/settings.json @@ -1,4 +1,4 @@ { - "abVersion": "2.12.0", - "prefix": "ab:" + "abVersion": "2.13.0 Beta", + "prefix": "abb:" } -- cgit v1.2.3 From ed456ef581c5acd852a924d9cc274a259b2d8ce5 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Thu, 23 Jul 2020 11:41:02 -0400 Subject: Converted to Discord.JS v12, starting database --- To be worked on/leave.js | 22 +- To be worked on/play.js | 136 +++++----- To be worked on/queue.js | 30 +-- To be worked on/skip.js | 40 +-- bot_discord.js | 635 +++++++++++++++++++++++---------------------- commands/addquote.js | 16 +- commands/ask.js | 44 ++-- commands/avatarurl.js | 16 +- commands/balance.js | 50 ---- commands/ban.js | 38 +-- commands/eval.js | 104 ++++---- commands/git.js | 34 +-- commands/help.js | 74 +++--- commands/info.js | 32 +-- commands/interrogate.js | 26 +- commands/invite.js | 44 ++-- commands/jail.js | 26 +- commands/kick.js | 38 +-- commands/leaveguild.js | 18 +- commands/pay.js | 60 ----- commands/ping.js | 14 +- commands/poweroff.js | 38 +-- commands/purge.js | 22 +- commands/quote.js | 60 ++--- commands/reload.js | 55 ++++ commands/say.js | 20 +- commands/setprefix.js | 44 ++-- commands/setup.js | 45 ++++ commands/suggest.js | 38 +-- commands/suggestfeature.js | 40 +-- commands/uptime.js | 34 +-- commands/userinfo.js | 32 +-- commands/vtquote.js | 64 ----- deprecated/balance.js | 50 ++++ deprecated/buy.js | 17 +- deprecated/daily.js | 42 +-- deprecated/pay.js | 60 +++++ package.json | 11 +- storage/items.json | 20 -- 39 files changed, 1104 insertions(+), 1085 deletions(-) delete mode 100644 commands/balance.js delete mode 100644 commands/pay.js create mode 100644 commands/reload.js create mode 100644 commands/setup.js delete mode 100644 commands/vtquote.js create mode 100644 deprecated/balance.js create mode 100644 deprecated/pay.js delete mode 100644 storage/items.json (limited to 'storage') diff --git a/To be worked on/leave.js b/To be worked on/leave.js index 63915c8..da0b4cc 100644 --- a/To be worked on/leave.js +++ b/To be worked on/leave.js @@ -19,24 +19,24 @@ * *************************************/ module.exports.run = async (client, message, args) => { - if (!message.member.voiceChannel) return message.reply('You need a voice channel to perform this action.'); + if (!message.member.voiceChannel) return message.reply('You need a voice channel to perform this action.'); - if (!message.guild.me.voiceChannel) return message.reply('Error: The bot isn\'t connected to a voice channel.'); + if (!message.guild.me.voiceChannel) return message.reply('Error: The bot isn\'t connected to a voice channel.'); - if (message.guild.me.voiceChannelID !== message.member.voiceChannelID) return message.reply('Error: You aren\'t connected in the same voice channel as the bot...'); + if (message.guild.me.voiceChannelID !== message.member.voiceChannelID) return message.reply('Error: You aren\'t connected in the same voice channel as the bot...'); - message.guild.me.voiceChannel.leave(); + message.guild.me.voiceChannel.leave(); - message.channel.send('Leaving channel...'); + message.channel.send('Leaving channel...'); }; exports.conf = { - aliases: [], - guildOnly: false, + aliases: [], + guildOnly: false, }; exports.help = { - name: 'leave', - description: 'Leaves voice chat.', - usage: 'leave', - category: '- Music Commands', + name: 'leave', + description: 'Leaves voice chat.', + usage: 'leave', + category: '- Music Commands', }; diff --git a/To be worked on/play.js b/To be worked on/play.js index 71112e1..abebc8b 100644 --- a/To be worked on/play.js +++ b/To be worked on/play.js @@ -19,97 +19,97 @@ * *************************************/ module.exports.run = async (client, message, args, ops) => { - const ytdl = require('ytdl-core'); + const ytdl = require('ytdl-core'); - if (!message.member.voiceChannel) return message.reply('Please connect to a voice channel...'); + if (!message.member.voiceChannel) return message.reply('Please connect to a voice channel...'); - if (!args[0]) return message.reply('Please input a url.'); + if (!args[0]) return message.reply('Please input a url.'); - const vaildate = await ytdl.validateURL(args[0]); + const vaildate = await ytdl.validateURL(args[0]); - if (!vaildate) return message.reply('Please input a **valid** url.'); + if (!vaildate) return message.reply('Please input a **valid** url.'); - const info = await ytdl.getInfo(args[0]); + const info = await ytdl.getInfo(args[0]); - const data = ops.active.get(message.guild.id) || {}; + const data = ops.active.get(message.guild.id) || {}; - if (!data.connection) data.connection = await message.member.voiceChannel.join(); - if (!data.queue) data.queue = []; - data.guildID = message.guild.id; + if (!data.connection) data.connection = await message.member.voiceChannel.join(); + if (!data.queue) data.queue = []; + data.guildID = message.guild.id; - data.queue.push({ - songTitle: info.title, - requester: message.author.tag, - url: args[0], - announceChannel: message.channel.id, - }); - if (!data.dispatcher) play(client, ops, data); - else { - const {RichEmbed} = require('discord.js'); - const embed = new RichEmbed() - .setTitle('This music has been added to the queue!') - .setAuthor(info.title, client.user.avatarURL) - .setColor(0x00afff) - .setTimestamp() - .addField('Title', info.title) - .addField('Requested by:', message.author.tag) - .setFooter('AleeBot Music Player'); + data.queue.push({ + songTitle: info.title, + requester: message.author.tag, + url: args[0], + announceChannel: message.channel.id, + }); + if (!data.dispatcher) play(client, ops, data); + else { + const {MessageEmbed} = require('discord.js'); + const embed = new MessageEmbed() + .setTitle('This music has been added to the queue!') + .setAuthor(info.title, client.user.avatarURL()) + .setColor(0x00afff) + .setTimestamp() + .addField('Title', info.title) + .addField('Requested by:', message.author.tag) + .setFooter('AleeBot Music Player'); - message.channel.send({embed}); - } + message.channel.send({embed}); + } - ops.active.set(message.guild.id, data); + ops.active.set(message.guild.id, data); }; async function play(client, ops, data) { - const ytdl = require('ytdl-core'); - const {RichEmbed} = require('discord.js'); - const embed = new RichEmbed() - .setTitle('Now playing!') - .setAuthor(data.queue[0].songTitle, client.user.avatarURL) - .setColor(0x00afff) - .setTimestamp() - .addField('Title', data.queue[0].songTitle) - .addField('Requested by:', data.queue[0].requester) - // .addField('Link', info.url) - // .addField('Duration', time) - .setFooter('AleeBot Music Player'); - - client.channels.get(data.queue[0].announceChannel).send({embed}); - - data.dispatcher = await data.connection.playStream(ytdl(data.queue[0].url, {filter: 'audioonly'})); - data.dispatcher.guildID = data.guildID; - - data.dispatcher.once('finish', function() { - finish(client, ops, this); - }); -}; + const ytdl = require('ytdl-core'); + const {MessageEmbed} = require('discord.js'); + const embed = new MessageEmbed() + .setTitle('Now playing!') + .setAuthor(data.queue[0].songTitle, client.user.avatarURL()) + .setColor(0x00afff) + .setTimestamp() + .addField('Title', data.queue[0].songTitle) + .addField('Requested by:', data.queue[0].requester) + // .addField('Link', info.url) + // .addField('Duration', time) + .setFooter('AleeBot Music Player'); + + client.channels.get(data.queue[0].announceChannel).send({embed}); + + data.dispatcher = await data.connection.playStream(ytdl(data.queue[0].url, {filter: 'audioonly'})); + data.dispatcher.guildID = data.guildID; + + data.dispatcher.once('finish', function() { + finish(client, ops, this); + }); +} function finish(client, ops, dispatcher) { - const fetched = ops.active.get(dispatcher.guildID); + const fetched = ops.active.get(dispatcher.guildID); - fetched.queue.shift(); + fetched.queue.shift(); - if (fetched.queue.length > 0) { - ops.active.set(dispatcher.guildID, fetched); + if (fetched.queue.length > 0) { + ops.active.set(dispatcher.guildID, fetched); - play(client, ops, fetched); - } else { - ops.active.delete(dispatcher.guildID); + play(client, ops, fetched); + } else { + ops.active.delete(dispatcher.guildID); - const vc = client.guild.get(dispatcher.guildID).me.voiceChannel; + const vc = client.guild.get(dispatcher.guildID).me.voiceChannel; - if (vc) vc.leave(); - } + if (vc) vc.leave(); + } } exports.conf = { - aliases: [], - guildOnly: false, + aliases: [], + guildOnly: false, }; exports.help = { - name: 'play', - description: 'Plays music.', - usage: 'play [url]', - category: '- Music Commands', + name: 'play', + description: 'Plays music.', + usage: 'play [url]', + category: '- Music Commands', }; diff --git a/To be worked on/queue.js b/To be worked on/queue.js index f5f0ae9..1208ddf 100644 --- a/To be worked on/queue.js +++ b/To be worked on/queue.js @@ -19,29 +19,29 @@ * *************************************/ module.exports.run = async (client, message, args, ops) => { - const fetched = ops.active.get(message.guild.id); + const fetched = ops.active.get(message.guild.id); - if (!fetched) return message.reply('Currently, there isn\'t any music playing in this guild.'); + if (!fetched) return message.reply('Currently, there isn\'t any music playing in this guild.'); - const queue = fetched.queue; - const nowPlaying = queue[0]; + const queue = fetched.queue; + const nowPlaying = queue[0]; - let resp = `__**Now Playing**__\n**${nowPlaying.songTitle}** -- **Requested By:** *${nowPlaying.requester}*\n\n__**Queue**__\n`; + let resp = `__**Now Playing**__\n**${nowPlaying.songTitle}** -- **Requested By:** *${nowPlaying.requester}*\n\n__**Queue**__\n`; - for (let i = 1; i < queue.length; i++) { - resp += `${i}. **${queue[i].songTitle}** -- **Requested By:** *${queue[i].requester}*\n`; - } + for (let i = 1; i < queue.length; i++) { + resp += `${i}. **${queue[i].songTitle}** -- **Requested By:** *${queue[i].requester}*\n`; + } - message.channel.send(resp); + message.channel.send(resp); }; exports.conf = { - aliases: [], - guildOnly: false, + aliases: [], + guildOnly: false, }; exports.help = { - name: 'queue', - description: 'Checks what music is in queue.', - usage: 'queue', - category: '- Music Commands', + name: 'queue', + description: 'Checks what music is in queue.', + usage: 'queue', + category: '- Music Commands', }; diff --git a/To be worked on/skip.js b/To be worked on/skip.js index 965b013..371e7e7 100644 --- a/To be worked on/skip.js +++ b/To be worked on/skip.js @@ -19,40 +19,40 @@ * *************************************/ module.exports.run = async (client, message, args, ops) => { - const fetched = ops.active.get(message.guild.id); + const fetched = ops.active.get(message.guild.id); - if (!fetched) return message.reply('Currently, there isn\'t any music playing in this guild.'); + if (!fetched) return message.reply('Currently, there isn\'t any music playing in this guild.'); - if (message.member.voiceChannel !== message.guild.me.voiceChannel) return message.reply('Sorry, you are currently not in the same channel as the bot.'); + if (message.member.voiceChannel !== message.guild.me.voiceChannel) return message.reply('Sorry, you are currently not in the same channel as the bot.'); - const userCount = message.member.voiceChannel.members.size; + const userCount = message.member.voiceChannel.members.size; - const required = Math.ceil(userCount/2); + const required = Math.ceil(userCount/2); - if (!fetched.queue[0].voteSkips) fetched.queue[0].voteSkips = []; + if (!fetched.queue[0].voteSkips) fetched.queue[0].voteSkips = []; - if (fetched.queue[0].voteSkips.includes(message.member.id)) return message.reply(`Sorry, you have already voted to skip! ${fetched.queue[0].voteSkips.length}/${required} required.`); + if (fetched.queue[0].voteSkips.includes(message.member.id)) return message.reply(`Sorry, you have already voted to skip! ${fetched.queue[0].voteSkips.length}/${required} required.`); - fetched.queue[0].voteSkips.push(message.member.id); + fetched.queue[0].voteSkips.push(message.member.id); - ops.active.set(message.guild.id, fetched); + ops.active.set(message.guild.id, fetched); - if (fetched.queue[0].voteSkips.length >= required) { - message.channel.send('Successfully skipped song!'); + if (fetched.queue[0].voteSkips.length >= required) { + message.channel.send('Successfully skipped song!'); - return fetched.dispatcher.emit('finish'); - } + return fetched.dispatcher.emit('finish'); + } - message.channel.send(`Successfully voted to skip! ${fetched.queue[0].voteSkips.length}/${required} required.`); + message.channel.send(`Successfully voted to skip! ${fetched.queue[0].voteSkips.length}/${required} required.`); }; exports.conf = { - aliases: [], - guildOnly: false, + aliases: [], + guildOnly: false, }; exports.help = { - name: 'skip', - description: 'Skips a music.', - usage: 'skip', - category: '- Music Commands', + name: 'skip', + description: 'Skips a music.', + usage: 'skip', + category: '- Music Commands', }; diff --git a/bot_discord.js b/bot_discord.js index 5c437c9..dfaf6fc 100644 --- a/bot_discord.js +++ b/bot_discord.js @@ -19,12 +19,13 @@ * *************************************/ const Discord = require('discord.js'); const moment = require('moment'); +const Sequelize = require('sequelize'); const readline = require('readline'); const colors = require('colors'); const DBL = require('dblapi.js'); const i18next = require('i18next'); const client = new Discord.Client({ - disableEveryone: true, + disableEveryone: true, }); const settings = require('./storage/settings.json'); const fs = require('fs'); @@ -32,15 +33,18 @@ const api = require('./tokens.json'); const dbl = new DBL(api.dbltoken, client); const active = new Map(); const ownerID = '242775871059001344'; +var autoRole = true; +var logChannel = '318874545593384970'; +let statusChannelID = '606602551634296968'; const log = (message) => { - console.log(`[${moment().format('YYYY-MM-DD HH:mm:ss')}] ${message}`.white); + console.log(`[${moment().format('YYYY-MM-DD HH:mm:ss')}] ${message}`.white); }; const rl = readline.createInterface({ - input: process.stdin, - output: process.stdout, - prompt: '> '.gray, + input: process.stdin, + output: process.stdout, + prompt: '> '.gray, }); console.log(`AleeBot ${settings.abVersion}: Copyright (C) 2017-2020 Alee Productions`.gray); @@ -49,376 +53,373 @@ console.log('This is free software, and you are welcome to redistribute it'.gray console.log('under certain conditions; type `show c\' for details.\n'.gray); if (process.argv.indexOf('--debug') == -1) { - console.log('Running AleeBot without --debug command line flag. Debug output disabled.\n'.yellow); + console.log('Running AleeBot without --debug command line flag. Debug output disabled.\n'.yellow); } else { - console.log('[!] Entering debug mode...'.yellow); - client.on('debug', function(info) { - log(info.gray); - }); - client.on('warn', function(info) { - log(info.red); - }); + console.log('[!] Entering debug mode...'.yellow); + client.on('debug', function(info) { + log(info.gray); + }); + client.on('warn', function(info) { + log(info.red); + }); } if (process.argv.indexOf('--beta') == -1) { - client.login(api.abtoken).catch(function() { - console.log('[X] Login failed. The token that you put in is invalid, please put in a new one...'.red); - process.exit(0); - }); + client.login(api.abtoken).catch(function() { + console.log('[X] Login failed. The token that you put in is invalid, please put in a new one...'.red); + process.exit(0); + }); } else { - client.login(api.abbtoken).catch(function() { - console.log('[X] Login failed. The token that you put in is invalid, please put in a new one...'.red); - process.exit(0); - }); + client.login(api.abbtoken).catch(function() { + console.log('[X] Login failed. The token that you put in is invalid, please put in a new one...'.red); + process.exit(0); + }); } client.commands = new Discord.Collection(); client.aliases = new Discord.Collection(); fs.readdir('./commands', (err, files) => { - if (err) console.error(err); - log(`[!] Attempting to load a total of ${files.length} commands into the memory.`.cyan); - files.forEach((file) => { - try { - const command = require(`./commands/${file}`); - log(`[!] Attempting to load the command "${command.help.name}".`.cyan); - client.commands.set(command.help.name, command); - command.conf.aliases.forEach((alias) => { - client.aliases.set(alias, command.help.name); - log(`[!] Attempting to load "${alias}" as an alias for "${command.help.name}"`.cyan); - }); - } catch (err) { - log('[X] An error has occured trying to load a command. Here is the error.'.red); - console.log(err.stack); - } - }); - log('[>] Command Loading complete!'.green); - console.log('\n'); + if (err) console.error(err); + log(`[!] Attempting to load a total of ${files.length} commands into the memory.`.cyan); + files.forEach((file) => { + try { + const command = require(`./commands/${file}`); + log(`[!] Attempting to load the command "${command.help.name}".`.cyan); + client.commands.set(command.help.name, command); + command.conf.aliases.forEach((alias) => { + client.aliases.set(alias, command.help.name); + log(`[!] Attempting to load "${alias}" as an alias for "${command.help.name}"`.cyan); + }); + } catch (err) { + log('[X] An error has occured trying to load a command. Here is the error.'.red); + console.log(err.stack); + } + }); + log('[>] Command Loading complete!'.green); + console.log('\n'); }); rl.on('line', function(cmd) { - const args = cmd.split(' '); - switch (args[0]) { - case 'guilds': - if (client.guilds.size === 0) { - console.log(('[!] No guilds found.'.yellow)); - } else { - console.log('[i] Here\'s the servers that AleeBot is connected to:'); - for ([id, guild] of client.guilds) { - console.log(` Guild Name: ${guild.name} - ID: ${guild.id}`.blue); - } - } - break; - case 'channels': - if (!args[1]) { - console.log('[!] Please insert the guild\'s ID.'.yellow); - } else { - var guild = client.guilds.get(args[1]); - console.log('[i] Here\'s the channels that this guild have:'.blue); - for ([id, channel, guild] of guild && client.channels) { - console.log(` Channel: #${channel.name} - ID: ${channel.id}`.blue); - } - } - break; - case 'leave': - if (!args[1]) { - console.log('[!] Please insert the guild\'s ID.'.yellow); - } else { - var guild = client.guilds.get(args[1]); - guild.leave(); - } - break; - case 'broadcast': - if (!args[1]) { - console.log('[!] Usage: broadcast [guildID] [channelID].'.yellow); - } else { - const broadcast = args.join(' ').slice(48); - var guild = null; - guild = client.guilds.get(args[1]); - var channel = null; - channel = guild.channels.get(args[2]); - if (channel != null) { - channel.send(broadcast); - } - } - break; - case 'uptime': - 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; - console.log(`[i] AleeBot has been up for ${hours} hours, ${uptimeMinutes} minutes, and ${uptimeSeconds} seconds.`.blue); - break; - case 'exit': - console.log('[i] AleeBot will now exit!'.blue); - const asyncPowerOff = async () => { - const embed = new Discord.RichEmbed() - .setAuthor('AleeBot Status', client.user.avatarURL) - .setDescription('AleeBot is now going offline...') - .setColor('#ff3333'); - await client.channels.find('id', '606602551634296968').send({embed}); - }; - asyncPowerOff(); - client.destroy(); - process.exit(0); - break; - case 'help': - let msg = (`AleeBot `+ settings.abVersion +` Console Help\n\n`); - msg += (`guilds - Shows all guilds that AleeBot's on.\n`); - msg += (`channels - Shows all the channels that the guilds have.\n`); - msg += (`leave - Leaves a guild.\n`); - msg += (`broadcast - Broadcasts a message to a server.\n`); - msg += (`uptime - Shows the uptime for AleeBot.\n`); - msg += (`help - Shows this command.\n`); - msg += (`exit - Exits AleeBot.\n`); - console.log(msg.cyan); - break; - default: - console.log('Unknown command, type \'help\' to list the commands...'.yellow); - } - rl.prompt(); + const args = cmd.split(' '); + switch (args[0]) { + case 'guilds': + if (client.guilds.size === 0) { + console.log(('[!] No guilds found.'.yellow)); + } else { + console.log('[i] Here\'s the servers that AleeBot is connected to:'); + for ([id, guild] of client.guilds) { + console.log(` Guild Name: ${guild.name} - ID: ${guild.id}`.blue); + } + } + break; + case 'channels': + if (!args[1]) { + console.log('[!] Please insert the guild\'s ID.'.yellow); + } else { + var guild = client.guilds.get(args[1]); + console.log('[i] Here\'s the channels that this guild have:'.blue); + for ([id, channel, guild] of guild && client.channels) { + console.log(` Channel: #${channel.name} - ID: ${channel.id}`.blue); + } + } + break; + case 'leave': + if (!args[1]) { + console.log('[!] Please insert the guild\'s ID.'.yellow); + } else { + var guild = client.guilds.get(args[1]); + guild.leave(); + } + break; + case 'broadcast': + if (!args[1]) { + console.log('[!] Usage: broadcast [guildID] [channelID].'.yellow); + } else { + const broadcast = args.join(' ').slice(48); + var guild = null; + guild = client.guilds.get(args[1]); + var channel = null; + channel = guild.channels.get(args[2]); + if (channel != null) { + channel.send(broadcast); + } + } + break; + case 'uptime': + 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; + console.log(`[i] AleeBot has been up for ${hours} hours, ${uptimeMinutes} minutes, and ${uptimeSeconds} seconds.`.blue); + break; + case 'exit': + console.log('[i] AleeBot will now exit!'.blue); + const asyncPowerOff = async () => { + const readyEmbed = new Discord.MessageEmbed() + .setAuthor('AleeBot Status', client.user.avatarURL()) + .setDescription('AleeBot is now going offline...') + .setColor('#ff3333'); + let statusChannel = client.channels.cache.get(statusChannelID); + if (!statusChannel) return console.error('The status channel does not exist! Skipping.'); + await statusChannel.send(readyEmbed); + }; + asyncPowerOff(); + client.destroy(); + process.exit(0); + break; + case 'help': + let msg = ('AleeBot '+ settings.abVersion +' Console Help\n\n'); + msg += ('guilds - Shows all guilds that AleeBot\'s on.\n'); + msg += ('channels - Shows all the channels that the guilds have.\n'); + msg += ('leave - Leaves a guild.\n'); + msg += ('broadcast - Broadcasts a message to a server.\n'); + msg += ('uptime - Shows the uptime for AleeBot.\n'); + msg += ('help - Shows this command.\n'); + msg += ('exit - Exits AleeBot.\n'); + console.log(msg.cyan); + break; + default: + console.log('Unknown command, type \'help\' to list the commands...'.yellow); + } + rl.prompt(); +}); + +const sequelize = new Sequelize('database', 'user', 'password', { + host: 'localhost', + dialect: 'sqlite', + logging: false, + // SQLite only + storage: 'database.sqlite', }); client.on('ready', () => { - log('[>] AleeBot is now ready!'.green); - log(`[i] Logged in as ${client.user.tag}`.green); - log(`[i] Default Prefix: ${settings.prefix}`.green); - log(`[i] Bot ID: ${client.user.id}`.green); - log(`[i] Token: ${api.abtoken}`.green); - log(`[i] Running version ${settings.abVersion} and in ${client.guilds.size} guilds`.green); - - client.setInterval(function() { - const games = [ - 'AleeBot ' + settings.abVersion + ' | ' + settings.prefix + 'help', - 'Annoying Alee', - 'Coding stuff', - 'Drawing shapes', - 'Fighting AstralMod', - ]; - /* + log('[>] AleeBot is now ready!'.green); + log(`[i] Logged in as ${client.user.tag}`.green); + log(`[i] Default Prefix: ${settings.prefix}`.green); + log(`[i] Bot ID: ${client.user.id}`.green); + log(`[i] Token: ${api.abtoken}`.green); + log(`[i] Running version ${settings.abVersion} and in ${client.guilds.cache.size} guilds`.green); + + client.setInterval(function() { + const games = [ + 'AleeBot ' + settings.abVersion + ' | ' + settings.prefix + 'help', + 'Coding stuff', + 'Drawing shapes', + 'Fighting AstralMod', + ]; + /* setInterval(() => { dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total); }, 1800000);*/ - client.user.setPresence({ - status: 'online', - afk: false, - game: { - type: 0, - name: games[Math.floor(Math.random() * games.length)], - }, - }); - }, 200000); - client.user.setStatus('online'); - const embed = new Discord.RichEmbed() - .setAuthor('AleeBot Status', client.user.avatarURL) - .setDescription('AleeBot has started') - .setColor('#5cd65c'); - client.channels.find('id', '606602551634296968').send({embed}); - rl.prompt(); + client.user.setPresence({ + status: 'online', + afk: false, + game: { + type: 0, + name: games[Math.floor(Math.random() * games.length)], + }, + }); + }, 200000); + client.user.setStatus('online'); + const readyEmbed = new Discord.MessageEmbed() + .setAuthor('AleeBot Status', client.user.avatarURL()) + .setDescription('AleeBot has started') + .addField('Prefix', `\`${settings.prefix}\``, true) + .setColor('#5cd65c'); + let statusChannel = client.channels.cache.get(statusChannelID); + if (!statusChannel) return console.error('The status channel does not exist! Skipping.'); + statusChannel.send(readyEmbed); + client.user.setStatus('online'); + rl.prompt(); }); client.on('guildMemberAdd', (member) => { - if (member.guild.id != '243022206437687296') return 0; - const role = member.guild.roles.find((role) => role.name === 'Member'); - member.addRole(role); - log(`[i] ${member.user.username} joined Alee Productions.`.green); - log(`[i] I gave ${member.user.username} the "Member" role.`.green); + if (autoRole = true) { + if (member.guild.id != '243022206437687296') return 0; + const role = member.guild.roles.cache.get('657426918416580614'); + member.roles.add(role); + log(`[i] ${member.user.username} joined Alee Productions.`.green); + log(`[i] I gave ${member.user.username} the "Member" role.`.green); + } else { + return; + } }); +/* +client.on('guildMemberRemove', (member) =>{ + +}) +*/ client.on('messageUpdate', async (oldMessage, newMessage) => { - if (oldMessage.guild.id != '243022206437687296') return 0; - if (oldMessage.content === newMessage.content) { - return; - } - const logEmbed = new Discord.RichEmbed() - .setAuthor('AleeBot Logging', client.user.avatarURL) - .setDescription(`A message from ${oldMessage.author.username} was edited`) - .addField('Before: ', `\`\`\`${oldMessage.content}\`\`\``) - .addField('After: ', `\`\`\`${newMessage.content}\`\`\``) - .setColor('#ffff1a') - .setTimestamp() - .setFooter(`Author ID: ${oldMessage.author.id}`); - - const editMessage = newMessage.guild.channels.find((ch) => ch.name === 'logs'); - if (!editMessage) return; - - editMessage.send(logEmbed); + if (oldMessage.guild.id != '243022206437687296') return 0; + if (oldMessage.content === newMessage.content) { + return; + } + const logEmbed = new Discord.MessageEmbed() + .setAuthor('AleeBot Logging', client.user.avatarURL()) + .setDescription(`A message from ${oldMessage.author.username} was edited`) + .addField('Before: ', `\`\`\`${oldMessage.content}\`\`\``) + .addField('After: ', `\`\`\`${newMessage.content}\`\`\``) + .setColor('#ffff1a') + .setTimestamp() + .setFooter(`Author ID: ${oldMessage.author.id}`); + + let editMessage = client.channels.cache.get(logChannel); + if (!editMessage) return; + + editMessage.send(logEmbed); }); client.on('messageDelete', (message) => { - if (message.guild.id != '243022206437687296') return 0; - const logEmbed = new Discord.RichEmbed() - .setAuthor('AleeBot Logging', client.user.avatarURL) - .setDescription(`A message from ${message.author.username} was deleted`) - .addField('Deleted Message: ', `\`\`\`${message.content}\`\`\``) - .setColor('#ff021b') - .setTimestamp() - .setFooter(`Author ID: ${message.author.id}`); - - const deleteMessage = message.guild.channels.find((ch) => ch.name === 'logs'); - if (!deleteMessage) return; - - deleteMessage.send(logEmbed); + if (message.guild.id != '243022206437687296') return 0; + const logEmbed = new Discord.MessageEmbed() + .setAuthor('AleeBot Logging', client.user.avatarURL()) + .setDescription(`A message from ${message.author.username} was deleted`) + .addField('Deleted Message: ', `\`\`\`${message.content}\`\`\``) + .setColor('#ff021b') + .setTimestamp() + .setFooter(`Author ID: ${message.author.id}`); + + let deleteMessage = client.channels.cache.get(logChannel); + if (!deleteMessage) return; + + deleteMessage.send(logEmbed); }); client.on('guildBanAdd', (guild, user) => { - if (guild.id != '243022206437687296') return 0; - const logEmbed = new Discord.RichEmbed() - .setAuthor('AleeBot Logging', client.user.avatarURL) - .setDescription(`This user got banned from ${guild.name}`) - .addField(`User:`, `${user.tag}`) - .addField(`User ID:`, `${user.id}`) - .setColor('#ff021b') - .setTimestamp(); - - const banMessage = guild.channels.find((ch) => ch.name === 'logs'); - if (!banMessage) return; - - banMessage.send(logEmbed); + if (guild.id != '243022206437687296') return 0; + const logEmbed = new Discord.MessageEmbed() + .setAuthor('AleeBot Logging', client.user.avatarURL()) + .setDescription(`This user got banned from ${guild.name}`) + .addField('User:', `${user.tag}`) + .addField('User ID:', `${user.id}`) + .setColor('#ff021b') + .setTimestamp(); + + let banMessage = client.channels.cache.get(logChannel); + if (!banMessage) return; + + banMessage.send(logEmbed); }); client.on('guildBanRemove', (guild, user) => { - if (guild.id != '243022206437687296') return 0; - const logEmbed = new Discord.RichEmbed() - .setAuthor('AleeBot Logging', client.user.avatarURL) - .setDescription(`This user got unbanned from ${guild.name}`) - .addField(`User:`, `${user.tag}`) - .addField(`User ID:`, `${user.id}`) - .setColor('#ff021b') - .setTimestamp(); - - const banMessage = guild.channels.find((ch) => ch.name === 'logs'); - if (!banMessage) return; - - banMessage.send(logEmbed); + if (guild.id != '243022206437687296') return 0; + const logEmbed = new Discord.MessageEmbed() + .setAuthor('AleeBot Logging', client.user.avatarURL()) + .setDescription(`This user got unbanned from ${guild.name}`) + .addField('User:', `${user.tag}`) + .addField('User ID:', `${user.id}`) + .setColor('#ff021b') + .setTimestamp(); + + let banMessage = client.channels.cache.get(logChannel); + if (!banMessage) return; + + banMessage.send(logEmbed); }); client.on('guildCreate', (guild) => { - log(`[i] New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`.blue); - /* - const logEmbed = new Discord.RichEmbed() - .setAuthor("AleeBot", client.user.avatarURL) - .setDescription(`I got added to this server!`) - .addField(`Server Name:`, `${guild.name}`) - .addField(`Server ID:`, `${guild.id}`) - .setColor("#5cd65c") - - client.channels.find('id', '606602551634296968').send({logEmbed});*/ + log(`[i] New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`.blue); + const logEmbed = new Discord.MessageEmbed() + .setAuthor('AleeBot', client.user.avatarURL()) + .setDescription('I got added to a server!') + .addField('Server Name:', `${guild.name}`, true) + .addField('Server ID:', `${guild.id}`, true) + .addField('Members', guild.memberCount, true) + .setColor('#5cd65c') + .setFooter(`We now run on ${client.guilds.cache.size} guilds.`); + + let statusChannel = client.channels.cache.get(statusChannelID); + if (!statusChannel) return; + statusChannel.send(logEmbed); }); client.on('guildDelete', (guild) => { - log(`[i] I have been removed from: ${guild.name} (id: ${guild.id})`.red); - /* - const logEmbed = new Discord.RichEmbed() - .setAuthor("AleeBot", client.user.avatarURL) - .setDescription(`I got removed from server...`) - .addField(`Server Name:`, `${guild.name}`) - .addField(`Server ID:`, `${guild.id}`) - .setColor("#5cd65c") - - client.channels.find('id', '606602551634296968').send({logEmbed});*/ + log(`[i] I have been removed from: ${guild.name} (id: ${guild.id})`.red); + const logEmbed = new Discord.MessageEmbed() + .setAuthor('AleeBot', client.user.avatarURL()) + .setDescription('I got removed from a server...') + .addField('Server Name:', `${guild.name}`, true) + .addField('Server ID:', `${guild.id}`, true) + .setColor('#ff021b') + .setFooter(`We now run on ${client.guilds.cache.size} guilds.`); + + let statusChannel = client.channels.cache.get(statusChannelID); + if (!statusChannel) return; + statusChannel.send(logEmbed); }); dbl.on('posted', () => { - log('Server count posted!'.blue); + log('Server count posted!'.blue); }); dbl.on('error', (e) => { - log(`[X | DBL ERROR] ${e}`.red); + log(`[X | DBL ERROR] ${e}`.red); }); client.on('message', (msg) => { - if (msg.author.bot) return; - - if (msg.mentions != null && msg.mentions.users != null) { - if (msg.mentions.users.has('282547024547545109')) { - if (msg.content.toLowerCase().includes('hello') || (msg.content.toLowerCase().includes('hi'))) { - msg.reply(`Hello ${msg.author.username}!`); - } else { - if (msg.content.toLowerCase().includes('shut') && msg.content.toLowerCase().includes('up')) { - switch (Math.floor(Math.random() * 1000) % 3) { - case 0: - msg.reply('Hey, Can you not speak to me in that tone...'); - break; - case 1: - msg.reply('NO! I can talk as much I can!'); - break; - case 2: - msg.reply('Nah I won\'t....'); - break; - } - } else if (msg.content.toLowerCase().includes('how') && msg.content.toLowerCase().includes('are') && msg.content.toLowerCase().includes('you')) { - msg.reply('I\'m doing OK, I suppose...'); - } else if (msg.content.toLowerCase().includes('ok') && msg.content.toLowerCase().includes('google')) { - msg.reply('Erm... I am not google, if you want to use Google here\'s the link: https://www.google.com'); - } else if (msg.content.toLowerCase().includes('f') && msg.content.toLowerCase().includes('off')) { - msg.reply('Do you want a hammer? :hammer:'); - } else if (msg.content.toLowerCase().includes('aleearmy')) { - msg.reply('Oh yeah.. that thing Alee made...'); - } - } - } - }; - - - const prefixes = JSON.parse(fs.readFileSync('./storage/prefixes.json', 'utf8')); - - if (!prefixes[msg.guild.id]) { - prefixes[msg.guild.id] = { - prefixes: settings.prefix, - }; - } - - const prefix = prefixes[msg.guild.id].prefixes; - - - 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 { - const ops = { - ownerID: ownerID, - active: active, - }; - - cmd.run(client, msg, args, ops); - } catch (e) { - console.error(e); - } - } + if (msg.author.bot) return; + + const prefixes = JSON.parse(fs.readFileSync('./storage/prefixes.json', 'utf8')); + + if (!prefixes[msg.guild.id]) { + prefixes[msg.guild.id] = { + prefixes: settings.prefix, + }; + } + + const prefix = prefixes[msg.guild.id].prefixes; + + + 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 { + const ops = { + ownerID: ownerID, + active: active, + autoRole: autoRole, + }; + + cmd.run(client, msg, args, ops); + } catch (e) { + console.error(e); + } + } }); process.on('unhandledRejection', function(err, p) { - log('[X | UNCAUGHT PROMISE] ' + err.stack.red); + log('[X | UNCAUGHT PROMISE] ' + err.stack.red); }); client.on('reconnecting', function() { - log('[!] AleeBot has disconnected from Discord and is now attempting to reconnect.'.yellow); + log('[!] AleeBot has disconnected from Discord and is now attempting to reconnect.'.yellow); }); client.on('disconnect', function() { - log('[X] AleeBot has disconnected from Discord and will not attempt to reconnect.'.red); - console.log('At this point, you\'ll need to restart AleeBot.'.red); - process.exit(0); + log('[X] AleeBot has disconnected from Discord and will not attempt to reconnect.'.red); + console.log('At this point, you\'ll need to restart AleeBot.'.red); + process.exit(0); }); diff --git a/commands/addquote.js b/commands/addquote.js index 7782b91..7b7221e 100644 --- a/commands/addquote.js +++ b/commands/addquote.js @@ -18,7 +18,7 @@ * * *************************************/ module.exports.run = async (client, message, args) => { - /* + /* const moment = require('moment'); const log = message => { @@ -44,17 +44,17 @@ module.exports.run = async (client, message, args) => { message.reply(`You just added a new quote!`); log(`[i] A quote has been added to quotes.json...`) */ - message.reply('Command is broken for now'); + message.reply('Command is broken for now'); }; exports.conf = { - aliases: [], - guildOnly: true, + aliases: [], + guildOnly: true, }; exports.help = { - name: 'addquote', - description: 'Sets the guild prefix.', - usage: 'addquote [author] [authorImage] [quote] [year]', - category: '- Quote Commands', + name: 'addquote', + description: 'Sets the guild prefix.', + usage: 'addquote [author] [authorImage] [quote] [year]', + category: '- Quote Commands', }; diff --git a/commands/ask.js b/commands/ask.js index 0bc0761..3b1efd5 100644 --- a/commands/ask.js +++ b/commands/ask.js @@ -18,31 +18,31 @@ * * *************************************/ module.exports.run = async (client, message, args) => { - const 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.'); - } + const 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.send(abaskanswer[Math.floor(Math.random() * abaskanswer.length)]); + } else { + message.channel.send('Sorry, I don\'t know what your saying.'); + } }; exports.conf = { - aliases: ['8ball'], - guildOnly: false, + aliases: ['8ball'], + guildOnly: false, }; exports.help = { - name: 'ask', - description: 'Give AleeBot a question!', - usage: 'ask [args]', - category: '- Fun Commands', + name: 'ask', + description: 'Give AleeBot a question!', + usage: 'ask [args]', + category: '- Fun Commands', }; diff --git a/commands/avatarurl.js b/commands/avatarurl.js index 7f9c256..293a1a4 100644 --- a/commands/avatarurl.js +++ b/commands/avatarurl.js @@ -1,6 +1,6 @@ /** ************************************** * - * AvatarURL: Command for AleeBot + * avatarurl: Command for AleeBot * Copyright (C) 2017-2020 Alee Productions * * This program is free software: you can redistribute it and/or modify @@ -18,16 +18,16 @@ * * *************************************/ module.exports.run = async (client, message) => { - message.reply(message.author.avatarURL); + message.reply(message.author.avatarURL()); }; exports.conf = { - aliases: [], - guildOnly: false, + aliases: [], + guildOnly: false, }; exports.help = { - name: 'avatarurl', - description: 'Sends you your avatar picture.', - usage: 'avatarurl', - category: '- Fun Commands', + name: 'avatarurl', + description: 'Sends you your avatar picture.', + usage: 'avatarurl', + category: '- Fun Commands', }; diff --git a/commands/balance.js b/commands/balance.js deleted file mode 100644 index 7b340b2..0000000 --- a/commands/balance.js +++ /dev/null @@ -1,50 +0,0 @@ -/** ************************************** - * - * Balance: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * *************************************/ -module.exports.run = async (client, message) => { - const db = require('quick.db'); - const {RichEmbed} = require('discord.js'); - - const user = message.mentions.users.first() || message.author; - - let balance = await db.fetch(`userBalance_${user.id}`); - - if (balance === null) { - db.set(`userBalance_${message.author.id}`, 0); - balance = 0; - } - const embed = new RichEmbed() - .setDescription(`**AleeCorp Bank**`) - .addField('Account Holder: ', user.username, true) - .addField('Account Balance: ', balance, true) - .setColor('#1fd619'); - - message.channel.send({embed}); -}; - -exports.conf = { - aliases: ['bal', 'money'], - guildOnly: false, -}; -exports.help = { - name: 'balance', - description: 'Checks the balance of AleeBot', - usage: 'balance [@someone (optional)]', - category: '- Economy Commands', -}; diff --git a/commands/ban.js b/commands/ban.js index 354dcaa..0f2f011 100644 --- a/commands/ban.js +++ b/commands/ban.js @@ -18,28 +18,28 @@ * * *************************************/ module.exports.run = async (client, message, args) => { - const Discord = require('discord.js'); - const 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.'); - if (!message.guild.member(client.user).hasPermission('BAN_MEMBERS')) return message.reply('Uhh... I don\'t have permission to ban members.'); - const member = message.mentions.members.first(); - if (!member) return message.reply('Uhh... Please mention a member first.'); - member.ban(`Banned by ${message.author.tag} Reason: ` + mreason); - const embed = new Discord.RichEmbed() - .setTitle('User Banned!') - .setColor('#1fd619') - .addField('**User:**', `${member.user.tag}`) - .addField('**Reason:**', `\`\`\`${mreason}\`\`\``); - await message.channel.send({embed}); + const Discord = require('discord.js'); + const 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.'); + if (!message.guild.member(client.user).hasPermission('BAN_MEMBERS')) return message.reply('Uhh... I don\'t have permission to ban members.'); + const member = message.mentions.members.first(); + if (!member) return message.reply('Uhh... Please mention a member first.'); + member.ban(`Banned by ${message.author.tag} Reason: ` + mreason); + const embed = new Discord.MessageEmbed() + .setTitle('User Banned!') + .setColor('#1fd619') + .addField('**User:**', `${member.user.tag}`) + .addField('**Reason:**', `\`\`\`${mreason}\`\`\``); + await message.channel.send({embed}); }; exports.conf = { - aliases: [], - guildOnly: false, + aliases: [], + guildOnly: false, }; exports.help = { - name: 'ban', - description: 'Bans a member', - usage: 'ban [user] [reason]', - category: '- Moderation Commands', + name: 'ban', + description: 'Bans a member', + usage: 'ban [user] [reason]', + category: '- Moderation Commands', }; diff --git a/commands/eval.js b/commands/eval.js index 2147376..ef8fc97 100644 --- a/commands/eval.js +++ b/commands/eval.js @@ -18,67 +18,67 @@ * * *************************************/ 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(' '); + if (!['242775871059001344'].includes(message.author.id)) return message.reply('Nope! You need the person who created this bot to use this command.'); + const {MessageEmbed} = require('discord.js'); + const code = args.join(' '); - let evaled; - let remove; + 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; - } - }; + 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); + 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}); - } + if (typeof evaled !== 'string') { + evaled = require('util').inspect(evaled); + } + } catch (err) { + const embed = new MessageEmbed() + .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'); + try { + const embed = new MessageEmbed() + .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}); - } + return message.channel.send({embed}); + } catch (err) { + const embed = new MessageEmbed() + .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, + aliases: [], + guildOnly: false, }; exports.help = { - name: 'eval', - description: 'Evalulates commands.', - usage: '', - category: '- Owners Only', + name: 'eval', + description: 'Evalulates commands.', + usage: '', + category: '- Owners Only', }; diff --git a/commands/git.js b/commands/git.js index cf754f4..ed98ebf 100644 --- a/commands/git.js +++ b/commands/git.js @@ -18,26 +18,26 @@ * * *************************************/ module.exports.run = async (client, message) => { - const Discord = require('discord.js'); - const git = require('git-last-commit'); - git.getLastCommit(function(err, commit) { - const embed = new Discord.RichEmbed() - .setTitle('GitHub Information') - .addField('**Repository:**', 'https://github.com/aleeproductions/AleeBot-JS') - .addField('**Last Commit:**', commit.subject) - .addField('**Commited By:**', commit.author.name) - .setColor('#1fd619'); - message.channel.send({embed}); - }); + const Discord = require('discord.js'); + const git = require('git-last-commit'); + git.getLastCommit(function(err, commit) { + const embed = new Discord.MessageEmbed() + .setTitle('GitHub Information') + .addField('**Repository:**', 'https://github.com/aleeproductions/AleeBot') + .addField('**Last Commit:**', commit.subject) + .addField('**Commited By:**', commit.author.name) + .setColor('#1fd619'); + message.channel.send({embed}); + }); }; exports.conf = { - aliases: [], - guildOnly: false, + aliases: [], + guildOnly: false, }; exports.help = { - name: 'git', - description: 'Get the git info.', - usage: 'git', - category: '- General Commands', + name: 'git', + description: 'Get the git info.', + usage: 'git', + category: '- General Commands', }; diff --git a/commands/help.js b/commands/help.js index 9d94c80..36d4630 100644 --- a/commands/help.js +++ b/commands/help.js @@ -20,51 +20,51 @@ const Discord = require('discord.js'); const fs = require('fs'); module.exports.run = async (client, message) => { - const categories = []; - const commands = Array.from(client.commands.keys()); - const settings = require('../storage/settings.json'); - commands.forEach(function(x) { - if (!categories.includes(client.commands.get(x).help.category)) { - categories.push(client.commands.get(x).help.category); - } - }); + const categories = []; + const commands = Array.from(client.commands.keys()); + const settings = require('../storage/settings.json'); + commands.forEach(function(x) { + if (!categories.includes(client.commands.get(x).help.category)) { + categories.push(client.commands.get(x).help.category); + } + }); - const prefixes = JSON.parse(fs.readFileSync('./storage/prefixes.json', 'utf8')); + const prefixes = JSON.parse(fs.readFileSync('./storage/prefixes.json', 'utf8')); - if (!prefixes[message.guild.id]) { - prefixes[message.guild.id] = { - prefixes: settings.prefix, - }; - } + if (!prefixes[message.guild.id]) { + prefixes[message.guild.id] = { + prefixes: settings.prefix, + }; + } - const prefix = prefixes[message.guild.id].prefixes; - if (!message.guild.member(client.user).hasPermission('EMBED_LINKS')) return message.reply('ERROR: AleeBot doesn\'t have the permission to send embed links please enable them to use the full help.'); - const embed = new Discord.RichEmbed() - .setAuthor('AleeBot ' + require('../storage/settings.json').abVersion + ` Help and on ${client.guilds.size} servers`, client.user.avatarURL) - .setDescription('Every command you input into AleeBot is `' + prefix + '`') - .setColor('#1fd619') - .setFooter('© Copyright 2017-2020 Alee Productions, Licensed with GPL-3.0'); + const prefix = prefixes[message.guild.id].prefixes; + if (!message.guild.member(client.user).hasPermission('EMBED_LINKS')) return message.reply('ERROR: AleeBot doesn\'t have the permission to send embed links please enable them to use the full help.'); + const embed = new Discord.MessageEmbed() + .setAuthor('AleeBot ' + require('../storage/settings.json').abVersion + ` Help and on ${client.guilds.cache.size} servers`, client.user.avatarURL()) + .setDescription('Every command you input into AleeBot is `' + prefix + '`') + .setColor('#1fd619') + .setFooter('© Copyright 2017-2020 Alee Productions, Licensed with GPL-3.0'); - 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, true); - }); + 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, true); + }); - await message.channel.send({embed}); + await message.channel.send({embed}); }; exports.conf = { - aliases: ['h'], - guildOnly: false, + 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', + 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/commands/info.js b/commands/info.js index 5487a14..3de7ecd 100644 --- a/commands/info.js +++ b/commands/info.js @@ -18,25 +18,25 @@ * * *************************************/ module.exports.run = async (client, message) => { - const Discord = require('discord.js'); - const os = require('os'); - const embed = new Discord.RichEmbed() - .setTitle('Information on AleeBot\'s Host') - .addField('OS Hostname: ', os.hostname(), true) - .addField('NodeJS Version: ', process.versions.node, true) - .addField('OS Platform: ', os.platform(), true) - .addField('OS Version: ', os.release(), true) - .setColor('#1fd619'); - message.channel.send({embed}); + const Discord = require('discord.js'); + const os = require('os'); + const embed = new Discord.MessageEmbed() + .setTitle('Information on AleeBot\'s Host') + .addField('OS Hostname: ', os.hostname(), true) + .addField('NodeJS Version: ', process.versions.node, true) + .addField('OS Platform: ', os.platform(), true) + .addField('OS Version: ', os.release(), true) + .setColor('#1fd619'); + message.channel.send({embed}); }; exports.conf = { - aliases: [], - guildOnly: false, + aliases: [], + guildOnly: false, }; exports.help = { - name: 'info', - description: 'Tells you information about the bot', - usage: 'info', - category: '- Information Commands', + name: 'info', + description: 'Tells you information about the bot', + usage: 'info', + category: '- Information Commands', }; diff --git a/commands/interrogate.js b/commands/interrogate.js index c015f2c..54e8cb2 100644 --- a/commands/interrogate.js +++ b/commands/interrogate.js @@ -18,25 +18,25 @@ * * *************************************/ module.exports.run = async (client, message, args) => { - if (message.guild.id != '243022206437687296') return message.reply('This is a ALP exclusive command.'); + if (message.guild.id != '243022206437687296') return message.reply('This is a ALP exclusive command.'); - if (!message.member.hasPermission('BAN_MEMBERS')) return message.reply('It looks like that you don\'t have the permissions to jail members.'); - if (!message.guild.member(client.user).hasPermission('MANAGE_ROLES')) return message.reply('Uhh... I don\'t have permission to jail members.'); + if (!message.member.hasPermission('BAN_MEMBERS')) return message.reply('It looks like that you don\'t have the permissions to jail members.'); + if (!message.guild.member(client.user).hasPermission('MANAGE_ROLES')) return message.reply('Uhh... I don\'t have permission to jail members.'); - const member = message.mentions.members.first(); - if (!member) return await message.reply('Uhh... Please mention a member first.'); + const member = message.mentions.members.first(); + if (!member) return await message.reply('Uhh... Please mention a member first.'); - member.addRole(message.guild.roles.find('name', 'Interrogation')); - message.reply(`Alright, I just interrogated ${member.user.tag}.`); + member.roles.add(message.guild.roles.cache.get('431973193608200193')); + message.reply(`Alright, I just interrogated ${member.user.tag}.`); }; exports.conf = { - aliases: [], - guildOnly: false, + aliases: [], + guildOnly: false, }; exports.help = { - name: 'interrogate', - description: 'Interrogates a member', - usage: 'interrogate [user]', - category: '- ALP Exclusive Commands', + name: 'interrogate', + description: 'Interrogates a member', + usage: 'interrogate [user]', + category: '- ALP Exclusive Commands', }; diff --git a/commands/invite.js b/commands/invite.js index a6ce5a8..e6f538f 100644 --- a/commands/invite.js +++ b/commands/invite.js @@ -18,34 +18,32 @@ * * *************************************/ module.exports.run = async (client, message) => { - const Discord = require('discord.js'); - const embed = new Discord.RichEmbed(); - message.channel.send({embed: { - color: 2086425, - title: 'Invite Command', - fields: [{ - name: 'Invite AleeBot', - value: '[Invite AleeBot to your server.](https://top.gg/bot/282547024547545109)', - }, - { - name: 'Join the Alee Productions Community', - value: '[If there\'s any bugs you can join Alee Community guild and explain the bug...](https://discord.gg/EFhRDqG)', - }, - ], - }, - }); + message.channel.send({embed: { + color: 2086425, + title: 'Invite Command', + fields: [{ + name: 'Invite AleeBot', + value: '[Invite AleeBot to your server.](https://top.gg/bot/282547024547545109)', + }, + { + name: 'Join the Alee Productions Community', + value: '[Discord Server](https://discord.gg/EFhRDqG)', + }, + ], + }, + }); - // message.channel.send('Want AleeBot in your server? Here\'s the link: https://discordapp.com/api/oauth2/authorize?client_id=282547024547545109&permissions=2080375863&scope=bot'); + // message.channel.send('Want AleeBot in your server? Here\'s the link: https://discordapp.com/api/oauth2/authorize?client_id=282547024547545109&permissions=2080375863&scope=bot'); }; exports.conf = { - aliases: [], - guildOnly: false, + aliases: [], + guildOnly: false, }; exports.help = { - name: 'invite', - description: 'Gives you an invite to the guild and the bot.', - usage: 'invite', - category: '- General Commands', + name: 'invite', + description: 'Gives you an invite to the guild and the bot.', + usage: 'invite', + category: '- General Commands', }; diff --git a/commands/jail.js b/commands/jail.js index 199ae20..432f60a 100644 --- a/commands/jail.js +++ b/commands/jail.js @@ -18,25 +18,25 @@ * * *************************************/ module.exports.run = async (client, message, args) => { - if (message.guild.id != '243022206437687296') return message.reply('This is a ALP exclusive command.'); + if (message.guild.id != '243022206437687296') return message.reply('This is a ALP exclusive command.'); - if (!message.member.hasPermission('BAN_MEMBERS')) return message.reply('It looks like that you don\'t have the permissions to jail members.'); - if (!message.guild.member(client.user).hasPermission('MANAGE_ROLES')) return message.reply('Uhh... I don\'t have permission to jail members.'); + if (!message.member.hasPermission('BAN_MEMBERS')) return message.reply('It looks like that you don\'t have the permissions to jail members.'); + if (!message.guild.member(client.user).hasPermission('MANAGE_ROLES')) return message.reply('Uhh... I don\'t have permission to jail members.'); - const member = message.mentions.members.first(); - if (!member) return await message.reply('Uhh... Please mention a member first.'); + const member = message.mentions.members.first(); + if (!member) return await message.reply('Uhh... Please mention a member first.'); - member.addRole(message.guild.roles.find('name', 'Jail')); - message.reply(`Alright, I just jailed ${member.user.tag}.`); + member.roles.add(message.guild.roles.cache.get('428205205155217418')); + message.reply(`Alright, I just jailed ${member.user.tag}.`); }; exports.conf = { - aliases: [], - guildOnly: false, + aliases: [], + guildOnly: false, }; exports.help = { - name: 'jail', - description: 'Jails a member', - usage: 'jail [user]', - category: '- ALP Exclusive Commands', + name: 'jail', + description: 'Jails a member', + usage: 'jail [user]', + category: '- ALP Exclusive Commands', }; diff --git a/commands/kick.js b/commands/kick.js index bfacd92..3cbaaf8 100644 --- a/commands/kick.js +++ b/commands/kick.js @@ -18,28 +18,28 @@ * * *************************************/ module.exports.run = async (client, message, args) => { - const Discord = require('discord.js'); - const mreason = args.join(' ').slice(22); - if (!message.member.permissions.has('KICK_MEMBERS')) return message.reply('It looks like that you don\'t have the permissions to ban people.'); - if (!message.guild.member(client.user).hasPermission('KICK_MEMBERS')) return message.reply('Uhh... I don\'t have permission to kick members.'); - const member = message.mentions.members.first(); - if (!member) return message.reply('Uhh... Please mention a member first.'); - member.kick(`Kicked by: ${message.author.tag} Reason: ` + mreason); - const embed = new Discord.RichEmbed() - .setTitle('User Kicked!') - .setColor('#1fd619') - .addField('**User:**', `${member.user.tag}`) - .addField('**Reason:**', `\`\`\`${mreason}\`\`\``); - await message.channel.send({embed}); + const Discord = require('discord.js'); + const mreason = args.join(' ').slice(22); + if (!message.member.permissions.has('KICK_MEMBERS')) return message.reply('It looks like that you don\'t have the permissions to kick people.'); + if (!message.guild.member(client.user).hasPermission('KICK_MEMBERS')) return message.reply('Uhh... I don\'t have permission to kick members.'); + const member = message.mentions.members.first(); + if (!member) return message.reply('Uhh... Please mention a member first.'); + member.kick(`Kicked by: ${message.author.tag} Reason: ` + mreason); + const embed = new Discord.MessageEmbed() + .setTitle('User Kicked!') + .setColor('#1fd619') + .addField('**User:**', `${member.user.tag}`) + .addField('**Reason:**', `\`\`\`${mreason}\`\`\``); + await message.channel.send({embed}); }; exports.conf = { - aliases: [], - guildOnly: false, + aliases: [], + guildOnly: false, }; exports.help = { - name: 'kick', - description: 'Kicks a member', - usage: 'kick [user]', - category: '- Moderation Commands', + name: 'kick', + description: 'Kicks a member', + usage: 'kick [user]', + category: '- Moderation Commands', }; diff --git a/commands/leaveguild.js b/commands/leaveguild.js index fd77509..5108436 100644 --- a/commands/leaveguild.js +++ b/commands/leaveguild.js @@ -18,18 +18,18 @@ * * *************************************/ module.exports.run = async (client, message) => { - if (!['242775871059001344', message.guild.owner.user.id].includes(message.author.id)) return message.reply('Nope! You need the person who created this bot or the owner of this guild to use this command.'); - message.channel.send('Alright, I\'m leaving the server now. Bye everyone!'); - message.guild.leave(); + if (!['242775871059001344', message.guild.owner.user.id].includes(message.author.id)) return message.reply('Nope! You need the person who created this bot or the owner of this guild to use this command.'); + message.channel.send('Alright, I\'m leaving the server now. Bye everyone!'); + message.guild.leave(); }; exports.conf = { - aliases: [], - guildOnly: false, + aliases: [], + guildOnly: false, }; exports.help = { - name: 'leaveguild', - description: 'Makes the bot leave the server', - usage: 'leaveguild', - category: '- Owners Only', + name: 'leaveguild', + description: 'Makes the bot leave the server', + usage: 'leaveguild', + category: '- Owners Only', }; diff --git a/commands/pay.js b/commands/pay.js deleted file mode 100644 index 2d0aa89..0000000 --- a/commands/pay.js +++ /dev/null @@ -1,60 +0,0 @@ -/** ************************************** - * - * Pay: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * *************************************/ - -module.exports.run = async (client, message, args) => { - const db = require('quick.db'); - if (!message.mentions.members.first()) return message.reply('Please mention a user...'); - - const targetMember = message.mentions.members.first(); - const amount = parseInt(args.join(' ').replace(targetMember, '')); - - if (isNaN(amount)) return message.reply('Please define an amount.'); - - let targetBalance = await db.fetch(`userBalance_${targetMember.id}`); - let selfBalance = await db.fetch(`userBalance_${message.author.id}`); - - if (targetBalance === null) { - db.set(`userBalance_${targetMember.id}`, 0); - targetBalance = 0; - } - - if (selfBalance === null) { - db.set(`userBalance_${message.author.id}`, 0); - selfBalance = 0; - } - - if (amount > selfBalance) return message.reply('Sorry you don\'t have enough money.'); - - db.add(`userBalance_${targetMember.id}`, amount); - db.subtract(`userBalance_${message.author.id}`, amount); - - message.reply(`Successfully transfered $${amount} to ${targetMember.user}`); -}; - -exports.conf = { - aliases: ['transfer'], - guildOnly: false, -}; -exports.help = { - name: 'pay', - description: 'You can pay others!', - usage: 'pay [@user] [interger]', - category: '- Economy Commands', -}; diff --git a/commands/ping.js b/commands/ping.js index afb3807..b8d2779 100644 --- a/commands/ping.js +++ b/commands/ping.js @@ -18,16 +18,16 @@ * * *************************************/ module.exports.run = async (client, message) => { - message.reply('**PONG!** :ping_pong: ' + Math.round(client.ping) + ' ms'); + message.reply('**PONG!** :ping_pong: ' + Math.round(client.ws.ping) + ' ms'); }; exports.conf = { - aliases: [], - guildOnly: false, + aliases: [], + guildOnly: false, }; exports.help = { - name: 'ping', - description: 'Ping the bot.', - usage: 'ping', - category: '- General Commands', + name: 'ping', + description: 'Ping the bot.', + usage: 'ping', + category: '- General Commands', }; diff --git a/commands/poweroff.js b/commands/poweroff.js index 3f60f8a..8067c5f 100644 --- a/commands/poweroff.js +++ b/commands/poweroff.js @@ -17,26 +17,30 @@ * along with this program. If not, see . * * *************************************/ -module.exports.run = async (client, message, args) => { - const Discord = require('discord.js'); - if (!['242775871059001344'].includes(message.author.id)) return message.reply('Nope! You need the person who created this bot to use this command.'); - const embed = new Discord.RichEmbed() - .setAuthor('AleeBot Status', client.user.avatarURL) - .setDescription('AleeBot is now going offline...') - .setColor('#ff3333'); - await client.channels.find('id', '606602551634296968').send({embed}); - await message.reply(':warning: AleeBot will now exit!'); - client.destroy(); - process.exit(0); +module.exports.run = async (client, message) => { + const Discord = require('discord.js'); + if (!['242775871059001344'].includes(message.author.id)) return message.reply('Nope! You need the person who created this bot to use this command.'); + const stopEmbed = new Discord.MessageEmbed() + .setAuthor('AleeBot Status', client.user.avatarURL()) + .setDescription('AleeBot is now going offline...') + .setColor('#ff3333'); + + let statusChannel = client.channels.cache.get('606602551634296968'); + if (!statusChannel) return console.error('The status channel does not exist! Skipping.'); + await statusChannel.send(stopEmbed); + await message.reply(':warning: AleeBot will now exit!'); + console.log('[i] AleeBot will now exit!'.blue); + client.destroy(); + process.exit(0); }; exports.conf = { - aliases: ['reboot'], - guildOnly: false, + aliases: ['reboot'], + guildOnly: false, }; exports.help = { - name: 'poweroff', - description: 'Turns off AleeBot.', - usage: 'poweroff', - category: '- Owners Only', + name: 'poweroff', + description: 'Turns off AleeBot.', + usage: 'poweroff', + category: '- Owners Only', }; diff --git a/commands/purge.js b/commands/purge.js index 6122083..97c1be6 100644 --- a/commands/purge.js +++ b/commands/purge.js @@ -18,22 +18,22 @@ * * *************************************/ 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 (!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.'); + 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.`)); + message.channel.bulkDelete(args[0]) + .then( (messages) => message.channel.send(`Successfully deleted ${messages.size} messages.`)); }; exports.conf = { - aliases: ['rm'], - guildOnly: false, + aliases: ['rm'], + guildOnly: false, }; exports.help = { - name: 'purge', - description: 'Removes messages in a bulk.', - usage: 'purge [number]', - category: '- Moderation Commands', + name: 'purge', + description: 'Removes messages in a bulk.', + usage: 'purge [number]', + category: '- Moderation Commands', }; diff --git a/commands/quote.js b/commands/quote.js index ce7b56a..149fe37 100644 --- a/commands/quote.js +++ b/commands/quote.js @@ -18,47 +18,47 @@ * * *************************************/ module.exports.run = async (client, message) => { - const Discord = require('discord.js'); + const Discord = require('discord.js'); - let NewQuote; + let NewQuote; - function GetNewQuote(quoteNum = -1) { - NewQuote = new Discord.RichEmbed(); + function GetNewQuote(quoteNum = -1) { + NewQuote = new Discord.MessageEmbed(); - let quo = require('../storage/quotes.json').quotes; + let quo = require('../storage/quotes.json').quotes; - if (quoteNum == -1) { - quoteNum = Math.floor(Math.random() * 1000) % quo.length; - quo=quo[quoteNum]; - } + if (quoteNum == -1) { + quoteNum = Math.floor(Math.random() * 1000) % quo.length; + quo=quo[quoteNum]; + } - const author = quo.author; - const authorImage = quo.authorImage; - const quote = quo.quote; - const year = quo.year; - const url = quo.url; + const author = quo.author; + const authorImage = quo.authorImage; + const quote = quo.quote; + const year = quo.year; + const url = quo.url; - NewQuote.setAuthor(author, authorImage); - NewQuote.setColor('#1fd619'); - NewQuote.setDescription(quote); - NewQuote.setFooter('- ' + year); - NewQuote.setURL(url); + NewQuote.setAuthor(author, authorImage); + NewQuote.setColor('#1fd619'); + NewQuote.setDescription(quote); + NewQuote.setFooter('- ' + year); + NewQuote.setURL(url); - return NewQuote; - } + return NewQuote; + } - const newquote = GetNewQuote(); - message.reply('Alright, here\'s your quote.'); - message.channel.send(newquote); + const newquote = GetNewQuote(); + message.reply('Alright, here\'s your quote.'); + message.channel.send(newquote); }; exports.conf = { - aliases: [], - guildOnly: false, + aliases: [], + guildOnly: false, }; exports.help = { - name: 'quote', - description: 'Tells you quotes', - usage: 'quote', - category: '- Quote Commands', + name: 'quote', + description: 'Tells you quotes', + usage: 'quote', + category: '- Quote Commands', }; diff --git a/commands/reload.js b/commands/reload.js new file mode 100644 index 0000000..118aae4 --- /dev/null +++ b/commands/reload.js @@ -0,0 +1,55 @@ +/** ************************************** + * + * Invite: Command for AleeBot + * Copyright (C) 2017-2020 Alee Productions + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * *************************************/ +// eslint-disable-next-line no-unused-vars +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.'); + if (!args.length) return message.channel.send(`You didn't pass any command to reload, ${message.author}!`); + const commandName = args[0].toLowerCase(); + const command = message.client.commands.get(commandName) + || message.client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName)); + + if (!command) return message.channel.send(`There is no command with name or alias \`${commandName}\`, ${message.author}!`); + delete require.cache[require.resolve(`./${command.name}.js`)]; + try { + const newCommand = require(`./${command.name}.js`); + message.client.commands.set(newCommand.name, newCommand); + } catch (error) { + console.log(error); + message.channel.send(`There was an error while reloading a command \`${command.name}\`:\n\`${error.message}\``); + } + message.channel.send(`Command \`${command.name}\` was reloaded!`);*/ + + message.reply('Coming soon.'); + +}; + +exports.conf = { + aliases: [], + guildOnly: false, +}; +exports.help = { + name: 'reload', + description: 'Reloads command.', + usage: 'reload [command]', + category: '- Owners Only', +}; + + \ No newline at end of file diff --git a/commands/say.js b/commands/say.js index 774e9e3..fe17b42 100644 --- a/commands/say.js +++ b/commands/say.js @@ -18,19 +18,19 @@ * * *************************************/ 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 absay = args.join(' '); - message.delete().catch(); - message.channel.send(absay); + if (!['242775871059001344'].includes(message.author.id)) return message.reply('Nope! You need the person who created this bot to use this command.'); + const absay = args.join(' '); + message.delete().catch(); + message.channel.send(absay); }; exports.conf = { - aliases: [], - guildOnly: false, + aliases: [], + guildOnly: false, }; exports.help = { - name: 'say', - description: 'You can control AleeBot now!', - usage: 'say [context]', - category: '- Owners Only', + name: 'say', + description: 'You can control AleeBot now!', + usage: 'say [context]', + category: '- Owners Only', }; diff --git a/commands/setprefix.js b/commands/setprefix.js index 1c53509..edb42c9 100644 --- a/commands/setprefix.js +++ b/commands/setprefix.js @@ -18,35 +18,35 @@ * * *************************************/ module.exports.run = async (client, message, args) => { - const moment = require('moment'); - const log = (message) => { - console.log(`[${moment().format('YYYY-MM-DD HH:mm:ss')}] ${message}`); - }; - const fs = require('fs'); - if (!message.member.hasPermission('ADMINISTRATOR')) return message.reply('Sorry you need admin to set my prefix'); - if (!args[0] || args[0 == 'help']) return message.reply(`Usage: setprefix `); + const moment = require('moment'); + const log = (message) => { + console.log(`[${moment().format('YYYY-MM-DD HH:mm:ss')}] ${message}`); + }; + const fs = require('fs'); + if (!message.member.hasPermission('ADMINISTRATOR')) return message.reply('Sorry you need admin to set my prefix'); + if (!args[0] || args[0 == 'help']) return message.reply('Usage: setprefix '); - const prefixes = JSON.parse(fs.readFileSync('./storage/prefixes.json', 'utf8')); + const prefixes = JSON.parse(fs.readFileSync('./storage/prefixes.json', 'utf8')); - prefixes[message.guild.id] = { - prefixes: args[0], - }; + prefixes[message.guild.id] = { + prefixes: args[0], + }; - fs.writeFile('./storage/prefixes.json', JSON.stringify(prefixes), (err) =>{ - if (err) log(err); - }); + fs.writeFile('./storage/prefixes.json', JSON.stringify(prefixes), (err) =>{ + if (err) log(err); + }); - message.reply(`AleeBot's Prefix in this guild is now \`${args[0]}\``); - log(`[i] The guild ${message.guild.name} has changed AleeBot's prefix to ${args[0]}`); + message.reply(`AleeBot's Prefix in this guild is now \`${args[0]}\``); + log(`[i] The guild ${message.guild.name} has changed AleeBot's prefix to ${args[0]}`); }; exports.conf = { - aliases: [], - guildOnly: true, + aliases: [], + guildOnly: true, }; exports.help = { - name: 'setprefix', - description: 'Sets the guild prefix.', - usage: 'setprefix [prefix]', - category: '- Settings Commands', + name: 'setprefix', + description: 'Sets the guild prefix.', + usage: 'setprefix [prefix]', + category: '- Settings Commands', }; diff --git a/commands/setup.js b/commands/setup.js new file mode 100644 index 0000000..c45fbae --- /dev/null +++ b/commands/setup.js @@ -0,0 +1,45 @@ +/**************************************** + * + * Setup: Command for AleeBot + * Copyright (C) 2017-2020 Alee Productions + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * *************************************/ + +module.exports.run = async (client, message) => { + if (!['242775871059001344', message.guild.owner.user.id].includes(message.author.id)) return message.reply(':warning: You must be a server owner or be the creator of the bot to access this command.'); + message.reply('Look at your DMs.'); + //message.reply("This feature is coming soon. Stay tuned!"); + const Discord = require('discord.js'); + const setupEmbed = new Discord.MessageEmbed() + .setTitle('AleeBot Setup', client.user.avatarURL()) + .setDescription('Select the options') + .addField('Chat Logs', 'placeholder', true) + .addField('Chat Logs', 'placeholder', true) + .addField('Chat Logs', 'placeholder', true); + + message.author.send(setupEmbed); +}; + +exports.conf = { + aliases: [], + guildOnly: false, +}; +exports.help = { + name: 'setup', + description: 'Setting up AleeBot.', + usage: 'setup', + category: '- Settings Commands', +}; \ No newline at end of file diff --git a/commands/suggest.js b/commands/suggest.js index 6fb4289..3adaa31 100644 --- a/commands/suggest.js +++ b/commands/suggest.js @@ -18,28 +18,28 @@ * * *************************************/ module.exports.run = async (client, message, args) => { - if (message.guild.id != '243022206437687296') return message.reply('This is a ALP exclusive command.'); - const {RichEmbed} = require('discord.js'); - client.channels.find('id', '427495678390960148').send( - new RichEmbed() - .setColor('#1fd619') - .setTitle('Suggestion') - .setDescription(`This is a suggestion from `+ message.author.username +` please react to it using the following emojis.`) - .addField('Suggestion Contents', args.join(' ')), - ).then((message) => { - message.react('\u2705'); - message.react('\u274E'); - }); - message.reply('Your suggestion has been shown in the suggestions channel.'); + if (message.guild.id != '243022206437687296') return message.reply('This is a ALP exclusive command.'); + const {MessageEmbed} = require('discord.js'); + client.channels.cache.get('427495678390960148').send( + new MessageEmbed() + .setColor('#1fd619') + .setTitle('Suggestion') + .setDescription('This is a suggestion from '+ message.author.username +' please react to it using the following emojis.') + .addField('Suggestion Contents', args.join(' ')), + ).then((message) => { + message.react('\u2705'); + message.react('\u274E'); + }); + message.reply('Your suggestion has been shown in the suggestions channel.'); }; exports.conf = { - aliases: [], - guildOnly: false, + aliases: [], + guildOnly: false, }; exports.help = { - name: 'suggest', - description: 'Suggest a feature in ACN.', - usage: 'suggest [suggestion]', - category: '- ALP Exclusive Commands', + name: 'suggest', + description: 'Suggest a feature in ALP.', + usage: 'suggest [suggestion]', + category: '- ALP Exclusive Commands', }; diff --git a/commands/suggestfeature.js b/commands/suggestfeature.js index fac82a6..8b8b3c7 100644 --- a/commands/suggestfeature.js +++ b/commands/suggestfeature.js @@ -18,27 +18,27 @@ * * *************************************/ module.exports.run = async (client, message, args) => { - const { RichEmbed } = require('discord.js'); + const { MessageEmbed } = require('discord.js'); - client.channels.find('id', '427495678390960148').send( - new RichEmbed() - .setColor ('#1fd619') - .setTitle('AleeBot Feature Suggestion') - .setDescription(`This is an AleeBot feature suggestion from `+ message.author.username +` sending from ${message.guild.name}.`) - .addField('Suggestion Contents', args.join(' ')) - ) - await message.reply("Your suggestion has been shown to the ALP discord server!") + client.channels.cache.get('427495678390960148').send( + new MessageEmbed() + .setColor ('#1fd619') + .setTitle('AleeBot Feature Suggestion') + .setDescription('This is an AleeBot feature suggestion from '+ message.author.username +` sending from ${message.guild.name}.`) + .addField('Suggestion Contents', args.join(' ')) + ); + await message.reply('Your suggestion has been shown to the ALP discord server!'); - }; +}; - exports.conf = { - aliases: [], - guildOnly: false, - }; - exports.help = { - name: 'suggestfeature', - description: 'Suggest features in AleeBot.', - usage: 'suggestfeature [suggestion]', - category: '- General Commands', - }; +exports.conf = { + aliases: [], + guildOnly: false, +}; +exports.help = { + name: 'suggestfeature', + description: 'Suggest features in AleeBot.', + usage: 'suggestfeature [suggestion]', + category: '- General Commands', +}; diff --git a/commands/uptime.js b/commands/uptime.js index 8f97d02..90afc81 100644 --- a/commands/uptime.js +++ b/commands/uptime.js @@ -18,26 +18,26 @@ * * *************************************/ 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.'); + 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, + aliases: [], + guildOnly: false, }; exports.help = { - name: 'uptime', - description: 'Displays Uptime.', - usage: 'uptime', - category: '- General Commands', + name: 'uptime', + description: 'Displays Uptime.', + usage: 'uptime', + category: '- General Commands', }; diff --git a/commands/userinfo.js b/commands/userinfo.js index 3b79beb..c03dfed 100644 --- a/commands/userinfo.js +++ b/commands/userinfo.js @@ -18,25 +18,25 @@ * * *************************************/ module.exports.run = async (client, message) => { - const Discord = require('discord.js'); - const embed = new Discord.RichEmbed() - .setAuthor(message.author.tag, message.author.avatarURL) - .setDescription('User Information') - .setThumbnail(message.author.avatarURL) - .addField('Names', '**Username:** ' + message.author.username + '\n**Current Nickname:** ' + message.member.displayName) - .addField('Identity', `**User ID:** ${message.author.id} `) - .addField('Create and Join Times', '**Created At:** ' + message.member.user.createdAt.toUTCString() + '\n**Joined Guild At:** ' + message.member.joinedAt.toUTCString()) - .setColor('#1fd619'); - message.channel.send({embed}); + const Discord = require('discord.js'); + const embed = new Discord.MessageEmbed() + .setAuthor(message.author.tag, message.author.avatarURL()) + .setDescription('User Information') + .setThumbnail(message.author.avatarURL()) + .addField('Names', '**Username:** ' + message.author.username + '\n**Current Nickname:** ' + message.member.displayName) + .addField('Identity', `**User ID:** ${message.author.id} `) + .addField('Create and Join Times', '**Created At:** ' + message.member.user.createdAt.toUTCString() + '\n**Joined Guild At:** ' + message.member.joinedAt.toUTCString()) + .setColor('#1fd619'); + message.channel.send({embed}); }; exports.conf = { - aliases: ['uinfo'], - guildOnly: false, + aliases: ['uinfo'], + guildOnly: false, }; exports.help = { - name: 'userinfo', - description: 'Tells your info.', - usage: 'userinfo', - category: '- Information Commands', + name: 'userinfo', + description: 'Tells your info.', + usage: 'userinfo', + category: '- Information Commands', }; diff --git a/commands/vtquote.js b/commands/vtquote.js deleted file mode 100644 index 7d1ccd0..0000000 --- a/commands/vtquote.js +++ /dev/null @@ -1,64 +0,0 @@ -/** ************************************** - * - * VTQuote: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * *************************************/ -module.exports.run = async (client, message) => { - const Discord = require('discord.js'); - - let VictorQuote; - - function GetVictorQuote(quoteNum = -1) { - VictorQuote = new Discord.RichEmbed(); - - let quo = require('../storage/vtquotes.json').quotes; - - if (quoteNum == -1) { - quoteNum = Math.floor(Math.random() * 1000) % quo.length; - quo=quo[quoteNum]; - } - - const author = quo.author; - const authorImage = quo.authorImage; - const quote = quo.quote; - const year = quo.year; - const url = quo.url; - - VictorQuote.setAuthor(author, authorImage); - VictorQuote.setColor('#1fd619'); - VictorQuote.setDescription(quote); - VictorQuote.setFooter('- ' + year); - VictorQuote.setURL(url); - - return VictorQuote; - } - - const victorquote = GetVictorQuote(); - message.reply('Alright, here\'s your Victor quote.'); - message.channel.send(victorquote); -}; - -exports.conf = { - aliases: [], - guildOnly: false, -}; -exports.help = { - name: 'vtquote', - description: 'Tells you quotes when victor accidentaly swore.', - usage: 'vtquote', - category: '- Quote Commands', -}; diff --git a/deprecated/balance.js b/deprecated/balance.js new file mode 100644 index 0000000..ca32081 --- /dev/null +++ b/deprecated/balance.js @@ -0,0 +1,50 @@ +/** ************************************** + * + * Balance: Command for AleeBot + * Copyright (C) 2017-2020 Alee Productions + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * *************************************/ +module.exports.run = async (client, message) => { + const db = require('quick.db'); + const {MessageEmbed} = require('discord.js'); + + const user = message.mentions.users.first() || message.author; + + let balance = await db.fetch(`userBalance_${user.id}`); + + if (balance === null) { + db.set(`userBalance_${message.author.id}`, 0); + balance = 0; + } + const embed = new MessageEmbed() + .setDescription('**AleeCorp Bank**') + .addField('Account Holder: ', user.username, true) + .addField('Account Balance: ', balance, true) + .setColor('#1fd619'); + + message.channel.send({embed}); +}; + +exports.conf = { + aliases: ['bal', 'money'], + guildOnly: false, +}; +exports.help = { + name: 'balance', + description: 'Checks the balance of AleeBot', + usage: 'balance [@someone (optional)]', + category: '- Economy Commands', +}; diff --git a/deprecated/buy.js b/deprecated/buy.js index 9757d51..25f2589 100644 --- a/deprecated/buy.js +++ b/deprecated/buy.js @@ -18,7 +18,6 @@ * * *************************************/ module.exports.run = async (client, message, args) => { -/* const Discord = require('discord.js'); const fs = require('fs') const db = require('quick.db'); @@ -39,7 +38,7 @@ const items = JSON.parse(fs.readFileSync('./storage/items.json', 'utf8')); } - const embed = new Discord.RichEmbed() + const embed = new Discord.MessageEmbed() .setDescription(`Available Items`) .setColor('#1fd619') @@ -101,17 +100,15 @@ const items = JSON.parse(fs.readFileSync('./storage/items.json', 'utf8')); } message.channel.send('You bought ' + itemName + '!'); - */ - message.reply('Command is broken for now'); }; exports.conf = { - aliases: [], - guildOnly: false, + aliases: [], + guildOnly: false, }; exports.help = { - name: 'buy', - description: 'Buy things.', - usage: 'buy [item]', - category: '- Economy Commands', + name: 'buy', + description: 'Buy things.', + usage: 'buy [item]', + category: '- Economy Commands', }; diff --git a/deprecated/daily.js b/deprecated/daily.js index c58928c..c0f04f9 100644 --- a/deprecated/daily.js +++ b/deprecated/daily.js @@ -21,36 +21,36 @@ const db = require('quick.db'); ms = require('parse-ms'); module.exports.run = async (client, message) => { - const cooldown = 8.64e+7; - const amount = 100; + const cooldown = 8.64e+7; + const amount = 100; - const lastDaily = await db.fetch(`lastDaily_${message.author.id}`); + const lastDaily = await db.fetch(`lastDaily_${message.author.id}`); - if (lastDaily !== null && cooldown - (Date.now() - lastDaily) > 0) { - const timeObj = ms(cooldown - (Date.now() - lastDaily)); + if (lastDaily !== null && cooldown - (Date.now() - lastDaily) > 0) { + const timeObj = ms(cooldown - (Date.now() - lastDaily)); - message.reply(`You already collected your money, please wait **${timeObj.hours}h ${timeObj.minutes}m**!`); - } else { - message.channel.send(`You have successfully collected $${amount} dollars!`); + message.reply(`You already collected your money, please wait **${timeObj.hours}h ${timeObj.minutes}m**!`); + } else { + message.channel.send(`You have successfully collected $${amount} dollars!`); - const balance = await db.fetch(`userBalance_${message.author.id}`); + const balance = await db.fetch(`userBalance_${message.author.id}`); - if (balance == null) { - db.set(`userBalance_${message.author.id}`, 0); - } + if (balance == null) { + db.set(`userBalance_${message.author.id}`, 0); + } - db.set(`lastDaily_${message.author.id}`, Date.now()); - db.add(`userBalance_${message.author.id}`, 100); - } + db.set(`lastDaily_${message.author.id}`, Date.now()); + db.add(`userBalance_${message.author.id}`, 100); + } }; exports.conf = { - aliases: [], - guildOnly: false, + aliases: [], + guildOnly: false, }; exports.help = { - name: 'daily', - description: 'This gives you money everyday.', - usage: 'daily', - category: '- Economy Commands', + name: 'daily', + description: 'This gives you money everyday.', + usage: 'daily', + category: '- Economy Commands', }; diff --git a/deprecated/pay.js b/deprecated/pay.js new file mode 100644 index 0000000..bc27a4b --- /dev/null +++ b/deprecated/pay.js @@ -0,0 +1,60 @@ +/** ************************************** + * + * Pay: Command for AleeBot + * Copyright (C) 2017-2020 Alee Productions + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * *************************************/ + +module.exports.run = async (client, message, args) => { + const db = require('quick.db'); + if (!message.mentions.members.first()) return message.reply('Please mention a user...'); + + const targetMember = message.mentions.members.first(); + const amount = parseInt(args.join(' ').replace(targetMember, '')); + + if (isNaN(amount)) return message.reply('Please define an amount.'); + + let targetBalance = await db.fetch(`userBalance_${targetMember.id}`); + let selfBalance = await db.fetch(`userBalance_${message.author.id}`); + + if (targetBalance === null) { + db.set(`userBalance_${targetMember.id}`, 0); + targetBalance = 0; + } + + if (selfBalance === null) { + db.set(`userBalance_${message.author.id}`, 0); + selfBalance = 0; + } + + if (amount > selfBalance) return message.reply('Sorry you don\'t have enough money.'); + + db.add(`userBalance_${targetMember.id}`, amount); + db.subtract(`userBalance_${message.author.id}`, amount); + + message.reply(`Successfully transfered $${amount} to ${targetMember.user}`); +}; + +exports.conf = { + aliases: ['transfer'], + guildOnly: false, +}; +exports.help = { + name: 'pay', + description: 'You can pay others!', + usage: 'pay [@user] [interger]', + category: '- Economy Commands', +}; diff --git a/package.json b/package.json index c982509..ad4eb3f 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "aleebot", "version": "2.0.0", "description": "A chat bot for discord written in discord.js.", - "main": "src/bot.js", + "main": "bot_discord.js", "scripts": { "start": "node bot_discord.js", "dev": "nodemon bot_discord.js --beta" @@ -14,14 +14,15 @@ "author": "Alee Productions", "license": "GPL-3.0", "bugs": { - "url": "https://github.com/aleeproductions/AleeBot-JS/issues" + "url": "https://github.com/aleeproductions/AleeBot/issues" }, - "homepage": "https://github.com/aleeproductions/AleeBot-JS#readme", + "homepage": "https://github.com/aleeproductions/AleeBot#readme", "dependencies": { "blessed": "^0.1.81", "colors": "^1.3.0", "dblapi.js": "^2.0.0", - "discord.js": "^11.3.1", + "discord.js": "^12.2.0", + "eslint": "^7.1.0", "fs": "0.0.1-security", "git-last-commit": "^0.3.0", "i18next": "^19.4.4", @@ -30,6 +31,8 @@ "os": "^0.1.1", "parse-ms": "^1.0.1", "readline": "^1.3.0", + "sequelize": "^6.2.3", + "sqlite3": "^4.2.0", "ytdl-core": "^0.20.4" }, "devDependencies": { diff --git a/storage/items.json b/storage/items.json deleted file mode 100644 index 1d57718..0000000 --- a/storage/items.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "Programmer" : { - "name": "Programmer Role", - "price": "100", - "type": "Roles", - "desc": "Buying this gives you the programmer role." - }, - "AleeOS" : { - "name": "AleeOS", - "price": "400", - "type": "OS", - "desc": "Buying this gives you AleeOS." - }, - "theSlate" : { - "name": "theSlate", - "price": "400", - "type": "Tools", - "desc": "Buying this gives you theSlate." - } -} \ No newline at end of file -- cgit v1.2.3 From 06dd6383d7a239817c2a9724465896ef7da70bc2 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Thu, 29 Jul 2021 16:00:22 -0400 Subject: Big changes --- CONTRIBUTING.md | 8 +- To be worked on/leave.js | 2 +- To be worked on/play.js | 2 +- To be worked on/queue.js | 2 +- To be worked on/skip.js | 2 +- bot_discord.js | 59 ++++++---- commands/about.js | 4 +- commands/addquote.js | 82 ++++++++++---- commands/ask.js | 2 +- commands/avatarurl.js | 12 ++- commands/ban.js | 4 +- commands/eval.js | 2 +- commands/git.js | 2 +- commands/help.js | 4 +- commands/info.js | 6 +- commands/interrogate.js | 2 +- commands/invite.js | 12 ++- commands/jail.js | 2 +- commands/kick.js | 4 +- commands/leaveguild.js | 2 +- commands/nick.js | 2 +- commands/ping.js | 2 +- commands/poweroff.js | 2 +- commands/purge.js | 2 +- commands/quote.js | 44 ++++++-- commands/say.js | 2 +- commands/serverinfo.js | 51 +++++++++ commands/setlogchannel.js | 63 +++++++++++ commands/setprefix.js | 2 +- commands/setup.js | 45 -------- commands/slowdown.js | 2 +- commands/suggest.js | 2 +- commands/suggestfeature.js | 2 +- commands/uptime.js | 2 +- commands/userinfo.js | 2 +- deprecated/balance.js | 2 +- deprecated/buy.js | 2 +- deprecated/daily.js | 2 +- deprecated/pay.js | 2 +- deprecated/setup.js | 45 ++++++++ package.json | 7 +- plugins/mongo.js | 10 ++ schema/logging-schema.js | 13 +++ schema/quote-schema.js | 17 +++ storage/quotes.json | 260 --------------------------------------------- storage/quotes.json.bak | 260 --------------------------------------------- storage/vtquotes.json | 60 ----------- 47 files changed, 402 insertions(+), 718 deletions(-) create mode 100644 commands/serverinfo.js create mode 100644 commands/setlogchannel.js delete mode 100644 commands/setup.js create mode 100644 deprecated/setup.js create mode 100644 plugins/mongo.js create mode 100644 schema/logging-schema.js create mode 100644 schema/quote-schema.js delete mode 100644 storage/quotes.json delete mode 100644 storage/quotes.json.bak delete mode 100644 storage/vtquotes.json (limited to 'storage') diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 473704a..aa79553 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,7 +5,7 @@ Include the GPL-3.0 license too and follow the following format when you create /**************************************** * * [Command/Plugin]: (Command or Plugin) for AleeBot - * Copyright (C) 2017-2020 Alee Productions & (your name here) + * Copyright (C) 2017-2021 Alee Productions & (your name here) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -43,7 +43,9 @@ exports.help = { First get NodeJS then clone this repo then do `npm install` or `yarn install` in the AleeBot folder. Now add a file called `tokens.json` then copy and paste this follow code. ```json { - "abtoken": "token" + "abtoken": "token", + "mongoPath": "mongodb://127.0.0.1:27017/aleebot", + "port": 3000 } ``` -Then get your token from discord and replace `token` with your token and finally run this in linux `./run_linux.sh` or for windows `run_win.bat` or `npm/yarn start`. +Then get your token from discord and replace `token` with your token. After that, install MongoDB and run it. Finally, run this in linux `./run_linux.sh` or for windows `run_win.bat` or `npm/yarn start`. diff --git a/To be worked on/leave.js b/To be worked on/leave.js index da0b4cc..78410e2 100644 --- a/To be worked on/leave.js +++ b/To be worked on/leave.js @@ -1,7 +1,7 @@ /** ************************************** * * Leave: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/To be worked on/play.js b/To be worked on/play.js index abebc8b..f14d3c5 100644 --- a/To be worked on/play.js +++ b/To be worked on/play.js @@ -1,7 +1,7 @@ /** ************************************** * * Play: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/To be worked on/queue.js b/To be worked on/queue.js index 1208ddf..2b6d31a 100644 --- a/To be worked on/queue.js +++ b/To be worked on/queue.js @@ -1,7 +1,7 @@ /** ************************************** * * Queue: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/To be worked on/skip.js b/To be worked on/skip.js index 371e7e7..bda040b 100644 --- a/To be worked on/skip.js +++ b/To be worked on/skip.js @@ -1,7 +1,7 @@ /** ************************************** * * Skip: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/bot_discord.js b/bot_discord.js index 991a294..79e9643 100644 --- a/bot_discord.js +++ b/bot_discord.js @@ -1,7 +1,7 @@ /** ************************************** * * AleeBot: Made for discord servers - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,16 +18,19 @@ * * *************************************/ const Discord = require('discord.js'); +const client = new Discord.Client({ + disableEveryone: true, +}); const moment = require('moment'); +const express = require('express'); +const fs = require('fs'); const readline = require('readline'); const colors = require('colors'); const DBL = require('dblapi.js'); //const i18next = require('i18next'); -const client = new Discord.Client({ - disableEveryone: true, -}); +const web = express(); const settings = require('./storage/settings.json'); -const fs = require('fs'); +const mongo = require('./plugins/mongo'); const api = require('./tokens.json'); const dbl = new DBL(api.dbltoken, client); const active = new Map(); @@ -35,13 +38,16 @@ const ownerID = '242775871059001344'; let autoRole = true; let logChannel = '318874545593384970'; let statusChannelID = '606602551634296968'; -let readyEmbedMessage = true; +let readyEmbedMessage = false; + const activities = [ 'AleeBot ' + settings.abVersion + ' | ' + settings.prefix + 'help', 'Coding bytes', 'Drawing shapes', 'Fighting Quad', - 'Ultra Jump Mania!' + 'Ultra Jump Mania!', + 'Exposing TAS-Corp', + 'Fighting Evelyn Claythorne' ]; const log = (message) => { @@ -54,7 +60,7 @@ const rl = readline.createInterface({ prompt: '> '.gray, }); -console.log(`AleeBot ${settings.abVersion}: Copyright (C) 2017-2020 Alee Productions`.gray); +console.log(`AleeBot ${settings.abVersion}: Copyright (C) 2017-2021 Alee Productions`.gray); console.log('This program comes with ABSOLUTELY NO WARRANTY; for details type `show w\'.'.gray); console.log('This is free software, and you are welcome to redistribute it'.gray); console.log('under certain conditions; type `show c\' for details.\n'.gray); @@ -103,8 +109,7 @@ fs.readdir('./commands', (err, files) => { console.log(err.stack); } }); - log('[>] Command Loading complete!'.green); - console.log('\n'); + log('[>] Command loading complete!\n'.green); }); rl.on('line', function(cmd) { @@ -114,7 +119,7 @@ rl.on('line', function(cmd) { if (client.guilds.size === 0) { console.log(('[!] No guilds found.'.yellow)); } else { - console.log('[i] Here\'s the servers that AleeBot is connected to:'); + console.log('[i] These are the servers that AleeBot is connected to:'); for ([id, guild] of client.guilds) { console.log(` Guild Name: ${guild.name} - ID: ${guild.id}`.blue); } @@ -124,8 +129,8 @@ rl.on('line', function(cmd) { if (!args[1]) { console.log('[!] Please insert the guild\'s ID.'.yellow); } else { - var guild = client.guilds.get(args[1]); - console.log('[i] Here\'s the channels that this guild have:'.blue); + let guild = client.guilds.get(args[1]); + console.log('[i] These are the channels that this guild have:'.blue); for ([id, channel, guild] of guild && client.channels) { console.log(` Channel: #${channel.name} - ID: ${channel.id}`.blue); } @@ -135,7 +140,7 @@ rl.on('line', function(cmd) { if (!args[1]) { console.log('[!] Please insert the guild\'s ID.'.yellow); } else { - var guild = client.guilds.get(args[1]); + let guild = client.guilds.get(args[1]); guild.leave(); } break; @@ -144,9 +149,9 @@ rl.on('line', function(cmd) { console.log('[!] Usage: broadcast [guildID] [channelID].'.yellow); } else { const broadcast = args.join(' ').slice(48); - var guild = null; + let guild = null; guild = client.guilds.get(args[1]); - var channel = null; + let channel = null; channel = guild.channels.get(args[2]); if (channel != null) { channel.send(broadcast); @@ -198,14 +203,29 @@ rl.on('line', function(cmd) { rl.prompt(); }); -client.on('ready', () => { +client.on('ready', async () => { log('[>] AleeBot is now ready!'.green); log(`[i] Logged in as ${client.user.tag}`.green); log(`[i] Default Prefix: ${settings.prefix}`.green); log(`[i] Bot ID: ${client.user.id}`.green); - log(`[i] Token: ${api.abtoken}`.green); log(`[i] Running version ${settings.abVersion} and in ${client.guilds.cache.size} guilds`.green); + await mongo().then(mongoose => { + try { + log('[>] Connected to MongoDB!'.green); + } finally { + mongoose.connection.close(); + } + }) + + web.get('/', (req, res) => { + res.send("Hello World! This is going to become the AleeBot dashboard..."); + }); + + web.listen(api.port, () => { + console.log(`Listening at https://localhost:${api.port}`) + }) + client.setInterval(function() { /* setInterval(() => { @@ -223,6 +243,7 @@ client.on('ready', () => { const readyEmbed = new Discord.MessageEmbed() .setAuthor('AleeBot Status', client.user.avatarURL()) .setDescription('AleeBot has started') + .addField('Version', settings.abVersion, true) .addField('Prefix', `\`${settings.prefix}\``, true) .setColor('#5cd65c'); let statusChannel = client.channels.cache.get(statusChannelID); @@ -410,7 +431,7 @@ client.on('message', (msg) => { if (cmd) { if (cmd.conf.guildOnly === true) { if (!msg.channel.guild) { - return msg.channel.createMessage('This command can only be ran in a guild.'); + return msg.channel.send('This command can only be ran in a guild.'); } } try { diff --git a/commands/about.js b/commands/about.js index a455faa..e22d0f8 100644 --- a/commands/about.js +++ b/commands/about.js @@ -1,7 +1,7 @@ /** ************************************** * * About: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ module.exports.run = async (client, message) => { .setAuthor(`AleeBot ${require('../storage/settings.json').abVersion}`, client.user.avatarURL()) .addField('About AleeBot', 'AleeBot is an all-in-one bot that\'s made from the Discord.JS api!') .addField('Contributors', 'Andrew Lee (Founder of this project)\nOfficialRain (Raina) (Uptime Command)\njtsshieh (Command Handler)') - .setFooter('© Copyright 2017-2020 Alee Productions, Licensed with GPL-3.0') + .setFooter('© Copyright 2017-2021 Alee Productions, Licensed with GPL-3.0') .setColor('#1fd619'); await message.channel.send({embed}); }; diff --git a/commands/addquote.js b/commands/addquote.js index 7b7221e..6334470 100644 --- a/commands/addquote.js +++ b/commands/addquote.js @@ -1,7 +1,7 @@ /** ************************************** * * AddQuote: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,34 +17,74 @@ * along with this program. If not, see . * * *************************************/ +const mongo = require('../plugins/mongo'); +const quoteSchema = require('../schema/quote-schema'); module.exports.run = async (client, message, args) => { - /* - const moment = require('moment'); - const log = message => { +/* + let authorMessage; + let authorImageMessage; + let quoteMessage; + let yearMessage;*/ - console.log(`[${moment().format('YYYY-MM-DD HH:mm:ss')}] ${message}`); + if (!['242775871059001344'].includes(message.author.id)) return message.reply('**This command is disabled due to a new system being implemented.**'); + //await message.author.send('Welcome to AleeBot\'s quoting system!\nThis process will be easy.'); - }; - const fs = require('fs'); - if(!args[0]) return message.reply(`Usage: ab:addquote [author] [authorImage] [quote] [year]`); + if (!args.length) return message.reply("Error: Did not provide more context (message will be replaced eventually)"); - let quotes = JSON.parse(fs.readFileSync("./storage/quotes.json", "utf8")); + await mongo().then(async (mongoose) => { + try { + await new quoteSchema({ + author: args[0], + authorImage: args[1], + quote: args[2], + year: args[3] - quotes = { - author: args[0], - authorImage: args[1], - quote: args[2], - year: args[3] - }; + }).save() + } finally { + await mongoose.connection.close(); + message.reply('Added this quote to the database...'); + } + }) - fs.writeFile("./storage/quotes.json", JSON.stringify(quotes), (err) =>{ - if (err) log(err) - }) +/* + let quoteState = {}; + let state = quoteState[message.author.id]; - message.reply(`You just added a new quote!`); - log(`[i] A quote has been added to quotes.json...`) + if (message.content.toLowerCase() === "q"){ + await message.author.send("Process has been cancelled"); + state = null; + } else { + switch (state) { + case 1: + await message.author.send('Enter the author\'s name'); + authorMessage = message.content; + console.log(authorMessage); + state = 2; + break; + case 2: + await message.author.send('author url here'); + authorImageMessage = message.content; + console.log(authorImageMessage); + state = 3; + break; + case 3: + await message.author.send('quote here'); + quoteMessage = message.content; + console.log(quoteMessage); + state = 4; + break; + case 4: + await message.author.send('year here'); + yearMessage = message.content; + console.log(yearMessage); + state = 5; + break; + case 5: + await message.author.send('process complete'); + state = null; + break; + } */ - message.reply('Command is broken for now'); }; exports.conf = { diff --git a/commands/ask.js b/commands/ask.js index 3b1efd5..1dd5edd 100644 --- a/commands/ask.js +++ b/commands/ask.js @@ -1,7 +1,7 @@ /** ************************************** * * Ask: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/commands/avatarurl.js b/commands/avatarurl.js index 7c50e2c..2c796f4 100644 --- a/commands/avatarurl.js +++ b/commands/avatarurl.js @@ -1,7 +1,7 @@ /** ************************************** * * avatarurl: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,11 +18,17 @@ * * *************************************/ module.exports.run = async (client, message) => { - message.reply(message.author.avatarURL({ dynamic: true, format: 'png', size: 1024 })); + if(!message.mentions.users.first()) { + message.reply(message.author.avatarURL({ dynamic: true, format: 'png', size: 1024 })); + } else { + let targetMember; + targetMember = message.mentions.users.first(); + message.reply(targetMember.avatarURL({ dynamic: true, format: 'png', size: 1024 })) + } }; exports.conf = { - aliases: [], + aliases: ['pic'], guildOnly: false, }; exports.help = { diff --git a/commands/ban.js b/commands/ban.js index 3c8a809..2c4950a 100644 --- a/commands/ban.js +++ b/commands/ban.js @@ -1,7 +1,7 @@ /** ************************************** * * Ban: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ module.exports.run = async (client, message, args) => { if (!message.guild.member(client.user).hasPermission('BAN_MEMBERS')) return message.reply('Uhh... I don\'t have permission to ban members.'); const member = message.mentions.members.first(); if (!member) return message.reply('Uhh... Please mention a member first.'); - await member.ban(`Banned by ${message.author.tag} Reason: ` + mreason); + await member.ban(`Banned by ${message.author.tag}. Reason: ${mreason}.`); const embed = new Discord.MessageEmbed() .setTitle('User Banned!') .setColor('#1fd619') diff --git a/commands/eval.js b/commands/eval.js index ef8fc97..9ace7bf 100644 --- a/commands/eval.js +++ b/commands/eval.js @@ -1,7 +1,7 @@ /** ************************************** * * Eval: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions & jtsshieh + PokeWorld + * Copyright (C) 2017-2021 Alee Productions & jtsshieh + PokeWorld * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/commands/git.js b/commands/git.js index ed98ebf..4f44edb 100644 --- a/commands/git.js +++ b/commands/git.js @@ -1,7 +1,7 @@ /** ************************************** * * Git: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/commands/help.js b/commands/help.js index 36d4630..2dafe0c 100644 --- a/commands/help.js +++ b/commands/help.js @@ -1,7 +1,7 @@ /** ************************************** * * Help: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -43,7 +43,7 @@ module.exports.run = async (client, message) => { .setAuthor('AleeBot ' + require('../storage/settings.json').abVersion + ` Help and on ${client.guilds.cache.size} servers`, client.user.avatarURL()) .setDescription('Every command you input into AleeBot is `' + prefix + '`') .setColor('#1fd619') - .setFooter('© Copyright 2017-2020 Alee Productions, Licensed with GPL-3.0'); + .setFooter('© Copyright 2017-2021 Alee Productions, Licensed with GPL-3.0'); categories.forEach(function(x) { let cat = ''; diff --git a/commands/info.js b/commands/info.js index 3de7ecd..4476ac0 100644 --- a/commands/info.js +++ b/commands/info.js @@ -1,7 +1,7 @@ /** ************************************** * * Info: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,14 +20,16 @@ module.exports.run = async (client, message) => { const Discord = require('discord.js'); const os = require('os'); + const mongoose = require('mongoose'); const embed = new Discord.MessageEmbed() .setTitle('Information on AleeBot\'s Host') .addField('OS Hostname: ', os.hostname(), true) .addField('NodeJS Version: ', process.versions.node, true) .addField('OS Platform: ', os.platform(), true) .addField('OS Version: ', os.release(), true) + .addField('Mongoose Version:', mongoose.version, true) .setColor('#1fd619'); - message.channel.send({embed}); + await message.channel.send({embed}); }; exports.conf = { diff --git a/commands/interrogate.js b/commands/interrogate.js index 54e8cb2..1b9b97b 100644 --- a/commands/interrogate.js +++ b/commands/interrogate.js @@ -1,7 +1,7 @@ /** ************************************** * * Interrogate: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/commands/invite.js b/commands/invite.js index e6f538f..a12cff4 100644 --- a/commands/invite.js +++ b/commands/invite.js @@ -1,7 +1,7 @@ /** ************************************** * * Invite: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,7 +17,13 @@ * along with this program. If not, see . * * *************************************/ -module.exports.run = async (client, message) => { +module.exports.run = (client, message) => { + const disbut = require('discord-buttons')(client); + let button = new disbut.MessageButton() + .setLabel('My First Button!') //default: NO_LABEL_PROVIDED + .setID('click_to_function') //note: if you use the style "url" you must provide url using .setURL('https://example.com') + .setDisabled(); //disables the button | default: false + message.channel.send({embed: { color: 2086425, title: 'Invite Command', @@ -31,7 +37,7 @@ module.exports.run = async (client, message) => { }, ], }, - }); + }, button); // message.channel.send('Want AleeBot in your server? Here\'s the link: https://discordapp.com/api/oauth2/authorize?client_id=282547024547545109&permissions=2080375863&scope=bot'); }; diff --git a/commands/jail.js b/commands/jail.js index 432f60a..a82e1b2 100644 --- a/commands/jail.js +++ b/commands/jail.js @@ -1,7 +1,7 @@ /** ************************************** * * Jail: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/commands/kick.js b/commands/kick.js index 3cbaaf8..79cd964 100644 --- a/commands/kick.js +++ b/commands/kick.js @@ -1,7 +1,7 @@ /** ************************************** * * Kick: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ module.exports.run = async (client, message, args) => { if (!message.guild.member(client.user).hasPermission('KICK_MEMBERS')) return message.reply('Uhh... I don\'t have permission to kick members.'); const member = message.mentions.members.first(); if (!member) return message.reply('Uhh... Please mention a member first.'); - member.kick(`Kicked by: ${message.author.tag} Reason: ` + mreason); + await member.kick(`Kicked by: ${message.author.tag}. Reason: ${mreason}.`); const embed = new Discord.MessageEmbed() .setTitle('User Kicked!') .setColor('#1fd619') diff --git a/commands/leaveguild.js b/commands/leaveguild.js index 5108436..146512c 100644 --- a/commands/leaveguild.js +++ b/commands/leaveguild.js @@ -1,7 +1,7 @@ /** ************************************** * * LeaveGuild: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/commands/nick.js b/commands/nick.js index f65bf74..d87d57e 100644 --- a/commands/nick.js +++ b/commands/nick.js @@ -1,7 +1,7 @@ /** ************************************** * * Nick: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/commands/ping.js b/commands/ping.js index b8d2779..d66330d 100644 --- a/commands/ping.js +++ b/commands/ping.js @@ -1,7 +1,7 @@ /** ************************************** * * Ping: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/commands/poweroff.js b/commands/poweroff.js index 8067c5f..700005a 100644 --- a/commands/poweroff.js +++ b/commands/poweroff.js @@ -1,7 +1,7 @@ /** ************************************** * * Poweroff: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/commands/purge.js b/commands/purge.js index 97c1be6..bc6e727 100644 --- a/commands/purge.js +++ b/commands/purge.js @@ -1,7 +1,7 @@ /** ************************************** * * Purge: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/commands/quote.js b/commands/quote.js index 149fe37..69e810a 100644 --- a/commands/quote.js +++ b/commands/quote.js @@ -1,7 +1,7 @@ /** ************************************** * * Quote: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,17 +17,49 @@ * along with this program. If not, see . * * *************************************/ -module.exports.run = async (client, message) => { +const mongo = require('../plugins/mongo'); +const quoteSchema = require('../schema/quote-schema'); +module.exports.run = async (client, message, args) => { + if (!['242775871059001344'].includes(message.author.id)) return message.reply('**This command is disabled due to a new system being implemented.**'); const Discord = require('discord.js'); let NewQuote; + let quo; + + let quoId; + let quoAuthor; + let quoAuthorImage; + let quoQuote; + let quoYear; + + if (args) { + await mongo().then(async (mongoose) => { + try { + const quote = await quoteSchema.findOne({quoteID: "1", author: quoAuthor, authorImage: quoAuthorImage, quote: quoQuote, year: quoYear}) + /*const embed = new Discord.MessageEmbed() + .setAuthor(quoAuthor, quoAuthorImage) + .setDescription(quoQuote) + .setColor('#1fd619') + .setFooter('- ' + quoYear); + + await message.channel.send({embed});*/ + console.log(quote); + } finally { + await mongoose.connection.close(); + } + }) + } else { + + } + + /* function GetNewQuote(quoteNum = -1) { NewQuote = new Discord.MessageEmbed(); - let quo = require('../storage/quotes.json').quotes; + let quo = require('../storage/quotes.json').quotes - if (quoteNum == -1) { + if (quoteNum === -1) { quoteNum = Math.floor(Math.random() * 1000) % quo.length; quo=quo[quoteNum]; } @@ -42,14 +74,14 @@ module.exports.run = async (client, message) => { NewQuote.setColor('#1fd619'); NewQuote.setDescription(quote); NewQuote.setFooter('- ' + year); - NewQuote.setURL(url); + //NewQuote.setURL(url); return NewQuote; } const newquote = GetNewQuote(); message.reply('Alright, here\'s your quote.'); - message.channel.send(newquote); + await message.channel.send(newquote);*/ }; exports.conf = { diff --git a/commands/say.js b/commands/say.js index fe17b42..9ef9707 100644 --- a/commands/say.js +++ b/commands/say.js @@ -1,7 +1,7 @@ /** ************************************** * * Say: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/commands/serverinfo.js b/commands/serverinfo.js new file mode 100644 index 0000000..9ccb7c2 --- /dev/null +++ b/commands/serverinfo.js @@ -0,0 +1,51 @@ +/** ************************************** + * + * ServerInfo: Command for AleeBot + * Copyright (C) 2017-2021 Alee Productions + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * *************************************/ +module.exports.run = async (client, message) => { + const Discord = require('discord.js'); + const listedChannels = []; + let memberCountNoBots = message.guild.members.cache.filter(member => !member.user.bot).size; + const embed = new Discord.MessageEmbed() + .setAuthor(message.guild.name, message.guild.iconURL()) + .setDescription('Server Information') + .setThumbnail(message.guild.iconURL()) + .addField('Server Name:', message.guild.name) + .addField('Server ID:', message.guild.id) + .addField('Create At:', message.guild.createdAt.toUTCString()) + /*message.guild.channels.cacheType.forEach(channel => { + listedChannels.push(channel) + })*/ + //.addField('Channels', `${listedChannels.join('\n')}`) + //.addField('Total Channels', message.guild.channelCountMode) + .addField('Total Members (with bots)', message.guild.memberCount) + .addField('Total Members (without bots)', memberCountNoBots) + .setColor('#1fd619'); + await message.channel.send({embed}); +}; + +exports.conf = { + aliases: ['sinfo'], + guildOnly: false, +}; +exports.help = { + name: 'serverinfo', + description: 'Tells your info.', + usage: 'serverinfo', + category: '- Information Commands', +}; diff --git a/commands/setlogchannel.js b/commands/setlogchannel.js new file mode 100644 index 0000000..902a210 --- /dev/null +++ b/commands/setlogchannel.js @@ -0,0 +1,63 @@ +/** ************************************** + * + * SetLogChannel: Command for AleeBot + * Copyright (C) 2017-2021 Alee Productions + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * *************************************/ +const mongo = require('../plugins/mongo'); +const logSchema = require('../schema/logging-schema'); +module.exports.run = async (client, message) => { + //This will be replaced in the future possibly + if (!message.member.permissions.has('MANAGE_GUILD')) return message.reply('It looks like that you can\'t manage this server.'); + const channel = await message.mentions.channels.first().id; + const cache = {} + + if (!channel) return message.reply('I cannot find that channel, please specify...'); + + cache[message.guild.id] = channel + + await mongo().then(async (mongoose) => { + try { + await logSchema.findOneAndUpdate( + { + _id: message.guild.id, + }, + { + _id: message.guild.id, + logChannel: channel + }, + { + upsert: true + } + ) + } finally { + await mongoose.connection.close(); + } + }) + + await message.reply(`Logging channel has been set to <#${channel}>`); +}; + +exports.conf = { + aliases: [], + guildOnly: false, +}; +exports.help = { + name: 'setlogchannel', + description: 'Set the log channel.', + usage: 'setlogchannel [channel id]', + category: '- Moderation Commands', +}; diff --git a/commands/setprefix.js b/commands/setprefix.js index edb42c9..2bea4bc 100644 --- a/commands/setprefix.js +++ b/commands/setprefix.js @@ -1,7 +1,7 @@ /** ************************************** * * SetPrefix: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/commands/setup.js b/commands/setup.js deleted file mode 100644 index bf6a14c..0000000 --- a/commands/setup.js +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************** - * - * Setup: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * *************************************/ - -module.exports.run = async (client, message) => { - if (!['242775871059001344', message.guild.owner.user.id].includes(message.author.id)) return message.reply(':warning: You must be a server owner or be the creator of the bot to access this command.'); - message.reply('Look at your DMs.'); - //message.reply("This feature is coming soon. Stay tuned!"); - const Discord = require('discord.js'); - const setupEmbed = new Discord.MessageEmbed() - .setTitle('AleeBot Setup', client.user.avatarURL()) - .setDescription('Select the options') - .addField('Logs', 'channelid', true) - // .addField('Chat Logs', 'placeholder', true) - // .addField('Chat Logs', 'placeholder', true); - - message.author.send(setupEmbed); -}; - -exports.conf = { - aliases: [], - guildOnly: false, -}; -exports.help = { - name: 'setup', - description: 'Setting up AleeBot.', - usage: 'setup', - category: '- Settings Commands', -}; \ No newline at end of file diff --git a/commands/slowdown.js b/commands/slowdown.js index c9fc611..008ceb6 100644 --- a/commands/slowdown.js +++ b/commands/slowdown.js @@ -1,7 +1,7 @@ /** ************************************** * * Slowdown: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/commands/suggest.js b/commands/suggest.js index 3adaa31..3a8e34a 100644 --- a/commands/suggest.js +++ b/commands/suggest.js @@ -1,7 +1,7 @@ /** ************************************** * * Suggest: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/commands/suggestfeature.js b/commands/suggestfeature.js index 8b8b3c7..28fc01a 100644 --- a/commands/suggestfeature.js +++ b/commands/suggestfeature.js @@ -1,7 +1,7 @@ /**************************************** * * SuggestFeature: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/commands/uptime.js b/commands/uptime.js index 90afc81..4753f70 100644 --- a/commands/uptime.js +++ b/commands/uptime.js @@ -1,7 +1,7 @@ /** ************************************** * * Uptime: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions & OfficialRain + * Copyright (C) 2017-2021 Alee Productions & OfficialRain * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/commands/userinfo.js b/commands/userinfo.js index f12454a..d90f7bf 100644 --- a/commands/userinfo.js +++ b/commands/userinfo.js @@ -1,7 +1,7 @@ /** ************************************** * * UserInfo: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/deprecated/balance.js b/deprecated/balance.js index ca32081..bf7618c 100644 --- a/deprecated/balance.js +++ b/deprecated/balance.js @@ -1,7 +1,7 @@ /** ************************************** * * Balance: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/deprecated/buy.js b/deprecated/buy.js index 25f2589..98d4fcf 100644 --- a/deprecated/buy.js +++ b/deprecated/buy.js @@ -1,7 +1,7 @@ /** ************************************** * * Buy: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/deprecated/daily.js b/deprecated/daily.js index c0f04f9..4a38f26 100644 --- a/deprecated/daily.js +++ b/deprecated/daily.js @@ -1,7 +1,7 @@ /** ************************************** * * Daily: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/deprecated/pay.js b/deprecated/pay.js index bc27a4b..42e0f28 100644 --- a/deprecated/pay.js +++ b/deprecated/pay.js @@ -1,7 +1,7 @@ /** ************************************** * * Pay: Command for AleeBot - * Copyright (C) 2017-2020 Alee Productions + * Copyright (C) 2017-2021 Alee Productions * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/deprecated/setup.js b/deprecated/setup.js new file mode 100644 index 0000000..a86f850 --- /dev/null +++ b/deprecated/setup.js @@ -0,0 +1,45 @@ +/**************************************** + * + * Setup: Command for AleeBot + * Copyright (C) 2017-2021 Alee Productions + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * *************************************/ + +module.exports.run = async (client, message) => { + if (!['242775871059001344', message.guild.owner.user.id].includes(message.author.id)) return message.reply(':warning: You must be a server owner or be the creator of the bot to access this command.'); + message.reply('Look at your DMs.'); + //message.reply("This feature is coming soon. Stay tuned!"); + const Discord = require('discord.js'); + const setupEmbed = new Discord.MessageEmbed() + .setTitle('AleeBot Setup', client.user.avatarURL()) + .setDescription('Select the options') + .addField('Logs', 'channelid', true) + // .addField('Chat Logs', 'placeholder', true) + // .addField('Chat Logs', 'placeholder', true); + + message.author.send(setupEmbed); +}; + +exports.conf = { + aliases: [], + guildOnly: false, +}; +exports.help = { + name: 'setup', + description: 'Setting up AleeBot.', + usage: 'setup', + category: '- Settings Commands', +}; \ No newline at end of file diff --git a/package.json b/package.json index 7d8ac45..5071221 100644 --- a/package.json +++ b/package.json @@ -21,18 +21,19 @@ "blessed": "^0.1.81", "colors": "^1.3.0", "dblapi.js": "^2.0.0", - "discord.js": "^12.2.0", + "discord-buttons": "^2.4.1", + "discord.js": "^12.5.3", "eslint": "^7.1.0", + "express": "^4.17.1", "fs": "0.0.1-security", "git-last-commit": "^0.3.0", "i18next": "^19.4.4", "moment": "^2.21.0", + "mongoose": "^5.11.8", "node-opus": "^0.3.0", "os": "^0.1.1", "parse-ms": "^1.0.1", "readline": "^1.3.0", - "sequelize": "^6.2.3", - "sqlite3": "^5.0.0", "ytdl-core": "^0.20.4" }, "devDependencies": { diff --git a/plugins/mongo.js b/plugins/mongo.js new file mode 100644 index 0000000..0102aab --- /dev/null +++ b/plugins/mongo.js @@ -0,0 +1,10 @@ +const mongoose = require('mongoose'); +const { mongoPath } = require('../tokens.json'); + +module.exports = async () => { + await mongoose.connect(mongoPath, { + useNewUrlParser: true, + useUnifiedTopology: true, + }); + return mongoose; +} \ No newline at end of file diff --git a/schema/logging-schema.js b/schema/logging-schema.js new file mode 100644 index 0000000..339c7f7 --- /dev/null +++ b/schema/logging-schema.js @@ -0,0 +1,13 @@ +const mongoose = require('mongoose') + +const reqString = { + type: String, + required: true +} + +const loggingSchema = mongoose.Schema({ + _id: reqString, + logChannel: reqString +}) + +module.exports = mongoose.model('logging', loggingSchema) \ No newline at end of file diff --git a/schema/quote-schema.js b/schema/quote-schema.js new file mode 100644 index 0000000..d1c7db8 --- /dev/null +++ b/schema/quote-schema.js @@ -0,0 +1,17 @@ +const mongoose = require('mongoose'); + +const reqString = { + type: String, + required: true +} + +const quoteSchema = mongoose.Schema({ + quoteID: reqString, + author: reqString, + authorImage: reqString, + quote: reqString, + year: reqString + +}) + +module.exports = mongoose.model('quote', quoteSchema) \ No newline at end of file diff --git a/storage/quotes.json b/storage/quotes.json deleted file mode 100644 index 78c76a4..0000000 --- a/storage/quotes.json +++ /dev/null @@ -1,260 +0,0 @@ -{ - "quotes" :[ - { - "id": 0, - "author": "Victor Tran", - "authorImage": "https://yt3.ggpht.com/-Iuf1v4-SSSM/AAAAAAAAAAI/AAAAAAAAAAA/89IYeQw--wU/photo.jpg", - "quote": "A letter says a whole video!", - "year": "2017", - "url": "https://cdn.discordapp.com/attachments/278874966542385152/280566273992032258/Screenshot_20170213-160944.png" - }, - { - "id": 1, - "author" : "Prince Hamlet: William Shakespeare", - "authorImage" : "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a2/Shakespeare.jpg/468px-Shakespeare.jpg", - "quote" : "To be, or not to be, that is the question", - "year" : "circa. 1600", - "url" : "https://en.wikipedia.org/wiki/To_be,_or_not_to_be" - }, - { - "id": 2, - "author" : "Diana Adams / Mitsubishi Mirage", - "authorImage" : "https://yt3.ggpht.com/-tQLg1M-3org/AAAAAAAAAAI/AAAAAAAAAAA/-kkOvupMHXQ/s88-c-k-no-mo-rj-c0xffffff/photo.jpg", - "quote" : "Dialing 000...\nNOOO!!!", - "year" : "2017", - "url" : "https://youtu.be/jDy57c7Y-4A?t:11m52s" - }, - { - "id": 3, - "author" : "Diana Adams / Mitsubishi Mirage", - "authorImage" : "https://yt3.ggpht.com/-tQLg1M-3org/AAAAAAAAAAI/AAAAAAAAAAA/-kkOvupMHXQ/s88-c-k-no-mo-rj-c0xffffff/photo.jpg", - "quote" : "You'd have a crash by now!\nPardon?", - "year" : "2017", - "url" : "https://youtu.be/jDy57c7Y-4A?t:15m5s" - }, - { - "id": 4, - "author" : "Ivoponop Pena", - "authorImage" : "https://yt3.ggpht.com/-hZJxXIFsfB8/AAAAAAAAAAI/AAAAAAAAAAA/c_mjVjQWvTw/s48-c-k-no-mo-rj-c0xffffff/photo.jpg", - "quote" : "i buy tablets for the bubble plastic", - "year" : "2016", - "url" : "https://www.youtube.com/watch?v:AqFDn0TxwH4" - }, - { - "id": 5, - "author" : "The Mill on the Floss: George Eliot", - "authorImage" : "https://upload.wikimedia.org/wikipedia/commons/8/81/George_Eliot_at_30_by_François_D%27Albert_Durade.jpg", - "quote" : "Don't judge a book by its cover", - "year" : "1860", - "url" : "https://en.wikipedia.org/wiki/Don't_judge_a_book_by_its_cover" - }, - { - "id": 6, - "author" : "tostoday", - "authorImage" : "https://yt3.ggpht.com/-gNRclMiHzN4/AAAAAAAAAAI/AAAAAAAAAAA/BNEDEUakd4A/s48-c-k-no-mo-rj-c0xffffff/photo.jpg", - "quote" : "I don't know why but Visopsys sounds like a medical condition", - "year" : "circa. 2015", - "url" : "https://www.youtube.com/watch?v:5T-vEZeY2v0" - }, - { - "id": 7, - "author" : "Diana Adams", - "authorImage" : "https://yt3.ggpht.com/-tQLg1M-3org/AAAAAAAAAAI/AAAAAAAAAAA/-kkOvupMHXQ/s88-c-k-no-mo-rj-c0xffffff/photo.jpg", - "quote" : "4 × 1 000 000!? 4 000 000! It's not that hard...", - "year" : "2014", - "url" : "https://youtu.be/5T-vEZeY2v0?t:9m28s" - }, - { - "id": 8, - "author" : "Victor Tran", - "authorImage" : "https://yt3.ggpht.com/-Iuf1v4-SSSM/AAAAAAAAAAI/AAAAAAAAAAA/89IYeQw--wU/photo.jpg", - "quote" : "Yes! I'm not *just* a blue happy face!", - "year" : "2016", - "url" : "https://youtu.be/2E21oad5pWQ" - }, - { - "id": 9, - "author" : "ItsDeckyah", - "authorImage" : "https://yt3.ggpht.com/-t70ZI-25A1k/AAAAAAAAAAI/AAAAAAAAAAA/uGrVakleFIM/s48-c-k-no-mo-rj-c0xffffff/photo.jpg", - "quote" : "Always remember, don't let those who are bullying you ruin your life, they are out to do just that. And that's probably all they'll do their whole lives", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 10, - "author" : "Mighty_Eagle073", - "authorImage" : "https://yt3.ggpht.com/-Q5IvX3eEGl8/AAAAAAAAAAI/AAAAAAAAAAA/LspLd8v-PR8/s100-c-k-no-mo-rj-c0xffffff/photo.jpg", - "quote" : "Spamming : Damning", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 11, - "author" : "Nibble", - "authorImage" : "https://yt3.ggpht.com/-SUPNlJ8a7qA/AAAAAAAAAAI/AAAAAAAAAAA/R_I4z7057_w/s100-c-k-no-mo-rj-c0xffffff/photo.jpg", - "quote" : "AUTO CORRECF!!!", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 12, - "author" : "Alee", - "authorImage" : "https://cdn.discordapp.com/avatars/242775871059001344/b8a995d836bbb8529ae35dc12c2289de.png?size:2048", - "quote" : "IS THERE A GOOOOOGALIE HERE!!!!", - "year" : "2014", - "url" : "https://youtu.be/Ap6fUlMx90A?t:2m30s" - }, - { - "id": 13, - "author" : "143malliw", - "authorImage" : "https://yt3.ggpht.com/-SUPNlJ8a7qA/AAAAAAAAAAI/AAAAAAAAAAA/R_I4z7057_w/s100-c-k-no-mo-rj-c0xffffff/photo.jpg", - "quote" : "but i can't write a quote, for I am the quote", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 14, - "author" : "AstralMod", - "authorImage" : "https://cdn.discordapp.com/avatars/282048599574052864/56d2d99bf763df5a05f5d157108edbdc.png?size:2048", - "quote" : "Welcome to the weekly chat chat!", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 15, - "author" : "AstralPhaser", - "authorImage" : "https://cdn.discordapp.com/avatars/230480971084988417/32f46a9671c6ceedc54b369ea73be178.png?size:2048", - "quote" : "Ok the shrimp is now on the barbie", - "year" : "2017", - "url" : "https://media.discordapp.net/attachments/277922530973581312/355882401546764289/d300-123-6379-orton-wp.png" - }, - { - "id": 16, - "author" : "Victor Tran", - "authorImage" : "https://yt3.ggpht.com/-Iuf1v4-SSSM/AAAAAAAAAAI/AAAAAAAAAAA/89IYeQw--wU/photo.jpg", - "quote" : ":joy: It's Cameron's Birthday!\nJoy!!!11!!111!!!!", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 17, - "author" : "Steve Jobs", - "authorImage" : "http://media.syracuse.com/news/photo/2011/01/9177328-large.jpg", - "quote" : "It's really hard to design products by focus groups. A lot of times, people don't know what they want until you show it to them.", - "year" : "1998", - "url" : "https://www.huffingtonpost.com/gregory-ciotti/why-steve-jobs-didnt-list_b_5628355.html" - }, - { - "id": 18, - "author" : "arencllc", - "authorImage" : "https://cdn.discordapp.com/avatars/191290329985581069/e4d6ee5c8836f5c79c51611d0ba536eb.png?size:2048", - "quote" : "Coding for uwp is as hard as using a UWP program.", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 19, - "author" : "FloppyDiskDrive", - "authorImage" : "https://cdn.discordapp.com/avatars/228271067821506560/a_0122b441972a6edfa6201ee871fad2a7.gif?size:2048", - "quote" : "Victor would be a champ at synchronized thinking.", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 20, - "author" : "Tembot", - "authorImage" : "https://cdn.discordapp.com/avatars/361202413165608962/fba99664eb0aeec8a47db3a74a2029d5.png?size:2048", - "quote" : "Why are u stocking me", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 21, - "author" : "PieLover12", - "authorImage" : "https://cdn.discordapp.com/avatars/344630031303311371/d84ae603ee53a5b54f7b78bcb4f733f2.png?size:2048", - "quote" : "DIE YOU LOOK LIKE TINY GIRL", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 22, - "author" : "AstralPhaser", - "authorImage" : "https://cdn.discordapp.com/avatars/230480971084988417/32f46a9671c6ceedc54b369ea73be178.png?size:2048", - "quote" : "anyway, I've gotta go now, I'll be back in 3 \"year\"s", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 23, - "author" : "Victor Tran", - "authorImage" : "https://yt3.ggpht.com/-Iuf1v4-SSSM/AAAAAAAAAAI/AAAAAAAAAAA/89IYeQw--wU/photo.jpg", - "quote" : "Zero electric cars means they don't sell electric cards here", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 24, - "author" : "Victor Tran", - "authorImage" : "https://yt3.ggpht.com/-Iuf1v4-SSSM/AAAAAAAAAAI/AAAAAAAAAAA/89IYeQw--wU/photo.jpg", - "quote" : "Unless you're living in like Denland or something", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 25, - "author" : "Victor Tran", - "authorImage" : "https://yt3.ggpht.com/-Iuf1v4-SSSM/AAAAAAAAAAI/AAAAAAAAAAA/89IYeQw--wU/photo.jpg", - "quote" : "[goes and cries in a corner]\nWAAA\nWAAAAAAAAAA\nWAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", - "year" : "2017", - "url" : "https://cdn.discordapp.com/attachments/373884824034869249/374564169678061568/unknown.png" - }, - { - "id": 26, - "author" : "OSFirstTimer", - "authorImage" : "https://yt3.ggpht.com/-tQLg1M-3org/AAAAAAAAAAI/AAAAAAAAAAA/-kkOvupMHXQ/s88-c-k-no-mo-rj-c0xffffff/photo.jpg", - "quote" : "The most popular version of Linux ever called Abuncho. Abuncho 12.10.", - "year" : "2012", - "url" : "https://youtu.be/PgGbZfR6Vec?t:6s" - }, - { - "id": 27, - "author" : "Vat19", - "authorImage" : "https://s3.amazonaws.com/images1.vat19.com/branding/vat19-mobile-logo-2x.png", - "quote" : "VAAAAT NINETEEEEEEN! dot com ._.", - "year" : "2017", - "url" : "https://youtu.be/tnvcxBns_uQ?t:3m17s" - }, - { - "id": 28, - "author" : "Steve Jobs", - "authorImage" : "http://media.syracuse.com/news/photo/2011/01/9177328-large.jpg", - "quote" : "Sometimes life is going to hit you in the head with a brick. Don't lose faith.", - "year" : "circa. 2000", - "url" : "https://www.example.com/" - }, - { - "id": 29, - "author" : "Alee", - "authorImage" : "https://cdn.discordapp.com/avatars/242775871059001344/b9814f1117027993d46cd5ae9ce2dd48.png?size=2048", - "quote" : "Victor finally swore\nAnd I was like \"HOLY SHIT\"", - "year" : "2018", - "url" : "https://www.example.com/" - }, - { - "id": 30, - "author" : "Zac Bowden", - "authorImage" : "https://pbs.twimg.com/profile_images/963331874503430144/NTv0Dlaj_400x400.jpg", - "quote" : "We can happily move on to Windows 11, Windows 10 is now done and dusted", - "year" : "2018", - "url" : "https://www.example.com/" - }, - { - "id": 31, - "author" : "Victor Tran", - "authorImage" : "https://yt3.ggpht.com/-Iuf1v4-SSSM/AAAAAAAAAAI/AAAAAAAAAAA/89IYeQw--wU/photo.jpg", - "quote" : "WHAT THE - IS THAT\nMAN I JUST CAME BACK TO MY ROOM\nAND THEN I SEE YOU WITH A GUY IN IT", - "year" : "2018", - "url" : "https://www.example.com/" - } - ] -} diff --git a/storage/quotes.json.bak b/storage/quotes.json.bak deleted file mode 100644 index 78c76a4..0000000 --- a/storage/quotes.json.bak +++ /dev/null @@ -1,260 +0,0 @@ -{ - "quotes" :[ - { - "id": 0, - "author": "Victor Tran", - "authorImage": "https://yt3.ggpht.com/-Iuf1v4-SSSM/AAAAAAAAAAI/AAAAAAAAAAA/89IYeQw--wU/photo.jpg", - "quote": "A letter says a whole video!", - "year": "2017", - "url": "https://cdn.discordapp.com/attachments/278874966542385152/280566273992032258/Screenshot_20170213-160944.png" - }, - { - "id": 1, - "author" : "Prince Hamlet: William Shakespeare", - "authorImage" : "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a2/Shakespeare.jpg/468px-Shakespeare.jpg", - "quote" : "To be, or not to be, that is the question", - "year" : "circa. 1600", - "url" : "https://en.wikipedia.org/wiki/To_be,_or_not_to_be" - }, - { - "id": 2, - "author" : "Diana Adams / Mitsubishi Mirage", - "authorImage" : "https://yt3.ggpht.com/-tQLg1M-3org/AAAAAAAAAAI/AAAAAAAAAAA/-kkOvupMHXQ/s88-c-k-no-mo-rj-c0xffffff/photo.jpg", - "quote" : "Dialing 000...\nNOOO!!!", - "year" : "2017", - "url" : "https://youtu.be/jDy57c7Y-4A?t:11m52s" - }, - { - "id": 3, - "author" : "Diana Adams / Mitsubishi Mirage", - "authorImage" : "https://yt3.ggpht.com/-tQLg1M-3org/AAAAAAAAAAI/AAAAAAAAAAA/-kkOvupMHXQ/s88-c-k-no-mo-rj-c0xffffff/photo.jpg", - "quote" : "You'd have a crash by now!\nPardon?", - "year" : "2017", - "url" : "https://youtu.be/jDy57c7Y-4A?t:15m5s" - }, - { - "id": 4, - "author" : "Ivoponop Pena", - "authorImage" : "https://yt3.ggpht.com/-hZJxXIFsfB8/AAAAAAAAAAI/AAAAAAAAAAA/c_mjVjQWvTw/s48-c-k-no-mo-rj-c0xffffff/photo.jpg", - "quote" : "i buy tablets for the bubble plastic", - "year" : "2016", - "url" : "https://www.youtube.com/watch?v:AqFDn0TxwH4" - }, - { - "id": 5, - "author" : "The Mill on the Floss: George Eliot", - "authorImage" : "https://upload.wikimedia.org/wikipedia/commons/8/81/George_Eliot_at_30_by_François_D%27Albert_Durade.jpg", - "quote" : "Don't judge a book by its cover", - "year" : "1860", - "url" : "https://en.wikipedia.org/wiki/Don't_judge_a_book_by_its_cover" - }, - { - "id": 6, - "author" : "tostoday", - "authorImage" : "https://yt3.ggpht.com/-gNRclMiHzN4/AAAAAAAAAAI/AAAAAAAAAAA/BNEDEUakd4A/s48-c-k-no-mo-rj-c0xffffff/photo.jpg", - "quote" : "I don't know why but Visopsys sounds like a medical condition", - "year" : "circa. 2015", - "url" : "https://www.youtube.com/watch?v:5T-vEZeY2v0" - }, - { - "id": 7, - "author" : "Diana Adams", - "authorImage" : "https://yt3.ggpht.com/-tQLg1M-3org/AAAAAAAAAAI/AAAAAAAAAAA/-kkOvupMHXQ/s88-c-k-no-mo-rj-c0xffffff/photo.jpg", - "quote" : "4 × 1 000 000!? 4 000 000! It's not that hard...", - "year" : "2014", - "url" : "https://youtu.be/5T-vEZeY2v0?t:9m28s" - }, - { - "id": 8, - "author" : "Victor Tran", - "authorImage" : "https://yt3.ggpht.com/-Iuf1v4-SSSM/AAAAAAAAAAI/AAAAAAAAAAA/89IYeQw--wU/photo.jpg", - "quote" : "Yes! I'm not *just* a blue happy face!", - "year" : "2016", - "url" : "https://youtu.be/2E21oad5pWQ" - }, - { - "id": 9, - "author" : "ItsDeckyah", - "authorImage" : "https://yt3.ggpht.com/-t70ZI-25A1k/AAAAAAAAAAI/AAAAAAAAAAA/uGrVakleFIM/s48-c-k-no-mo-rj-c0xffffff/photo.jpg", - "quote" : "Always remember, don't let those who are bullying you ruin your life, they are out to do just that. And that's probably all they'll do their whole lives", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 10, - "author" : "Mighty_Eagle073", - "authorImage" : "https://yt3.ggpht.com/-Q5IvX3eEGl8/AAAAAAAAAAI/AAAAAAAAAAA/LspLd8v-PR8/s100-c-k-no-mo-rj-c0xffffff/photo.jpg", - "quote" : "Spamming : Damning", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 11, - "author" : "Nibble", - "authorImage" : "https://yt3.ggpht.com/-SUPNlJ8a7qA/AAAAAAAAAAI/AAAAAAAAAAA/R_I4z7057_w/s100-c-k-no-mo-rj-c0xffffff/photo.jpg", - "quote" : "AUTO CORRECF!!!", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 12, - "author" : "Alee", - "authorImage" : "https://cdn.discordapp.com/avatars/242775871059001344/b8a995d836bbb8529ae35dc12c2289de.png?size:2048", - "quote" : "IS THERE A GOOOOOGALIE HERE!!!!", - "year" : "2014", - "url" : "https://youtu.be/Ap6fUlMx90A?t:2m30s" - }, - { - "id": 13, - "author" : "143malliw", - "authorImage" : "https://yt3.ggpht.com/-SUPNlJ8a7qA/AAAAAAAAAAI/AAAAAAAAAAA/R_I4z7057_w/s100-c-k-no-mo-rj-c0xffffff/photo.jpg", - "quote" : "but i can't write a quote, for I am the quote", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 14, - "author" : "AstralMod", - "authorImage" : "https://cdn.discordapp.com/avatars/282048599574052864/56d2d99bf763df5a05f5d157108edbdc.png?size:2048", - "quote" : "Welcome to the weekly chat chat!", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 15, - "author" : "AstralPhaser", - "authorImage" : "https://cdn.discordapp.com/avatars/230480971084988417/32f46a9671c6ceedc54b369ea73be178.png?size:2048", - "quote" : "Ok the shrimp is now on the barbie", - "year" : "2017", - "url" : "https://media.discordapp.net/attachments/277922530973581312/355882401546764289/d300-123-6379-orton-wp.png" - }, - { - "id": 16, - "author" : "Victor Tran", - "authorImage" : "https://yt3.ggpht.com/-Iuf1v4-SSSM/AAAAAAAAAAI/AAAAAAAAAAA/89IYeQw--wU/photo.jpg", - "quote" : ":joy: It's Cameron's Birthday!\nJoy!!!11!!111!!!!", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 17, - "author" : "Steve Jobs", - "authorImage" : "http://media.syracuse.com/news/photo/2011/01/9177328-large.jpg", - "quote" : "It's really hard to design products by focus groups. A lot of times, people don't know what they want until you show it to them.", - "year" : "1998", - "url" : "https://www.huffingtonpost.com/gregory-ciotti/why-steve-jobs-didnt-list_b_5628355.html" - }, - { - "id": 18, - "author" : "arencllc", - "authorImage" : "https://cdn.discordapp.com/avatars/191290329985581069/e4d6ee5c8836f5c79c51611d0ba536eb.png?size:2048", - "quote" : "Coding for uwp is as hard as using a UWP program.", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 19, - "author" : "FloppyDiskDrive", - "authorImage" : "https://cdn.discordapp.com/avatars/228271067821506560/a_0122b441972a6edfa6201ee871fad2a7.gif?size:2048", - "quote" : "Victor would be a champ at synchronized thinking.", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 20, - "author" : "Tembot", - "authorImage" : "https://cdn.discordapp.com/avatars/361202413165608962/fba99664eb0aeec8a47db3a74a2029d5.png?size:2048", - "quote" : "Why are u stocking me", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 21, - "author" : "PieLover12", - "authorImage" : "https://cdn.discordapp.com/avatars/344630031303311371/d84ae603ee53a5b54f7b78bcb4f733f2.png?size:2048", - "quote" : "DIE YOU LOOK LIKE TINY GIRL", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 22, - "author" : "AstralPhaser", - "authorImage" : "https://cdn.discordapp.com/avatars/230480971084988417/32f46a9671c6ceedc54b369ea73be178.png?size:2048", - "quote" : "anyway, I've gotta go now, I'll be back in 3 \"year\"s", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 23, - "author" : "Victor Tran", - "authorImage" : "https://yt3.ggpht.com/-Iuf1v4-SSSM/AAAAAAAAAAI/AAAAAAAAAAA/89IYeQw--wU/photo.jpg", - "quote" : "Zero electric cars means they don't sell electric cards here", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 24, - "author" : "Victor Tran", - "authorImage" : "https://yt3.ggpht.com/-Iuf1v4-SSSM/AAAAAAAAAAI/AAAAAAAAAAA/89IYeQw--wU/photo.jpg", - "quote" : "Unless you're living in like Denland or something", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "id": 25, - "author" : "Victor Tran", - "authorImage" : "https://yt3.ggpht.com/-Iuf1v4-SSSM/AAAAAAAAAAI/AAAAAAAAAAA/89IYeQw--wU/photo.jpg", - "quote" : "[goes and cries in a corner]\nWAAA\nWAAAAAAAAAA\nWAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", - "year" : "2017", - "url" : "https://cdn.discordapp.com/attachments/373884824034869249/374564169678061568/unknown.png" - }, - { - "id": 26, - "author" : "OSFirstTimer", - "authorImage" : "https://yt3.ggpht.com/-tQLg1M-3org/AAAAAAAAAAI/AAAAAAAAAAA/-kkOvupMHXQ/s88-c-k-no-mo-rj-c0xffffff/photo.jpg", - "quote" : "The most popular version of Linux ever called Abuncho. Abuncho 12.10.", - "year" : "2012", - "url" : "https://youtu.be/PgGbZfR6Vec?t:6s" - }, - { - "id": 27, - "author" : "Vat19", - "authorImage" : "https://s3.amazonaws.com/images1.vat19.com/branding/vat19-mobile-logo-2x.png", - "quote" : "VAAAAT NINETEEEEEEN! dot com ._.", - "year" : "2017", - "url" : "https://youtu.be/tnvcxBns_uQ?t:3m17s" - }, - { - "id": 28, - "author" : "Steve Jobs", - "authorImage" : "http://media.syracuse.com/news/photo/2011/01/9177328-large.jpg", - "quote" : "Sometimes life is going to hit you in the head with a brick. Don't lose faith.", - "year" : "circa. 2000", - "url" : "https://www.example.com/" - }, - { - "id": 29, - "author" : "Alee", - "authorImage" : "https://cdn.discordapp.com/avatars/242775871059001344/b9814f1117027993d46cd5ae9ce2dd48.png?size=2048", - "quote" : "Victor finally swore\nAnd I was like \"HOLY SHIT\"", - "year" : "2018", - "url" : "https://www.example.com/" - }, - { - "id": 30, - "author" : "Zac Bowden", - "authorImage" : "https://pbs.twimg.com/profile_images/963331874503430144/NTv0Dlaj_400x400.jpg", - "quote" : "We can happily move on to Windows 11, Windows 10 is now done and dusted", - "year" : "2018", - "url" : "https://www.example.com/" - }, - { - "id": 31, - "author" : "Victor Tran", - "authorImage" : "https://yt3.ggpht.com/-Iuf1v4-SSSM/AAAAAAAAAAI/AAAAAAAAAAA/89IYeQw--wU/photo.jpg", - "quote" : "WHAT THE - IS THAT\nMAN I JUST CAME BACK TO MY ROOM\nAND THEN I SEE YOU WITH A GUY IN IT", - "year" : "2018", - "url" : "https://www.example.com/" - } - ] -} diff --git a/storage/vtquotes.json b/storage/vtquotes.json deleted file mode 100644 index 79781cd..0000000 --- a/storage/vtquotes.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "quotes" :[ - { - "author" : "Victor Tran", - "authorImage" : "https://yt3.ggpht.com/-Iuf1v4-SSSM/AAAAAAAAAAI/AAAAAAAAAAA/89IYeQw--wU/photo.jpg", - "quote" : "@Derpy ♀ For your own fucking good, learn what political correctness is.", - "year" : "2017", - "url" : "https://cdn.discordapp.com/attachments/371830028381454337/372263065472729088/2017-10-24_01.58.19.png" - }, - { - "author" : "Victor Tran", - "authorImage" : "https://yt3.ggpht.com/-Iuf1v4-SSSM/AAAAAAAAAAI/AAAAAAAAAAA/89IYeQw--wU/photo.jpg", - "quote" : "But couldn't you at least put the mounted disks on the dick or on Dinder?\nDOCK", - "year" : "2017", - "url" : "https://www.example.com" - }, - { - "author" : "Victor Tran", - "authorImage" : "https://yt3.ggpht.com/-Iuf1v4-SSSM/AAAAAAAAAAI/AAAAAAAAAAA/89IYeQw--wU/photo.jpg", - "quote" : "Just happened one gay?\nDAY\nOH BOY\nI BLAME SWIPE TYPING", - "year" : "2017", - "url" : "https://www.example.com" - }, - { - "author" : "Victor Tran", - "authorImage" : "https://yt3.ggpht.com/-Iuf1v4-SSSM/AAAAAAAAAAI/AAAAAAAAAAA/89IYeQw--wU/photo.jpg", - "quote" : "(there is a :middle_finger: emoji sitting in Gboard now after my brother sent that to Google assistant)", - "year" : "2017", - "url" : "https://www.example.com/" - }, - { - "author" : "Victor Tran", - "authorImage" : "https://yt3.ggpht.com/-Iuf1v4-SSSM/AAAAAAAAAAI/AAAAAAAAAAA/89IYeQw--wU/photo.jpg", - "quote" : "Who needs to say fuck when you can say - instead\nI blame that on my secretary :sob:", - "year" : "2018", - "url" : "https://www.example.com/" - }, - { - "author" : "Victor Tran", - "authorImage" : "https://yt3.ggpht.com/-Iuf1v4-SSSM/AAAAAAAAAAI/AAAAAAAAAAA/89IYeQw--wU/photo.jpg", - "quote" : "Dire Dire DICKS\nWAIT\nNO\nDOCKS", - "year" : "2018", - "url" : "https://www.example.com/" - }, - { - "author" : "Victor Tran", - "authorImage" : "https://yt3.ggpht.com/-Iuf1v4-SSSM/AAAAAAAAAAI/AAAAAAAAAAA/89IYeQw--wU/photo.jpg", - "quote" : "I need to find a new sexretary ASAP\n.....\nHELP\nAHHHHHHHHHHHH\nSECRETARY", - "year" : "2018", - "url" : "https://www.example.com/" - }, - { - "author" : "Victor Tran", - "authorImage" : "https://yt3.ggpht.com/-Iuf1v4-SSSM/AAAAAAAAAAI/AAAAAAAAAAA/89IYeQw--wU/photo.jpg", - "quote" : "are you serious blake LMAO", - "year" : "2018", - "url" : "https://www.example.com/" - } - ] -} -- cgit v1.2.3 From 08a026ae7c9dc201740a7ae837a6090283f36252 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Thu, 29 Jul 2021 16:07:01 -0400 Subject: New branch name --- storage/settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage') diff --git a/storage/settings.json b/storage/settings.json index 83932cc..8f0e530 100644 --- a/storage/settings.json +++ b/storage/settings.json @@ -1,4 +1,4 @@ { - "abVersion": "2.13.0 Beta", + "abVersion": "2.13.0 Alpha Temp Branch", "prefix": "abb:" } -- cgit v1.2.3 From 96762ce209415c72e098a78771f80fcc41413280 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Thu, 15 Sep 2022 15:06:29 -0400 Subject: 2022 update; Modularized activities --- bot_discord.js | 29 +++++++++------------------ commands/about.js | 4 ++-- commands/quote.js | 43 ++++++++++++++++++++-------------------- commands/serverinfo.js | 2 +- storage/activities.js | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 87 insertions(+), 44 deletions(-) create mode 100644 storage/activities.js (limited to 'storage') diff --git a/bot_discord.js b/bot_discord.js index a390fef..d963a4d 100644 --- a/bot_discord.js +++ b/bot_discord.js @@ -36,6 +36,7 @@ const web = express(); const settings = require('./storage/settings.json'); const mongo = require('./plugins/mongo'); const api = require('./tokens.json'); +const { activity } = require('./storage/activities'); const active = new Map(); let autoRole = true; let readyEmbedMessage = false; @@ -45,22 +46,6 @@ let statusChannelID = '606602551634296968'; let serverWhitelist = "243022206437687296"; let roleWhitelist = "657426918416580614" -const activities = [ - 'AleeBot ' + settings.abVersion + ' | ' + settings.prefix + 'help', - 'Coding bytes', - 'Drawing shapes', - 'Fighting Quad', - 'Ultra Jump Mania!', - 'Exposing TAS-Corp', - 'Fighting Evelyn Claythorne', - 'Installing Windows 11', - 'Breaking Windows 10', - 'Reticulating splines', - 'Dag dag!', - '90% bug free!', - 'Now running ' + Discord.version + '!' -]; - const log = (message) => { console.log(`[${moment().format('YYYY-MM-DD HH:mm:ss')}] ${message}`.white); }; @@ -68,7 +53,7 @@ const log = (message) => { function botPresence() { client.user.setPresence({ activities: [{ - name: activities[Math.floor(Math.random() * activities.length)] + name: activity[Math.floor(Math.random() * activity.length)] }], status: 'online', afk: false, @@ -82,7 +67,7 @@ const rl = readline.createInterface({ prompt: '> '.gray, }); -console.log(`AleeBot ${settings.abVersion}: Copyright (C) 2017-2021 Alee Productions`.gray); +console.log(`AleeBot ${settings.abVersion}: Copyright (C) 2017-2022 Andrew Lee Projects`.gray); console.log('This program comes with ABSOLUTELY NO WARRANTY; for details type `show w\'.'.gray); console.log('This is free software, and you are welcome to redistribute it'.gray); console.log('under certain conditions; type `show c\' for details.\n'.gray); @@ -193,6 +178,10 @@ rl.on('line', function(cmd) { const uptimeSeconds = minutes % 60; console.log(`[i] AleeBot has been up for ${hours} hours, ${uptimeMinutes} minutes, and ${uptimeSeconds} seconds.`.blue); break; + case 'activity': + console.log('[i] Generating new activity'.blue); + botPresence(); + break; case 'exit': console.log('[i] AleeBot will now exit!'.blue); const asyncPowerOff = async () => { @@ -323,7 +312,7 @@ client.on('messageUpdate', async (oldMessage, newMessage) => { .setColor('#ffff1a') .setTimestamp() .setFooter(`Author ID: ${oldMessage.author.id}`); - + let editMessage = client.channels.cache.get(logChannel); if (!editMessage) return; @@ -419,7 +408,7 @@ AutoPoster(api.dbltoken, client) client.on('messageCreate', async(msg) => { if (!client.application?.owner) await client.application?.fetch(); if (msg.author.bot) return; - + const prefixes = JSON.parse(fs.readFileSync('./storage/prefixes.json', 'utf8')); if (!prefixes[msg.guild.id]) { diff --git a/commands/about.js b/commands/about.js index 5fd11de..14daebb 100644 --- a/commands/about.js +++ b/commands/about.js @@ -22,10 +22,10 @@ module.exports.run = async (client, message) => { const aboutEmbed = new MessageEmbed() .setAuthor(`AleeBot ${require('../storage/settings.json').abVersion}`, client.user.avatarURL()) - .addField('About AleeBot', 'AleeBot is an all-in-one bot that\'s made from the Discord.JS api!') + .addField('About AleeBot', 'AleeBot is an all-in-one bot that\'s made from the Discord.JS API!') .addField('License', 'GNU General Public License v3.0') .addField('Contributors', 'Andrew Lee (Founder of this project)\nOfficialRain (Raina) (Uptime Command)\njtsshieh (Command Handler)') - .setFooter('© Copyright 2017-2021 Alee Productions') + .setFooter('© Copyright 2017-2022 Andrew Lee Projects') .setColor('#1fd619'); let inviteButton = new MessageActionRow() diff --git a/commands/quote.js b/commands/quote.js index 57729ae..e431566 100644 --- a/commands/quote.js +++ b/commands/quote.js @@ -19,12 +19,12 @@ * *************************************/ const mongo = require('../plugins/mongo'); const quoteSchema = require('../schema/quote-schema'); -module.exports.run = async (client, message, args) => { +module.exports.run = async (client, message) => { if (!['242775871059001344'].includes(message.author.id)) return message.reply('**This command is disabled due to a new system being implemented.**'); const { MessageEmbed } = require('discord.js'); - let NewQuote; - let quo; +// let NewQuote; +// let quo; let quoId; let quoAuthor; @@ -32,26 +32,27 @@ module.exports.run = async (client, message, args) => { let quoQuote; let quoYear; - if (args) { - await mongo().then(async (mongoose) => { - try { - const quote = await quoteSchema.findOne({quoteID: args[1], author: quoAuthor, authorImage: quoAuthorImage, quote: quoQuote, year: quoYear}) - /* - const embed = new MessageEmbed() - .setAuthor(quoAuthor, quoAuthorImage) - .setDescription(quoQuote) - .setColor('#1fd619') - .setFooter('- ' + quoYear); + // Written using GitHub CoPilot - await message.channel.send({embeds:[embed]});*/ - console.log(quote); - } finally { - await mongoose.connection.close(); - } - }) - } else { + // Fetch a random quote from quoteSchema database then return the quote using embeds + const fetchQuote = async () => { + const quote = await mongo.db.collection('quotes').aggregate([{ $sample: { size: 1 } }]).toArray(); + quoId = quote[0]._id; + quoAuthor = quote[0].author; + quoAuthorImage = quote[0].authorImage; + quoQuote = quote[0].quote; + quoYear = quote[0].year; + const embed = new MessageEmbed() + + .setColor('#0099ff') + .setAuthor(quoAuthor, quoAuthorImage) + .setDescription(`${quoQuote}`) + .setFooter(`${quoYear}`) + return message.channel.send(embed); - } + }; + + fetchQuote(); /* diff --git a/commands/serverinfo.js b/commands/serverinfo.js index 049ad98..513b1b4 100644 --- a/commands/serverinfo.js +++ b/commands/serverinfo.js @@ -27,7 +27,7 @@ module.exports.run = async (client, message) => { .setThumbnail(`${message.guild.iconURL()}`) .addField('Server Name:', `${message.guild.name}`) .addField('Server ID:', `${message.guild.id}`) - .addField('Create At:', `${message.guild.createdAt.toUTCString()}`) + .addField('Created At:', `${message.guild.createdAt.toUTCString()}`) /*message.guild.channels.cacheType.forEach(channel => { listedChannels.push(channel) })*/ diff --git a/storage/activities.js b/storage/activities.js new file mode 100644 index 0000000..13362d9 --- /dev/null +++ b/storage/activities.js @@ -0,0 +1,53 @@ +const settings = require("./settings.json"); +const Discord = require("discord.js"); + +const activities = [ + `AleeBot ${settings.abVersion}`, + 'Coding bytes', + 'Drawing shapes', + 'Fighting Quad', + 'Ultra Jump Mania!', + 'Battle Blaze', + 'Tempest', + 'Turbo Crash 9', + 'Pocket Gakusei', + 'Hidden Heroes', + 'Skybreakers', + 'Exposing TAS-Corp', + 'Fighting Evelyn Claythorne', + 'Games with Tari', + 'Decommissioning Meta Runners', + 'Installing Meta Runners', + 'Installing Windows 11', + 'Breaking Windows 10', + 'Reticulating splines', + 'Generating terrain', + 'Never punch a tree...', + 'Collecting data', + 'Dag dag!', + 'Developed by Andrew Lee', + 'When will 2.13 release?', + 'Alert Irruption !!!', + 'when', + 'Thanks! @Victor', + 'Pombo', + 'AirCS Race', + 'ShiftOS', + 'Histacom', + 'theBeat', + 'FRESHMusicPlayer', + 'theShell', + 'theBeat', + 'theSlate', + 'Google Wallet', + 'Ian Clary\'s First Day At FrivoloCo!', + 'Squid Airlines', + 'Beating up big tech', + 'Deleting Google', + 'Watering down the Apple walled garden', + 'Frying Shrimpbot', + '90% bug free!', + 'Now running ' + Discord.version + '!' +]; + +exports.activity = activities -- cgit v1.2.3 From 85a8f11507c0fb74b67914090bdfe10c361b775e Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Tue, 20 Sep 2022 09:24:37 -0400 Subject: Removed jail command; Added more activities; Few tweaks --- bot_discord.js | 13 +++++---- commands/ask.js | 1 + commands/git.js | 2 +- commands/help.js | 4 +-- commands/info.js | 2 +- commands/jail.js | 42 ---------------------------- commands/quote.js | 39 +++++++++++++------------- commands/serverinfo.js | 2 +- commands/timeout.js | 49 +++++++++++++++++++++++++++++++++ storage/activities.js | 75 ++++++++++++++++++++++++++++++++++---------------- 10 files changed, 132 insertions(+), 97 deletions(-) delete mode 100644 commands/jail.js create mode 100644 commands/timeout.js (limited to 'storage') diff --git a/bot_discord.js b/bot_discord.js index d963a4d..60a133c 100644 --- a/bot_discord.js +++ b/bot_discord.js @@ -178,9 +178,9 @@ rl.on('line', function(cmd) { const uptimeSeconds = minutes % 60; console.log(`[i] AleeBot has been up for ${hours} hours, ${uptimeMinutes} minutes, and ${uptimeSeconds} seconds.`.blue); break; - case 'activity': - console.log('[i] Generating new activity'.blue); - botPresence(); + case 'activity': + console.log('[i] Generating new activity'.blue); + botPresence(); break; case 'exit': console.log('[i] AleeBot will now exit!'.blue); @@ -204,6 +204,7 @@ rl.on('line', function(cmd) { msg += ('leave - Leaves a guild.\n'); msg += ('broadcast - Broadcasts a message to a server.\n'); msg += ('uptime - Shows the uptime for AleeBot.\n'); + msg += ('activity - Generates new activity\n'); msg += ('help - Shows this command.\n'); msg += ('exit - Exits AleeBot.\n'); console.log(msg.cyan); @@ -219,7 +220,7 @@ client.on('ready', async () => { log(`[i] Logged in as ${client.user.tag}`.green); log(`[i] Default Prefix: ${settings.prefix}`.green); log(`[i] Bot ID: ${client.user.id}`.green); - log(`[i] Running version ${settings.abVersion} and in ${client.guilds.cache.size} guilds`.green); + log(`[i] Running version ${settings.abVersion} | Serving in ${client.guilds.cache.size} guilds`.green); botPresence(); @@ -368,7 +369,7 @@ client.on('guildBanRemove', (guild, user) => { }); client.on('guildCreate', (guild) => { - log(`[i] New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`.blue); + log(`[i] New guild joined: ${guild.name} (${guild.id}). This guild has ${guild.memberCount} members!`.blue); const logEmbed = new Discord.MessageEmbed() .setAuthor('AleeBot', client.user.avatarURL()) .setDescription('I got added to a server!') @@ -385,7 +386,7 @@ client.on('guildCreate', (guild) => { client.on('guildDelete', (guild) => { - log(`[i] I have been removed from: ${guild.name} (id: ${guild.id})`.red); + log(`[i] I have been removed from: ${guild.name} (${guild.id})`.red); const logEmbed = new Discord.MessageEmbed() .setAuthor('AleeBot', client.user.avatarURL()) .setDescription('I got removed from a server...') diff --git a/commands/ask.js b/commands/ask.js index 1dd5edd..efb4a22 100644 --- a/commands/ask.js +++ b/commands/ask.js @@ -26,6 +26,7 @@ module.exports.run = async (client, message, args) => { 'Yep. Just kidding :P', 'I doubt it.', 'Maybe?', + 'Perhaps...', 'I don\'t know?', 'Hmm let me think :thinking:', ]; diff --git a/commands/git.js b/commands/git.js index 8f6af1f..e4912e1 100644 --- a/commands/git.js +++ b/commands/git.js @@ -32,7 +32,7 @@ module.exports.run = async (client, message) => { new MessageButton() .setStyle('LINK') .setLabel('Source Code') - .setURL('https://github.com/aleeproductions/AleeBot') + .setURL('https://github.com/alee14-projects/AleeBot') ); message.channel.send({embeds: [gitInfo], components: [sourceCode]}); }); diff --git a/commands/help.js b/commands/help.js index 8fe42cc..e925754 100644 --- a/commands/help.js +++ b/commands/help.js @@ -40,8 +40,8 @@ module.exports.run = async (client, message) => { const prefix = prefixes[message.guild.id].prefixes; if (!message.guild.members.cache.get(client.user.id).permissions.has('EMBED_LINKS')) return message.reply('ERROR: AleeBot doesn\'t have the permission to send embed links, please enable them to use the full help.'); const embed = new Discord.MessageEmbed() - .setAuthor('AleeBot ' + require('../storage/settings.json').abVersion + ` Help and on ${client.guilds.cache.size} servers`, client.user.avatarURL()) - .setDescription('Currently on the Alpha-Temp branch. Meaning that experimental features are enabled in this bot...') + .setAuthor('AleeBot ' + require('../storage/settings.json').abVersion + ` Help | Serving in ${client.guilds.cache.size} servers`, client.user.avatarURL()) + .setDescription('[!] Currently on the Alpha-Temp branch. Meaning that experimental features are enabled in this bot...') .setColor('#1fd619') categories.forEach(function(x) { diff --git a/commands/info.js b/commands/info.js index bae45d4..95eaebb 100644 --- a/commands/info.js +++ b/commands/info.js @@ -25,7 +25,7 @@ module.exports.run = async (client, message) => { .setTitle('Information on AleeBot\'s Host') .addField('OS Hostname: ', os.hostname(), true) .addField('NodeJS Version: ', process.versions.node, true) - .addField('Discord.JS Version: ', version , true) + .addField('Discord.JS Version: ', version, true) .addField('OS Platform: ', os.platform(), true) .addField('OS Version: ', os.release(), true) .addField('Mongoose Version:', mongoose.version, true) diff --git a/commands/jail.js b/commands/jail.js deleted file mode 100644 index 7f6f3a3..0000000 --- a/commands/jail.js +++ /dev/null @@ -1,42 +0,0 @@ -/** ************************************** - * - * Jail: Command for AleeBot - * Copyright (C) 2017-2021 Alee Productions - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * *************************************/ -module.exports.run = async (client, message, args) => { - if (message.guild.id != '243022206437687296') return message.reply('This is a Binaryworks exclusive command.'); - - if (!message.member.permissions.has('BAN_MEMBERS')) return message.reply('It looks like that you don\'t have the permissions to jail members.'); - if (!message.guild.members.cache.get(client.user.id).permissions.has('MANAGE_ROLES')) return message.reply('Uhh... I don\'t have permission to jail members.'); - - const member = message.mentions.members.first(); - if (!member) return await message.reply('Uhh... Please mention a member first.'); - - member.roles.add(message.guild.roles.cache.get('428205205155217418')); - message.reply(`Alright, I just jailed ${member.user.tag}.`); -}; - -exports.conf = { - aliases: [], - guildOnly: false, -}; -exports.help = { - name: 'jail', - description: 'Jails a member', - usage: 'jail [user]', - category: '- Binaryworks Exclusive Commands', -}; diff --git a/commands/quote.js b/commands/quote.js index e431566..481cc9b 100644 --- a/commands/quote.js +++ b/commands/quote.js @@ -19,7 +19,7 @@ * *************************************/ const mongo = require('../plugins/mongo'); const quoteSchema = require('../schema/quote-schema'); -module.exports.run = async (client, message) => { +module.exports.run = async (client, message, args) => { if (!['242775871059001344'].includes(message.author.id)) return message.reply('**This command is disabled due to a new system being implemented.**'); const { MessageEmbed } = require('discord.js'); @@ -32,27 +32,26 @@ module.exports.run = async (client, message) => { let quoQuote; let quoYear; - // Written using GitHub CoPilot + if (args) { + await mongo().then(async (mongoose) => { + try { + const quote = await quoteSchema.findOne({quoteID: args[1], author: quoAuthor, authorImage: quoAuthorImage, quote: quoQuote, year: quoYear}) + /* + const embed = new MessageEmbed() + .setAuthor(quoAuthor, quoAuthorImage) + .setDescription(quoQuote) + .setColor('#1fd619') + .setFooter('- ' + quoYear); - // Fetch a random quote from quoteSchema database then return the quote using embeds - const fetchQuote = async () => { - const quote = await mongo.db.collection('quotes').aggregate([{ $sample: { size: 1 } }]).toArray(); - quoId = quote[0]._id; - quoAuthor = quote[0].author; - quoAuthorImage = quote[0].authorImage; - quoQuote = quote[0].quote; - quoYear = quote[0].year; - const embed = new MessageEmbed() - - .setColor('#0099ff') - .setAuthor(quoAuthor, quoAuthorImage) - .setDescription(`${quoQuote}`) - .setFooter(`${quoYear}`) - return message.channel.send(embed); + await message.channel.send({embeds:[embed]});*/ + console.log(quote); + } finally { + await mongoose.connection.close(); + } + }) + } else { - }; - - fetchQuote(); + } /* diff --git a/commands/serverinfo.js b/commands/serverinfo.js index 513b1b4..0a2e077 100644 --- a/commands/serverinfo.js +++ b/commands/serverinfo.js @@ -24,7 +24,7 @@ module.exports.run = async (client, message) => { const embed = new Discord.MessageEmbed() .setAuthor(`${message.guild.name}`, `${message.guild.iconURL()}`) .setDescription('Server Information') - .setThumbnail(`${message.guild.iconURL()}`) + .setThumbnail(message.guild.iconURL()) .addField('Server Name:', `${message.guild.name}`) .addField('Server ID:', `${message.guild.id}`) .addField('Created At:', `${message.guild.createdAt.toUTCString()}`) diff --git a/commands/timeout.js b/commands/timeout.js new file mode 100644 index 0000000..bed9077 --- /dev/null +++ b/commands/timeout.js @@ -0,0 +1,49 @@ +/** ************************************** + * + * Jail: Command for AleeBot + * Copyright (C) 2017-2021 Alee Productions + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * *************************************/ +module.exports.run = async (client, message, args) => { + const { MessageEmbed } = require('discord.js'); + + if (!message.member.permissions.has('BAN_MEMBERS')) return message.reply('It looks like that you don\'t have the permissions to jail members.'); + if (!message.guild.members.cache.get(client.user.id).permissions.has('MANAGE_ROLES')) return message.reply('Uhh... I don\'t have permission to jail members.'); + + if (!args[1]) message.reply('Determine the length of the timeout...'); + if (!args[2]) message.reply('Determine the reason of the timeout...'); + + const member = message.mentions.members.first(); + if (!member) return await message.reply('Uhh... Please mention a member first.'); + + const timeoutEmbed = new MessageEmbed() + .setDescription(`${member.user.tag} just got timed out!`) + .addField('Length', `${args[1]} minute(s)`) + .addField('Reason', args[2]) + .setColor('#ec2727') + member.timeout(args[1] * 60 * 1000, args[2]).then(message.reply({embeds: [timeoutEmbed]})); +}; + +exports.conf = { + aliases: [], + guildOnly: false, +}; +exports.help = { + name: 'timeout', + description: 'Times out a member', + usage: 'timeout [user]', + category: '- Moderation Commands', +}; diff --git a/storage/activities.js b/storage/activities.js index 13362d9..888c848 100644 --- a/storage/activities.js +++ b/storage/activities.js @@ -1,27 +1,18 @@ -const settings = require("./settings.json"); -const Discord = require("discord.js"); +const { abVersion } = require("./settings.json"); +const { version } = require("discord.js"); const activities = [ - `AleeBot ${settings.abVersion}`, + `AleeBot ${abVersion}`, 'Coding bytes', 'Drawing shapes', 'Fighting Quad', - 'Ultra Jump Mania!', - 'Battle Blaze', - 'Tempest', - 'Turbo Crash 9', - 'Pocket Gakusei', - 'Hidden Heroes', - 'Skybreakers', - 'Exposing TAS-Corp', - 'Fighting Evelyn Claythorne', - 'Games with Tari', - 'Decommissioning Meta Runners', - 'Installing Meta Runners', 'Installing Windows 11', 'Breaking Windows 10', + 'Beating up big tech', + 'Deleting Google', + 'Watering down the Apple walled garden', 'Reticulating splines', - 'Generating terrain', + 'Generating world', 'Never punch a tree...', 'Collecting data', 'Dag dag!', @@ -29,25 +20,61 @@ const activities = [ 'When will 2.13 release?', 'Alert Irruption !!!', 'when', + 'Frying Shrimpbot', + 'RADIATION BABY', + 'Frivolously Spending', 'Thanks! @Victor', + 'MCA DiscoVision', + 'Werq', 'Pombo', + 'Ian Clary\'s First Day At FrivoloCo!', + 'Squid Airlines', 'AirCS Race', + 'FrivoloCo', + 'I WANT 2 ORDER', + 'I REALLY WANT 2 ORDER', + 'I SAID I WANT 2 ORDER', + 'THANK YOU FOR TAKING SO LONG', + 'I COULD HAVE DONE THAT 67% FASTA', + 'I DO NOT WANT 2 ORDER ANYMORE', + 'Monica Is Going To Cosume You', + 'BLÅHAJ', 'ShiftOS', 'Histacom', + 'Wall Street', + 'Abunchoo 12.10', + 'MikeOS', 'theBeat', 'FRESHMusicPlayer', 'theShell', 'theBeat', 'theSlate', - 'Google Wallet', - 'Ian Clary\'s First Day At FrivoloCo!', - 'Squid Airlines', - 'Beating up big tech', - 'Deleting Google', - 'Watering down the Apple walled garden', - 'Frying Shrimpbot', + 'theDesk', + 'Ultra Jump Mania!', + 'Battle Blaze', + 'Tempest', + 'Turbo Crash 9', + 'Pocket Gakusei', + 'Hidden Heroes', + 'Skybreakers', + 'Always Running', + 'Only Up', + 'Trade', + 'Breeze', + 'Steady', + 'Bluejay', + 'Exposing TAS-Corp', + 'Fighting Evelyn Claythorne', + 'Hacking SherCorp', + 'Games with Tari', + 'Decommissioning Meta Runners', + 'Installing Meta Runners', '90% bug free!', - 'Now running ' + Discord.version + '!' + 'Google Wallet', + 'Apple Pay', + 'Splatoon 3', + 'Super Mario 64', + `Now running on Discord.JS ${version}!` ]; exports.activity = activities -- cgit v1.2.3 From 1a7a627446edfeb270850f0ed15c9c8d604380b2 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sat, 25 Mar 2023 21:25:43 -0400 Subject: Now using sequelize; Minor tweaks; New activities --- .gitignore | 5 +- .idea/dbnavigator.xml | 417 ++++++++++++++++++++++++++++++++++++++++++++++ CONTRIBUTING.md | 2 +- bot_discord.js | 22 +-- commands/about.js | 10 +- commands/addquote.js | 93 +++-------- commands/ban.js | 2 +- commands/kick.js | 2 +- commands/leaveguild.js | 2 +- commands/quote.js | 73 ++------ commands/setlogchannel.js | 35 +--- commands/setup.js | 46 +++++ commands/uptime.js | 11 +- deprecated/setup.js | 45 ----- models/guild-settings.js | 24 +++ models/quote.js | 29 ++++ package.json | 11 +- plugins/mongo.js | 10 -- schema/logging-schema.js | 13 -- schema/quote-schema.js | 17 -- storage/activities.js | 28 +++- sync-database.js | 9 + utils/sequelize.js | 9 + 23 files changed, 643 insertions(+), 272 deletions(-) create mode 100644 .idea/dbnavigator.xml create mode 100644 commands/setup.js delete mode 100644 deprecated/setup.js create mode 100644 models/guild-settings.js create mode 100644 models/quote.js delete mode 100644 plugins/mongo.js delete mode 100644 schema/logging-schema.js delete mode 100644 schema/quote-schema.js create mode 100644 sync-database.js create mode 100644 utils/sequelize.js (limited to 'storage') diff --git a/.gitignore b/.gitignore index fb6a084..bca3965 100644 --- a/.gitignore +++ b/.gitignore @@ -11,11 +11,10 @@ ffprobe.exe .directory -userData.sqlite .vs/slnx.sqlite .vs/slnx.sqlite-journal json.sqlite yarn.lock - -package-lock.json \ No newline at end of file +package-lock.json +database.sqlite diff --git a/.idea/dbnavigator.xml b/.idea/dbnavigator.xml new file mode 100644 index 0000000..b1bad03 --- /dev/null +++ b/.idea/dbnavigator.xml @@ -0,0 +1,417 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d75ca6a..2799fb4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,7 +5,7 @@ Include the GPL-3.0 license too and follow the following format when you create /**************************************** * * [Command/Plugin]: (Command or Plugin) for AleeBot - * Copyright (C) 2017-2021 Alee Productions & (your name here) + * Copyright (C) 2017-2023 Andrew Lee & (your name here) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/bot_discord.js b/bot_discord.js index 60a133c..00afe45 100644 --- a/bot_discord.js +++ b/bot_discord.js @@ -1,7 +1,7 @@ /** ************************************** * * AleeBot: Made for discord servers - * Copyright (C) 2017-2021 Alee Productions + * Copyright (C) 2017-2022 Andrew Lee Projects * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,11 +30,9 @@ const express = require('express'); const fs = require('fs'); const readline = require('readline'); const colors = require('colors'); -const { AutoPoster } = require('topgg-autoposter'); //const i18next = require('i18next'); const web = express(); const settings = require('./storage/settings.json'); -const mongo = require('./plugins/mongo'); const api = require('./tokens.json'); const { activity } = require('./storage/activities'); const active = new Map(); @@ -67,7 +65,7 @@ const rl = readline.createInterface({ prompt: '> '.gray, }); -console.log(`AleeBot ${settings.abVersion}: Copyright (C) 2017-2022 Andrew Lee Projects`.gray); +console.log(`AleeBot ${settings.abVersion}: Copyright (C) 2017-2023 Andrew Lee Projects`.gray); console.log('This program comes with ABSOLUTELY NO WARRANTY; for details type `show w\'.'.gray); console.log('This is free software, and you are welcome to redistribute it'.gray); console.log('under certain conditions; type `show c\' for details.\n'.gray); @@ -224,14 +222,6 @@ client.on('ready', async () => { botPresence(); - await mongo().then(mongoose => { - try { - log('[>] Connected to MongoDB!'.green); - } finally { - mongoose.connection.close(); - } - }) - web.get('/', (req, res) => { res.send("Hello World! This is going to become the AleeBot dashboard..."); }); @@ -263,10 +253,9 @@ client.on('guildMemberAdd', (member) => { const logEmbed = new Discord.MessageEmbed() .setAuthor('AleeBot Logging', client.user.avatarURL()) .setDescription(`A user has joined this server!`) - .addField('Username: ', `${member.displayName}`, true) + .addField('Username: ', `${member.user.tag}`, true) .addField('User ID: ', `${member.id}`, true) .addField('Created At: ', `${member.user.createdAt.toUTCString()}`) - //.addField('Invite Code: ', `${member.invite.code}`) .setColor('#4bff31') .setTimestamp(); @@ -278,8 +267,7 @@ client.on('guildMemberAdd', (member) => { if (member.guild.id !== serverWhitelist) return; const role = member.guild.roles.cache.get(roleWhitelist); member.roles.add(role); - log(`[i] ${member.user.username} joined Binaryworks Community.`.green); - log(`[i] I gave ${member.user.username} the "Member" role.`.green); + log(`[i] ${member.user.username} joined Andrew Lee Projects, automatically giving them role.`.green); } }); @@ -288,7 +276,7 @@ client.on('guildMemberRemove', (member) => { const logEmbed = new Discord.MessageEmbed() .setAuthor('AleeBot Logging', client.user.avatarURL()) .setDescription(`A user has left this server!`) - .addField('Username: ', `${member.displayName}`, true) + .addField('Username: ', `${member.user.tag}`, true) .addField('User ID: ', `${member.id}`, true) .setColor('#ec2727') .setTimestamp(); diff --git a/commands/about.js b/commands/about.js index 14daebb..be1c17d 100644 --- a/commands/about.js +++ b/commands/about.js @@ -20,12 +20,16 @@ module.exports.run = async (client, message) => { const { MessageEmbed, MessageButton, MessageActionRow } = require('discord.js'); + let Contributors = ('- Andrew Lee (Founder of this project)\n'); + Contributors += ('- OfficialRain (Raina) (Uptime Command)\n'); + Contributors += ('- jtsshieh (Command Handler)'); + const aboutEmbed = new MessageEmbed() .setAuthor(`AleeBot ${require('../storage/settings.json').abVersion}`, client.user.avatarURL()) .addField('About AleeBot', 'AleeBot is an all-in-one bot that\'s made from the Discord.JS API!') .addField('License', 'GNU General Public License v3.0') - .addField('Contributors', 'Andrew Lee (Founder of this project)\nOfficialRain (Raina) (Uptime Command)\njtsshieh (Command Handler)') - .setFooter('© Copyright 2017-2022 Andrew Lee Projects') + .addField('Contributors', Contributors) + .setFooter('© Copyright 2017-2023 Andrew Lee Projects') .setColor('#1fd619'); let inviteButton = new MessageActionRow() @@ -36,7 +40,7 @@ module.exports.run = async (client, message) => { .setURL('https://top.gg/bot/282547024547545109'), new MessageButton() .setStyle('LINK') - .setLabel('Join Binaryworks Community') + .setLabel('Join Andrew Lee Projects') .setURL('https://discord.gg/EFhRDqG') ); diff --git a/commands/addquote.js b/commands/addquote.js index 6334470..477d891 100644 --- a/commands/addquote.js +++ b/commands/addquote.js @@ -17,74 +17,35 @@ * along with this program. If not, see . * * *************************************/ -const mongo = require('../plugins/mongo'); -const quoteSchema = require('../schema/quote-schema'); +const quoteDB = require('../models/quote'); +const Discord = require("discord.js"); module.exports.run = async (client, message, args) => { -/* - let authorMessage; - let authorImageMessage; - let quoteMessage; - let yearMessage;*/ - if (!['242775871059001344'].includes(message.author.id)) return message.reply('**This command is disabled due to a new system being implemented.**'); - //await message.author.send('Welcome to AleeBot\'s quoting system!\nThis process will be easy.'); - - if (!args.length) return message.reply("Error: Did not provide more context (message will be replaced eventually)"); - - await mongo().then(async (mongoose) => { - try { - await new quoteSchema({ - author: args[0], - authorImage: args[1], - quote: args[2], - year: args[3] - - }).save() - } finally { - await mongoose.connection.close(); - message.reply('Added this quote to the database...'); - } - }) - -/* - let quoteState = {}; - let state = quoteState[message.author.id]; - - if (message.content.toLowerCase() === "q"){ - await message.author.send("Process has been cancelled"); - state = null; - } else { - switch (state) { - case 1: - await message.author.send('Enter the author\'s name'); - authorMessage = message.content; - console.log(authorMessage); - state = 2; - break; - case 2: - await message.author.send('author url here'); - authorImageMessage = message.content; - console.log(authorImageMessage); - state = 3; - break; - case 3: - await message.author.send('quote here'); - quoteMessage = message.content; - console.log(quoteMessage); - state = 4; - break; - case 4: - await message.author.send('year here'); - yearMessage = message.content; - console.log(yearMessage); - state = 5; - break; - case 5: - await message.author.send('process complete'); - state = null; - break; - } -*/ + try { + let newAuthor; + let newAuthorImage; + let newQuote; + let newYear; + + const quote = await quoteDB.create({ + author: newAuthor, + authorImage: newAuthorImage, + quote: newQuote, + year: newYear + }) + + const setupEmbed = new Discord.MessageEmbed() + .setTitle('AleeBot Quote Setup', client.user.avatarURL()) + .setDescription('Input the data to the following embed') + .addField('Author', newAuthor, true) + .addField('Author Image (URL)', newAuthorImage, true) + .addField('Quote', newQuote, true) + .addField('Year', newYear, true); + + message.reply({embeds: [setupEmbed]}); + } catch (error) { + console.log(error) + } }; exports.conf = { diff --git a/commands/ban.js b/commands/ban.js index 1e8ee6e..b734be5 100644 --- a/commands/ban.js +++ b/commands/ban.js @@ -29,7 +29,7 @@ module.exports.run = async (client, message, args) => { .setTitle('User Banned!') .setColor('#1fd619') .addField('**User:**', `${member.user.tag}`) - .addField('**Reason:**', `\`\`\`${mreason}\`\`\``); + if (mreason) return banEmbed.addField('**Reason:**', `\`\`\`${mreason}\`\`\``); await message.channel.send({embeds: [banEmbed]}); }; diff --git a/commands/kick.js b/commands/kick.js index 1bf83db..c248afc 100644 --- a/commands/kick.js +++ b/commands/kick.js @@ -29,7 +29,7 @@ module.exports.run = async (client, message, args) => { .setTitle('User Kicked!') .setColor('#1fd619') .addField('**User:**', `${member.user.tag}`) - .addField('**Reason:**', `\`\`\`${mreason}\`\`\``); + if (mreason) return kickEmbed.addField('**Reason:**', `\`\`\`${mreason}\`\`\``); await message.channel.send({embeds: [kickEmbed]}); }; diff --git a/commands/leaveguild.js b/commands/leaveguild.js index f88f0bb..00a97fc 100644 --- a/commands/leaveguild.js +++ b/commands/leaveguild.js @@ -19,7 +19,7 @@ * *************************************/ module.exports.run = async (client, message) => { if (!['242775871059001344', message.guild.ownerID].includes(message.author.id)) return message.reply('Nope! You need the person who created this bot or the owner of this guild to use this command.'); - await message.channel.send('Leaving server. If that\'s a mistake, you can re-invite me...'); + await message.channel.send('Leaving server. If that\'s a mistake, you can re-invite me'); message.guild.leave(); }; diff --git a/commands/quote.js b/commands/quote.js index 481cc9b..81f9142 100644 --- a/commands/quote.js +++ b/commands/quote.js @@ -17,72 +17,33 @@ * along with this program. If not, see . * * *************************************/ -const mongo = require('../plugins/mongo'); -const quoteSchema = require('../schema/quote-schema'); module.exports.run = async (client, message, args) => { - if (!['242775871059001344'].includes(message.author.id)) return message.reply('**This command is disabled due to a new system being implemented.**'); + const quoteDB = require('../models/quote'); const { MessageEmbed } = require('discord.js'); + let quoteID = args[0]; -// let NewQuote; -// let quo; - - let quoId; - let quoAuthor; - let quoAuthorImage; - let quoQuote; - let quoYear; - - if (args) { - await mongo().then(async (mongoose) => { - try { - const quote = await quoteSchema.findOne({quoteID: args[1], author: quoAuthor, authorImage: quoAuthorImage, quote: quoQuote, year: quoYear}) - /* - const embed = new MessageEmbed() - .setAuthor(quoAuthor, quoAuthorImage) - .setDescription(quoQuote) - .setColor('#1fd619') - .setFooter('- ' + quoYear); - - await message.channel.send({embeds:[embed]});*/ - console.log(quote); - } finally { - await mongoose.connection.close(); - } - }) - } else { - + if (quoteID === undefined) { + const quoteList = await quoteDB.findAll({ attributes: ['id'] }) + quoteID = Math.floor(Math.random() * (quoteList.length - 1)) + 1 } - /* + const quote = await quoteDB.findOne({ where: { id: quoteID } }) - function GetNewQuote(quoteNum = -1) { - NewQuote = new Discord.MessageEmbed(); - let quo = require('../storage/quotes.json').quotes + if (quote) { + const embed = new MessageEmbed() + .setAuthor({ name: quote.author, iconURL: quote.authorImage}) + .setDescription(quote.quote) + .setColor('#1fd619') + .setFooter('- ' + quote.year); - if (quoteNum === -1) { - quoteNum = Math.floor(Math.random() * 1000) % quo.length; - quo=quo[quoteNum]; - } - - const author = quo.author; - const authorImage = quo.authorImage; - const quote = quo.quote; - const year = quo.year; - const url = quo.url; - - NewQuote.setAuthor(author, authorImage); - NewQuote.setColor('#1fd619'); - NewQuote.setDescription(quote); - NewQuote.setFooter('- ' + year); - //NewQuote.setURL(url); - - return NewQuote; + await message.reply('Alright, here\'s your quote.') + await message.channel.send({embeds:[embed]}); + } else { + message.reply('Cannot find quote'); } - const newquote = GetNewQuote(); - message.reply('Alright, here\'s your quote.'); - await message.channel.send(newquote);*/ + }; exports.conf = { diff --git a/commands/setlogchannel.js b/commands/setlogchannel.js index 902a210..c04e926 100644 --- a/commands/setlogchannel.js +++ b/commands/setlogchannel.js @@ -17,36 +17,19 @@ * along with this program. If not, see . * * *************************************/ -const mongo = require('../plugins/mongo'); -const logSchema = require('../schema/logging-schema'); +const guildDB = require ('../models/guild-settings') module.exports.run = async (client, message) => { //This will be replaced in the future possibly if (!message.member.permissions.has('MANAGE_GUILD')) return message.reply('It looks like that you can\'t manage this server.'); const channel = await message.mentions.channels.first().id; - const cache = {} + const [ guild ] = await guildDB.findOrCreate({ where: { id: message.guild.id } } ) - if (!channel) return message.reply('I cannot find that channel, please specify...'); - - cache[message.guild.id] = channel - - await mongo().then(async (mongoose) => { - try { - await logSchema.findOneAndUpdate( - { - _id: message.guild.id, - }, - { - _id: message.guild.id, - logChannel: channel - }, - { - upsert: true - } - ) - } finally { - await mongoose.connection.close(); - } - }) + if (!channel) { + message.reply('No channel has been set, disabling the logging channel feature...'); + await guild.update({ channelId: null } ); + } else { + await guild.update({ channelId: message.guild.id } ) ; + } await message.reply(`Logging channel has been set to <#${channel}>`); }; @@ -58,6 +41,6 @@ exports.conf = { exports.help = { name: 'setlogchannel', description: 'Set the log channel.', - usage: 'setlogchannel [channel id]', + usage: 'setlogchannel #channel', category: '- Moderation Commands', }; diff --git a/commands/setup.js b/commands/setup.js new file mode 100644 index 0000000..5c2f232 --- /dev/null +++ b/commands/setup.js @@ -0,0 +1,46 @@ +/**************************************** + * + * Setup: Command for AleeBot + * Copyright (C) 2017-2021 Alee Productions + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * *************************************/ + +module.exports.run = async (client, message) => { + if (!['242775871059001344', message.guild.ownerId].includes(message.author.id)) return message.reply(':warning: You must be a server owner or be the creator of the bot to access this command.'); + message.reply('Look at your DMs.'); + //message.reply("This feature is coming soon. Stay tuned!"); + const Discord = require('discord.js'); + const setupEmbed = new Discord.MessageEmbed() + .setTitle('AleeBot Setup', client.user.avatarURL()) + .setDescription('Select the options') + .addField('Chat Logs', 'channelid', true) + .addField('Joining & Leaving Logs', 'placeholder', true) + .addField('Broadcast', 'placeholder', true) + .addField('Broadcast', 'placeholder', true); + + message.author.send({embeds: [setupEmbed]}); +}; + +exports.conf = { + aliases: [], + guildOnly: false, +}; +exports.help = { + name: 'setup', + description: 'Setting up AleeBot.', + usage: 'setup', + category: '- Settings Commands', +}; diff --git a/commands/uptime.js b/commands/uptime.js index 4753f70..7453ad5 100644 --- a/commands/uptime.js +++ b/commands/uptime.js @@ -23,12 +23,17 @@ module.exports.run = async (client, message) => { let uptimeMinutes = Math.floor(uptime / 60); const minutes = uptime % 60; let hours = 0; + let days = 0; while (uptimeMinutes >= 60) { - hours++; - uptimeMinutes = uptimeMinutes - 60; + hours++; + uptimeMinutes = uptimeMinutes - 60; + } + while (hours >= 24) { + days++; + hours = hours - 24; } const uptimeSeconds = minutes % 60; - message.channel.send(':clock3: AleeBot has been up for ' + hours + ' hours, ' + uptimeMinutes + ' minutes, and ' + uptimeSeconds + ' seconds.'); + message.channel.send(`:clock3: AleeBot has been up for ${days} days, ${hours} hours, ${uptimeMinutes} minutes, and ${uptimeSeconds} seconds.`); }; exports.conf = { diff --git a/deprecated/setup.js b/deprecated/setup.js deleted file mode 100644 index a86f850..0000000 --- a/deprecated/setup.js +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************** - * - * Setup: Command for AleeBot - * Copyright (C) 2017-2021 Alee Productions - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * *************************************/ - -module.exports.run = async (client, message) => { - if (!['242775871059001344', message.guild.owner.user.id].includes(message.author.id)) return message.reply(':warning: You must be a server owner or be the creator of the bot to access this command.'); - message.reply('Look at your DMs.'); - //message.reply("This feature is coming soon. Stay tuned!"); - const Discord = require('discord.js'); - const setupEmbed = new Discord.MessageEmbed() - .setTitle('AleeBot Setup', client.user.avatarURL()) - .setDescription('Select the options') - .addField('Logs', 'channelid', true) - // .addField('Chat Logs', 'placeholder', true) - // .addField('Chat Logs', 'placeholder', true); - - message.author.send(setupEmbed); -}; - -exports.conf = { - aliases: [], - guildOnly: false, -}; -exports.help = { - name: 'setup', - description: 'Setting up AleeBot.', - usage: 'setup', - category: '- Settings Commands', -}; \ No newline at end of file diff --git a/models/guild-settings.js b/models/guild-settings.js new file mode 100644 index 0000000..2e4f8ef --- /dev/null +++ b/models/guild-settings.js @@ -0,0 +1,24 @@ +const Sequelize = require("sequelize"); +const sequelize = require('../utils/sequelize'); + +const guildSettings = sequelize.define('guild-settings', { + id: { + type: Sequelize.STRING, + primaryKey: true + }, + logChannelID: { + type: Sequelize.STRING, + allowNull: true + }, + autoRoleToggle: { + type: Sequelize.BOOLEAN, + allowNull: true + }, + autoRoleID: { + type: Sequelize.STRING, + allowNull: true + } + +}) + +module.exports = guildSettings diff --git a/models/quote.js b/models/quote.js new file mode 100644 index 0000000..f31b472 --- /dev/null +++ b/models/quote.js @@ -0,0 +1,29 @@ +const Sequelize = require("sequelize"); +const sequelize = require('../utils/sequelize'); + +const quote = sequelize.define('quotes', { + id: { + type: Sequelize.INTEGER, + autoIncrement: true, + primaryKey: true + }, + author: { + type: Sequelize.STRING, + allowNull: false + }, + authorImage: { + type: Sequelize.STRING, + allowNull: false + }, + quote: { + type: Sequelize.TEXT, + allowNull: false + }, + year: { + type: Sequelize.STRING, + allowNull: false + } + +}) + +module.exports = quote diff --git a/package.json b/package.json index 0e34c8d..91c283c 100644 --- a/package.json +++ b/package.json @@ -9,19 +9,18 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/aleeproductions/AleeBot.git" + "url": "git+https://github.com/Alee14/AleeBot.git" }, - "author": "Alee Productions", + "author": "Andrew Lee", "license": "GPL-3.0", "bugs": { - "url": "https://github.com/aleeproductions/AleeBot/issues" + "url": "https://github.com/Alee14/AleeBot/issues" }, - "homepage": "https://github.com/aleeproductions/AleeBot#readme", + "homepage": "https://github.com/Alee14/AleeBot#readme", "dependencies": { "@top-gg/sdk": "^3.1.2", "blessed": "^0.1.81", "colors": "^1.3.0", - "discord-together": "^1.1.53", "discord.js": "^13.0.1", "eslint": "^7.1.0", "express": "^4.17.1", @@ -34,6 +33,8 @@ "os": "^0.1.1", "parse-ms": "^1.0.1", "readline": "^1.3.0", + "sequelize": "^6.30.0", + "sqlite3": "^5.1.6", "topgg-autoposter": "^2.0.0", "ytdl-core": "^0.20.4" }, diff --git a/plugins/mongo.js b/plugins/mongo.js deleted file mode 100644 index 0102aab..0000000 --- a/plugins/mongo.js +++ /dev/null @@ -1,10 +0,0 @@ -const mongoose = require('mongoose'); -const { mongoPath } = require('../tokens.json'); - -module.exports = async () => { - await mongoose.connect(mongoPath, { - useNewUrlParser: true, - useUnifiedTopology: true, - }); - return mongoose; -} \ No newline at end of file diff --git a/schema/logging-schema.js b/schema/logging-schema.js deleted file mode 100644 index 339c7f7..0000000 --- a/schema/logging-schema.js +++ /dev/null @@ -1,13 +0,0 @@ -const mongoose = require('mongoose') - -const reqString = { - type: String, - required: true -} - -const loggingSchema = mongoose.Schema({ - _id: reqString, - logChannel: reqString -}) - -module.exports = mongoose.model('logging', loggingSchema) \ No newline at end of file diff --git a/schema/quote-schema.js b/schema/quote-schema.js deleted file mode 100644 index d1c7db8..0000000 --- a/schema/quote-schema.js +++ /dev/null @@ -1,17 +0,0 @@ -const mongoose = require('mongoose'); - -const reqString = { - type: String, - required: true -} - -const quoteSchema = mongoose.Schema({ - quoteID: reqString, - author: reqString, - authorImage: reqString, - quote: reqString, - year: reqString - -}) - -module.exports = mongoose.model('quote', quoteSchema) \ No newline at end of file diff --git a/storage/activities.js b/storage/activities.js index 888c848..418a038 100644 --- a/storage/activities.js +++ b/storage/activities.js @@ -10,6 +10,9 @@ const activities = [ 'Breaking Windows 10', 'Beating up big tech', 'Deleting Google', + 'Deleting Apple', + 'Deleting System32', + 'Deleting /usr/bin/', 'Watering down the Apple walled garden', 'Reticulating splines', 'Generating world', @@ -33,15 +36,12 @@ const activities = [ 'FrivoloCo', 'I WANT 2 ORDER', 'I REALLY WANT 2 ORDER', - 'I SAID I WANT 2 ORDER', - 'THANK YOU FOR TAKING SO LONG', - 'I COULD HAVE DONE THAT 67% FASTA', - 'I DO NOT WANT 2 ORDER ANYMORE', 'Monica Is Going To Cosume You', 'BLÅHAJ', 'ShiftOS', 'Histacom', 'Wall Street', + 'Mac OS X Jaguar', 'Abunchoo 12.10', 'MikeOS', 'theBeat', @@ -65,6 +65,7 @@ const activities = [ 'Bluejay', 'Exposing TAS-Corp', 'Fighting Evelyn Claythorne', + 'Frying Dr. Sheridan', 'Hacking SherCorp', 'Games with Tari', 'Decommissioning Meta Runners', @@ -74,6 +75,25 @@ const activities = [ 'Apple Pay', 'Splatoon 3', 'Super Mario 64', + 'Minceraft', + 'Mario Kart 8', + 'bnbmc', + 'Evaluating JavaScript code', + 'Evaluating C# code', + 'Forkbombing FMP', + 'Merging with DLAP', + 'Now asbestos-free!', + 'May contain nuts!', + 'MythOS', + 'Also try Scratch!', + 'Funky!', + 'What is Web3?', + 'GNU\'s NOT UNIX!', + 'Linux, but actually GNU/Linux', + 'Praise RMS!', + 'Praying to St IGNUcius', + 'Debloating my ThinkPad', + 'Goddamn Idiotic Truckload of Windows', `Now running on Discord.JS ${version}!` ]; diff --git a/sync-database.js b/sync-database.js new file mode 100644 index 0000000..2462f29 --- /dev/null +++ b/sync-database.js @@ -0,0 +1,9 @@ +const quoteDB = require("./models/quote"); +const guildDB = require ('./models/guild-settings'); +quoteDB.sync({alter: true}).then(() => { + console.log('Quote database synced!') +}); + +guildDB.sync({alter: true}).then(() => { + console.log('Guild database synced!') +}); diff --git a/utils/sequelize.js b/utils/sequelize.js new file mode 100644 index 0000000..db18d50 --- /dev/null +++ b/utils/sequelize.js @@ -0,0 +1,9 @@ +const Sequelize = require("sequelize"); +const sequelize = new Sequelize('database', 'user', 'password', { + host: 'localhost', + dialect: 'sqlite', + logging: false, + storage: 'database.sqlite', +}); + +module.exports = sequelize; -- cgit v1.2.3 From 0c0155a4d207611fb3d975f9e7e56d04fff63d44 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sat, 14 Oct 2023 00:16:49 -0400 Subject: Docker; Removed packages; Removed binaryworks refs --- .dockerignore | 2 + Dockerfile | 15 +++++ To be worked on/addquote.js | 132 ++++++++++++++++++++++++++++++++++++++++++++ bot_discord.js | 66 ++++++++++++---------- commands/addquote.js | 61 -------------------- commands/help.js | 5 +- commands/interrogate.js | 4 +- commands/quote.js | 12 ++-- commands/serverinfo.js | 6 +- commands/slowdown.js | 2 +- commands/suggest.js | 6 +- commands/suggestfeature.js | 14 ++--- commands/userinfo.js | 2 +- package.json | 8 +-- storage/activities.js | 4 +- storage/settings.json | 2 +- 16 files changed, 218 insertions(+), 123 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 To be worked on/addquote.js delete mode 100644 commands/addquote.js (limited to 'storage') diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5171c54 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +node_modules +npm-debug.log \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1256d22 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM node:alpine + +WORKDIR /usr/src/bot + +COPY package.json ./ + +COPY tokens.json ./ + +COPY yarn.lock ./ + +RUN yarn install + +COPY . . + +CMD ["node", "bot_discord.js"] diff --git a/To be worked on/addquote.js b/To be worked on/addquote.js new file mode 100644 index 0000000..5f2b9bc --- /dev/null +++ b/To be worked on/addquote.js @@ -0,0 +1,132 @@ +/** ************************************** + * + * AddQuote: Command for AleeBot + * Copyright (C) 2017-2021 Alee Productions + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * *************************************/ +const quoteDB = require('../models/quote'); +const { MessageEmbed } = require("discord.js"); +module.exports.run = async (client, message, args) => { + if (!['242775871059001344'].includes(message.author.id)) return message.reply('**This command is disabled due to a new system being implemented.**'); + try { + let newAuthor; + let newAuthorImage; + let newQuote; + let newYear; + + let quoteOriginator; + + let isSetupRunning = false; + + const setupProcess = [ + 'Provide the name of the author.', + 'Submit the image of the author\nYou need to use a picture link that ends in .jpg or .png (like those from IMGUR or Google Images), and the picture should be either 128x128 pixels or 512x512 pixels in size.', + 'Enter the quote', + 'Specify the year from which the quote originates.' + ] + + let setupMessage = "Welcome to the AleeBot Quote Setup!\n" + setupMessage += "Please follow these rules when submitting quotes\n" + setupMessage += "```1. Do not use profanity or offensive language.\n" + setupMessage += "2. Do not send any personal information.\n" + setupMessage += "3. Only send noteworthy quotes.```\n" + setupMessage += "We reserve the right to reject any quotes that do not meet our criteria.\n" + + let counter = 0 + + if (isSetupRunning) { + return await message.reply('You are already setting up the quote.'); + } + const filter = m => m.author.id === message.author.id + + isSetupRunning = true; + await message.reply(':arrow_left: Check your DMs to continue.') + await message.author.send(setupMessage); + await message.author.send(setupProcess[counter++]); + + const collector = message.channel.createMessageCollector({ + filter, + max: setupProcess.length, + time: 1000 * 60 + }); + + collector.on('collect', message => { + console.log(`Collected ${message.content} from ${message.author.tag}`) + if (setupProcess.length > setupProcess.length + 1) { + message.author.send(setupProcess[counter++]); + } + }); + + collector.on('end', collected => { + if (collected.size === 0 && collected.size < 2) { + message.author.send('Quote setup was not completed, rerun the command.') + } else { + let quoteContent = []; + + collected.forEach((message) => { + quoteContent.push(message.content) + }) + + newAuthor = quoteContent[0] + newAuthorImage = quoteContent[1] + newQuote = quoteContent[2] + newYear = quoteContent[3] + + const setupEmbed = new MessageEmbed() + .setAuthor('AleeBot Quote Setup', client.user.avatarURL()) + .setDescription('Are you happy with this quote?\nThis quote will be sent for manual approval') + .addField('Author', newAuthor) + .addField('Author Image (URL)', newAuthorImage) + .addField('Quote', newQuote) + .addField('Year', newYear); + + message.author.send({embeds:[setupEmbed]}) + quoteOriginator = message.author.tag + console.log(`This quote has been originated from ${quoteOriginator}`) + isSetupRunning = false; + } + + }); + + /*await quoteDB.create({ + author: newAuthor, + authorImage: newAuthorImage, + quote: newQuote, + year: newYear, + });*/ + + //let messageReact = await message.author.send({embeds: [setupEmbed]}); + /*await messageReact.react('🧑'); + await messageReact.react('📷'); + await messageReact.react('🖋️'); + await messageReact.react('📅');*/ + + } catch (error) { + console.log(error) + } +}; + +exports.conf = { + aliases: [], + guildOnly: true, +}; +exports.help = { + name: 'addquote', + description: 'Adds a quote to the database.', + usage: 'addquote', + category: '- Quote Commands', +}; + diff --git a/bot_discord.js b/bot_discord.js index 00afe45..b32e018 100644 --- a/bot_discord.js +++ b/bot_discord.js @@ -23,7 +23,7 @@ const client = new Discord.Client({ parse: ['users', 'roles'], repliedUser: true }, - intents: ['GUILDS', 'GUILD_MESSAGES', 'GUILD_MEMBERS'] + intents: ['GUILDS', 'GUILD_MESSAGES', 'GUILD_MEMBERS', 'GUILD_MESSAGE_REACTIONS'] }); const moment = require('moment'); const express = require('express'); @@ -37,12 +37,12 @@ const api = require('./tokens.json'); const { activity } = require('./storage/activities'); const active = new Map(); let autoRole = true; -let readyEmbedMessage = false; +let readyEmbedMessage = true; const ownerID = '242775871059001344'; let logChannel = '318874545593384970'; let statusChannelID = '606602551634296968'; let serverWhitelist = "243022206437687296"; -let roleWhitelist = "657426918416580614" +let roleWhitelist = "657426918416580614"; const log = (message) => { console.log(`[${moment().format('YYYY-MM-DD HH:mm:ss')}] ${message}`.white); @@ -130,23 +130,14 @@ rl.on('line', function(cmd) { } } break; - case 'channels': - if (!args[1]) { - console.log('[!] Please insert the guild\'s ID.'.yellow); - } else { - let guild = client.guilds.get(args[1]); - console.log('[i] These are the channels that this guild have:'.blue); - for ([id, channel, guild] of guild && client.channels) { - console.log(` Channel: #${channel.name} - ID: ${channel.id}`.blue); - } - } - break; case 'leave': if (!args[1]) { console.log('[!] Please insert the guild\'s ID.'.yellow); } else { - let guild = client.guilds.get(args[1]); - guild.leave(); + let guild = client.guilds.cache.get(args[1]); + guild.leave().then(guild => { + console.log(`AleeBot has left ${guild.name}`) + }); } break; case 'broadcast': @@ -155,11 +146,13 @@ rl.on('line', function(cmd) { } else { const broadcast = args.join(' ').slice(48); let guild = null; - guild = client.guilds.get(args[1]); + guild = client.guilds.cache.get(args[1]); let channel = null; - channel = guild.channels.get(args[2]); + channel = guild.channels.cache.get(args[2]); if (channel != null) { - channel.send(broadcast); + channel.send(`**[Broadcast]** ${broadcast}`); + } else { + console.log('[X] Broadcast cannot be blank'.red) } } break; @@ -169,12 +162,17 @@ rl.on('line', function(cmd) { let uptimeMinutes = Math.floor(uptime / 60); const minutes = uptime % 60; let hours = 0; + let days = 0; while (uptimeMinutes >= 60) { hours++; uptimeMinutes = uptimeMinutes - 60; } + while (hours >= 24) { + days++; + hours = hours - 24; + } const uptimeSeconds = minutes % 60; - console.log(`[i] AleeBot has been up for ${hours} hours, ${uptimeMinutes} minutes, and ${uptimeSeconds} seconds.`.blue); + console.log(`[i] AleeBot has been up for ${days} days, ${hours} hours, ${uptimeMinutes} minutes, and ${uptimeSeconds} seconds.`); break; case 'activity': console.log('[i] Generating new activity'.blue); @@ -198,7 +196,6 @@ rl.on('line', function(cmd) { case 'help': let msg = ('AleeBot '+ settings.abVersion +' Console Help\n\n'); msg += ('guilds - Shows all guilds that AleeBot\'s on.\n'); - msg += ('channels - Shows all the channels that the guilds have.\n'); msg += ('leave - Leaves a guild.\n'); msg += ('broadcast - Broadcasts a message to a server.\n'); msg += ('uptime - Shows the uptime for AleeBot.\n'); @@ -239,7 +236,7 @@ client.on('ready', async () => { .setDescription('AleeBot has started') .addField('Version', settings.abVersion, true) .addField('Discord.JS Version', Discord.version, true) - .addField('Prefix', `\`${settings.prefix}\``, true) + .addField('Prefix', `\`${settings.prefix}\``) .setColor('#5cd65c'); let statusChannel = client.channels.cache.get(statusChannelID); if (!statusChannel) return console.error('The status channel does not exist! Skipping.'); @@ -388,12 +385,25 @@ client.on('guildDelete', (guild) => { statusChannel.send({ embeds: [logEmbed]}); }); -/* -AutoPoster(api.dbltoken, client) - .on('posted', () => { - log('[>] Posted stats to Top.gg!'.blue); - }) -*/ +client.on("messageReactionAdd", async (reaction, user) => { + // When a reaction is received, check if the structure is partial + if (reaction.partial) { + // If the message this reaction belongs to was removed, the fetching might result in an API error which should be handled + try { + await reaction.fetch(); + } catch (error) { + console.error('Something went wrong when fetching the message:', error); + // Return as `reaction.message.author` may be undefined/null + return; + } + } + + // Now the message has been cached and is fully available + console.log(`${reaction.message.author}'s message "${reaction.message.content}" gained a reaction!`); + // The reaction is now also fully available and the properties will be reflected accurately: + console.log(`${reaction.count} user(s) have given the same reaction to this message!`); +}); + client.on('messageCreate', async(msg) => { if (!client.application?.owner) await client.application?.fetch(); if (msg.author.bot) return; diff --git a/commands/addquote.js b/commands/addquote.js deleted file mode 100644 index 477d891..0000000 --- a/commands/addquote.js +++ /dev/null @@ -1,61 +0,0 @@ -/** ************************************** - * - * AddQuote: Command for AleeBot - * Copyright (C) 2017-2021 Alee Productions - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * *************************************/ -const quoteDB = require('../models/quote'); -const Discord = require("discord.js"); -module.exports.run = async (client, message, args) => { - if (!['242775871059001344'].includes(message.author.id)) return message.reply('**This command is disabled due to a new system being implemented.**'); - try { - let newAuthor; - let newAuthorImage; - let newQuote; - let newYear; - - const quote = await quoteDB.create({ - author: newAuthor, - authorImage: newAuthorImage, - quote: newQuote, - year: newYear - }) - - const setupEmbed = new Discord.MessageEmbed() - .setTitle('AleeBot Quote Setup', client.user.avatarURL()) - .setDescription('Input the data to the following embed') - .addField('Author', newAuthor, true) - .addField('Author Image (URL)', newAuthorImage, true) - .addField('Quote', newQuote, true) - .addField('Year', newYear, true); - - message.reply({embeds: [setupEmbed]}); - } catch (error) { - console.log(error) - } -}; - -exports.conf = { - aliases: [], - guildOnly: true, -}; -exports.help = { - name: 'addquote', - description: 'Sets the guild prefix.', - usage: 'addquote [author] [authorImage] [quote] [year]', - category: '- Quote Commands', -}; - diff --git a/commands/help.js b/commands/help.js index e925754..0b9191e 100644 --- a/commands/help.js +++ b/commands/help.js @@ -40,8 +40,9 @@ module.exports.run = async (client, message) => { const prefix = prefixes[message.guild.id].prefixes; if (!message.guild.members.cache.get(client.user.id).permissions.has('EMBED_LINKS')) return message.reply('ERROR: AleeBot doesn\'t have the permission to send embed links, please enable them to use the full help.'); const embed = new Discord.MessageEmbed() - .setAuthor('AleeBot ' + require('../storage/settings.json').abVersion + ` Help | Serving in ${client.guilds.cache.size} servers`, client.user.avatarURL()) - .setDescription('[!] Currently on the Alpha-Temp branch. Meaning that experimental features are enabled in this bot...') + .setAuthor('AleeBot ' + require('../storage/settings.json').abVersion + ` Help`, client.user.avatarURL()) + .setDescription('Every command you input into AleeBot is `ab:`') + .setFooter(`Currently serving on ${client.guilds.cache.size} servers`) .setColor('#1fd619') categories.forEach(function(x) { diff --git a/commands/interrogate.js b/commands/interrogate.js index 16a1887..3386352 100644 --- a/commands/interrogate.js +++ b/commands/interrogate.js @@ -18,7 +18,7 @@ * * *************************************/ module.exports.run = async (client, message, args) => { - if (message.guild.id != '243022206437687296') return message.reply('This is a Binaryworks exclusive command.'); + if (message.guild.id !== '243022206437687296') return message.reply('This is a Binaryworks exclusive command.'); if (!message.member.permissions.has('BAN_MEMBERS')) return message.reply('It looks like that you don\'t have the permissions to jail members.'); if (!message.guild.members.cache.get(client.user.id).permissions.has('MANAGE_ROLES')) return message.reply('Uhh... I don\'t have permission to jail members.'); @@ -38,5 +38,5 @@ exports.help = { name: 'interrogate', description: 'Interrogates a member', usage: 'interrogate [user]', - category: '- Binaryworks Exclusive Commands', + category: '- ALP Exclusive Commands', }; diff --git a/commands/quote.js b/commands/quote.js index 81f9142..37f5714 100644 --- a/commands/quote.js +++ b/commands/quote.js @@ -24,23 +24,23 @@ module.exports.run = async (client, message, args) => { if (quoteID === undefined) { const quoteList = await quoteDB.findAll({ attributes: ['id'] }) - quoteID = Math.floor(Math.random() * (quoteList.length - 1)) + 1 + const random = crypto.getRandomValues(new Uint32Array(1)); + quoteID = quoteList[random[0] % quoteList.length].id; } const quote = await quoteDB.findOne({ where: { id: quoteID } }) if (quote) { - const embed = new MessageEmbed() - .setAuthor({ name: quote.author, iconURL: quote.authorImage}) + const quoteEmbed = new MessageEmbed() + .setAuthor({ name: quote.author, iconURL: quote.authorImage }) .setDescription(quote.quote) .setColor('#1fd619') .setFooter('- ' + quote.year); - await message.reply('Alright, here\'s your quote.') - await message.channel.send({embeds:[embed]}); + await message.reply({ content: 'Alright, here\'s your quote.', embeds: [quoteEmbed] }) } else { - message.reply('Cannot find quote'); + message.reply('Cannot find quote, specify the correct quote id.'); } diff --git a/commands/serverinfo.js b/commands/serverinfo.js index 0a2e077..67442a2 100644 --- a/commands/serverinfo.js +++ b/commands/serverinfo.js @@ -20,14 +20,14 @@ module.exports.run = async (client, message) => { const Discord = require('discord.js'); const listedChannels = []; + let guildOwner = await message.guild.fetchOwner(); let memberCountNoBots = await message.guild.members.fetch().then((members) => members.filter(member => !member.user.bot).size); const embed = new Discord.MessageEmbed() .setAuthor(`${message.guild.name}`, `${message.guild.iconURL()}`) .setDescription('Server Information') .setThumbnail(message.guild.iconURL()) - .addField('Server Name:', `${message.guild.name}`) - .addField('Server ID:', `${message.guild.id}`) - .addField('Created At:', `${message.guild.createdAt.toUTCString()}`) + .addField('Main Information', `**Server Name:** ${message.guild.name}\n**Server ID:** ${message.guild.id}\n**Server Owner:** ${guildOwner.user.tag}`) + .addField('Join Dates', `**Created At:** ${message.guild.createdAt.toUTCString()}\n**AleeBot Joined:** ${message.guild.joinedAt.toUTCString()}`) /*message.guild.channels.cacheType.forEach(channel => { listedChannels.push(channel) })*/ diff --git a/commands/slowdown.js b/commands/slowdown.js index 44d8230..55e441b 100644 --- a/commands/slowdown.js +++ b/commands/slowdown.js @@ -21,7 +21,7 @@ module.exports.run = async (client, message, args) => { if (!message.member.permissions.has('MANAGE_CHANNELS')) return message.reply('It looks like that you don\'t have the permissions to slowdown channels.'); if (isNaN(args[0])) return message.reply('Please input a valid number to slowdown a channel.'); await message.channel.setRateLimitPerUser(args[0]); - message.channel.send(`This channel has been slowdowned for ${args[0]} second(s).`); + message.channel.send(`This channel has been slowdown for ${args[0]} second(s).`); }; diff --git a/commands/suggest.js b/commands/suggest.js index 0ca21b8..b503139 100644 --- a/commands/suggest.js +++ b/commands/suggest.js @@ -18,7 +18,7 @@ * * *************************************/ module.exports.run = async (client, message, args) => { - if (message.guild.id != '243022206437687296') return message.reply('This is a Binaryworks exclusive command.'); + if (message.guild.id !== '243022206437687296') return message.reply('This is a Andrew Lee Projects exclusive command.'); const {MessageEmbed} = require('discord.js'); client.channels.cache.get('427495678390960148').send({ embeds: [ new MessageEmbed() @@ -39,7 +39,7 @@ exports.conf = { }; exports.help = { name: 'suggest', - description: 'Suggest a feature in Binaryworks.', + description: 'Suggest a feature in Andrew Lee Projects.', usage: 'suggest [suggestion]', - category: '- Binaryworks Exclusive Commands', + category: '- ALP Exclusive Commands', }; diff --git a/commands/suggestfeature.js b/commands/suggestfeature.js index c7623d2..21b6849 100644 --- a/commands/suggestfeature.js +++ b/commands/suggestfeature.js @@ -1,5 +1,5 @@ /**************************************** - * + * * SuggestFeature: Command for AleeBot * Copyright (C) 2017-2021 Alee Productions * @@ -15,11 +15,11 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * + * * *************************************/ module.exports.run = async (client, message, args) => { const { MessageEmbed } = require('discord.js'); - + client.channels.cache.get('427495678390960148').send({ embeds: [ new MessageEmbed() .setColor('#1fd619') @@ -28,10 +28,10 @@ module.exports.run = async (client, message, args) => { .addField('Suggestion Contents', args.join(' ')) .setFooter(`Sending from ${message.guild.name}`, message.guild.iconURL())]} ); - await message.reply('Your suggestion has been shown to the Binaryworks discord server!'); - + await message.reply('Your suggestion has been shown to the Andrew Lee Projects discord server!'); + }; - + exports.conf = { aliases: [], guildOnly: false, @@ -42,4 +42,4 @@ exports.help = { usage: 'suggestfeature [suggestion]', category: '- General Commands', }; - + diff --git a/commands/userinfo.js b/commands/userinfo.js index a812dc4..bc7ec8e 100644 --- a/commands/userinfo.js +++ b/commands/userinfo.js @@ -23,7 +23,7 @@ module.exports.run = async (client, message) => { .setAuthor(message.author.tag, message.author.avatarURL()) .setDescription('User Information') .setThumbnail(message.author.avatarURL()) - .addField('Names', `**Username:** ${message.author.username}\n**Current Nickname:** ${message.member.displayName}`) + .addField('Names', `**Display Name:** ${message.member.displayName}\n**Username:** ${message.author.username}\n**Server Nickname:** ${message.member.displayName}`) .addField('Identity', `**User ID:** ${message.author.id} `) .addField('Create and Join Times', `**Created At:** ${message.member.user.createdAt.toUTCString()}\n**Joined Guild At:** ${message.member.joinedAt.toUTCString()}`) .setColor('#1fd619'); diff --git a/package.json b/package.json index 91c283c..4c23498 100644 --- a/package.json +++ b/package.json @@ -18,25 +18,19 @@ }, "homepage": "https://github.com/Alee14/AleeBot#readme", "dependencies": { - "@top-gg/sdk": "^3.1.2", "blessed": "^0.1.81", "colors": "^1.3.0", "discord.js": "^13.0.1", "eslint": "^7.1.0", "express": "^4.17.1", - "fs": "0.0.1-security", "git-last-commit": "^0.3.0", "i18next": "^19.4.4", "moment": "^2.21.0", - "mongoose": "^5.11.8", - "node-opus": "^0.3.0", "os": "^0.1.1", "parse-ms": "^1.0.1", "readline": "^1.3.0", "sequelize": "^6.30.0", - "sqlite3": "^5.1.6", - "topgg-autoposter": "^2.0.0", - "ytdl-core": "^0.20.4" + "sqlite3": "^5.1.6" }, "devDependencies": { "nodemon": "^2.0.2" diff --git a/storage/activities.js b/storage/activities.js index 418a038..2b2a286 100644 --- a/storage/activities.js +++ b/storage/activities.js @@ -87,12 +87,14 @@ const activities = [ 'MythOS', 'Also try Scratch!', 'Funky!', + 'Apple Vision Pro', 'What is Web3?', 'GNU\'s NOT UNIX!', 'Linux, but actually GNU/Linux', - 'Praise RMS!', + 'Praise RMS! (dont)', 'Praying to St IGNUcius', 'Debloating my ThinkPad', + 'Turbotastic!', 'Goddamn Idiotic Truckload of Windows', `Now running on Discord.JS ${version}!` ]; diff --git a/storage/settings.json b/storage/settings.json index 8f0e530..83932cc 100644 --- a/storage/settings.json +++ b/storage/settings.json @@ -1,4 +1,4 @@ { - "abVersion": "2.13.0 Alpha Temp Branch", + "abVersion": "2.13.0 Beta", "prefix": "abb:" } -- cgit v1.2.3 From 632ce4387c3458c87931528f4a047f0df103e5a7 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sat, 14 Oct 2023 00:23:17 -0400 Subject: Fixed some problems --- commands/help.js | 2 +- storage/settings.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'storage') diff --git a/commands/help.js b/commands/help.js index 0b9191e..7a824f1 100644 --- a/commands/help.js +++ b/commands/help.js @@ -41,7 +41,7 @@ module.exports.run = async (client, message) => { if (!message.guild.members.cache.get(client.user.id).permissions.has('EMBED_LINKS')) return message.reply('ERROR: AleeBot doesn\'t have the permission to send embed links, please enable them to use the full help.'); const embed = new Discord.MessageEmbed() .setAuthor('AleeBot ' + require('../storage/settings.json').abVersion + ` Help`, client.user.avatarURL()) - .setDescription('Every command you input into AleeBot is `ab:`') + .setDescription('Every command you input into AleeBot is `' + prefix + '`') .setFooter(`Currently serving on ${client.guilds.cache.size} servers`) .setColor('#1fd619') diff --git a/storage/settings.json b/storage/settings.json index 83932cc..b53fd84 100644 --- a/storage/settings.json +++ b/storage/settings.json @@ -1,4 +1,4 @@ { "abVersion": "2.13.0 Beta", - "prefix": "abb:" + "prefix": "ab:" } -- cgit v1.2.3 From f5de90ba89146008af78c16e798e216efccf0c50 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sat, 11 Jan 2025 11:55:18 -0500 Subject: Ability to add quotes, web interface, pending quotes --- api/server.js | 78 +++++++++++++++++ bot_discord.js | 30 +++---- commands/about.js | 3 +- commands/addquote.js | 198 +++++++++++++++++++++++++++--------------- commands/quote.js | 4 +- commands/setup.js | 6 +- deprecated/balance.js | 50 ----------- deprecated/buy.js | 114 ------------------------ deprecated/daily.js | 56 ------------ deprecated/pay.js | 60 ------------- models/quote.js | 27 +++++- package.json | 1 + storage/activities.js | 2 - storage/settings.json | 2 +- sync-database.js | 8 +- web/.gitignore | 24 +++++ web/.vscode/extensions.json | 4 + web/.vscode/launch.json | 11 +++ web/astro.config.mjs | 9 ++ web/bun.lockb | Bin 0 -> 172416 bytes web/package.json | 19 ++++ web/public/favicon.svg | 9 ++ web/src/components/Quotes.jsx | 86 ++++++++++++++++++ web/src/layouts/Layout.astro | 22 +++++ web/src/pages/index.astro | 29 +++++++ web/src/styles/Quote.css | 33 +++++++ web/tsconfig.json | 14 +++ yarn.lock | 12 ++- 28 files changed, 528 insertions(+), 383 deletions(-) create mode 100644 api/server.js delete mode 100644 deprecated/balance.js delete mode 100644 deprecated/buy.js delete mode 100644 deprecated/daily.js delete mode 100644 deprecated/pay.js create mode 100644 web/.gitignore create mode 100644 web/.vscode/extensions.json create mode 100644 web/.vscode/launch.json create mode 100644 web/astro.config.mjs create mode 100644 web/bun.lockb create mode 100644 web/package.json create mode 100644 web/public/favicon.svg create mode 100644 web/src/components/Quotes.jsx create mode 100644 web/src/layouts/Layout.astro create mode 100644 web/src/pages/index.astro create mode 100644 web/src/styles/Quote.css create mode 100644 web/tsconfig.json (limited to 'storage') diff --git a/api/server.js b/api/server.js new file mode 100644 index 0000000..a918308 --- /dev/null +++ b/api/server.js @@ -0,0 +1,78 @@ +const express = require('express'); +const cors = require('cors'); +const { pendingQuote, quote: approvedQuote } = require('../models/quote.js'); + +const app = express(); +const PORT = 3000; + +const createServer = () => { + app.use(cors()); // Allow cross-origin requests + app.use(express.json()); + + // Endpoint to get all pending quotes + app.get('/api/pending-quotes', async (req, res) => { + try { + const quotes = await pendingQuote.findAll(); + res.json(quotes); + } catch (error) { + console.error('Error fetching quotes:', error); + res.status(500).send('Internal Server Error'); + } + }); + + app.post('/api/approve-quote', async (req, res) => { + const { id } = req.body; + try { + const quote = await pendingQuote.findByPk(id); + if (quote) { + await approvedQuote.create({ + author: quote.author, + quote: quote.quote, + year: quote.year, + authorImage: quote.authorImage + }); + await pendingQuote.destroy({ where: { id } }); + res.status(200).send('Quote approved'); + } else { + res.status(404).send('Quote not found'); + } + } catch (error) { + console.error('Error approving quote:', error); + res.status(500).send('Internal Server Error'); + } + }); + + app.post('/api/reject-quote', async (req, res) => { + const { id } = req.body; + try { + const quote = await pendingQuote.findByPk(id); + if (quote) { + await pendingQuote.destroy({ where: { id } }); + res.status(200).send('Quote rejected'); + } else { + res.status(404).send('Quote not found'); + } + } catch (error) { + console.error('Error rejecting quote:', error); + res.status(500).send('Internal Server Error'); + } + }); + + app.get('/api/version', (req, res) => { + const { abVersion } = require('../storage/settings.json'); + res.json(abVersion); + + }); + + app.get('/' , (req, res) => { + res.send('API for AleeBot'); + // Most likely going to redirect to the frontend + }); + + // Start the server + app.listen(PORT, () => { + console.log(`Server is running on http://localhost:${PORT}`); + }); +}; + +module.exports = createServer; diff --git a/bot_discord.js b/bot_discord.js index df2264f..8bfa7da 100644 --- a/bot_discord.js +++ b/bot_discord.js @@ -1,7 +1,7 @@ /** ************************************** * * AleeBot: Made for discord servers - * Copyright (C) 2017-2022 Andrew Lee Projects + * Copyright (C) 2017-2025 Andrew Lee Projects * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,17 +24,16 @@ const client = new Discord.Client({ parse: ['users', 'roles'], repliedUser: true }, - intents: ['GUILDS', 'GUILD_MESSAGES', 'GUILD_MEMBERS', 'GUILD_MESSAGE_REACTIONS'] + intents: ['GUILDS', 'GUILD_MESSAGES', 'GUILD_MEMBERS', 'GUILD_MESSAGE_REACTIONS', 'DIRECT_MESSAGES', 'DIRECT_MESSAGE_REACTIONS'] }); const moment = require('moment'); -const express = require('express'); const fs = require('fs'); const readline = require('readline'); const colors = require('colors'); //const i18next = require('i18next'); -const web = express(); const settings = require('./storage/settings.json'); const { activity } = require('./storage/activities'); +const createServer = require("./api/server"); const active = new Map(); let autoRole = true; let readyEmbedMessage = true; @@ -50,11 +49,11 @@ const log = (message) => { function botPresence() { client.user.setPresence({ - activities: [{ - name: activity[Math.floor(Math.random() * activity.length)] - }], - status: 'online', - afk: false, + activities: [{ + name: activity[Math.floor(Math.random() * activity.length)] + }], + status: 'online', + afk: false, }); log(`[>] Updated bot presence to "${client.user.presence.activities[0].name}"`.green); } @@ -65,7 +64,7 @@ const rl = readline.createInterface({ prompt: '> '.gray, }); -console.log(`AleeBot ${settings.abVersion}: Copyright (C) 2017-2023 Andrew Lee Projects`.gray); +console.log(`AleeBot ${settings.abVersion}: Copyright (C) 2017-2025 Andrew Lee Projects`.gray); console.log('This program comes with ABSOLUTELY NO WARRANTY; for details type `show w\'.'.gray); console.log('This is free software, and you are welcome to redistribute it'.gray); console.log('under certain conditions; type `show c\' for details.\n'.gray); @@ -219,13 +218,7 @@ client.on('ready', async () => { botPresence(); - web.get('/', (req, res) => { - res.send("Hello World! This is going to become the AleeBot dashboard..."); - }); - - web.listen(process.env.port, () => { - console.log(`Listening at https://localhost:${process.env.port}`) - }) + createServer(); setInterval(function() { botPresence(); @@ -286,7 +279,7 @@ client.on('guildMemberRemove', (member) => { client.on('messageUpdate', async (oldMessage, newMessage) => { - if (oldMessage.guild.id !== serverWhitelist) return; + if (!oldMessage.guild || oldMessage.guild.id !== serverWhitelist) return; if (oldMessage.content === newMessage.content) { return; } @@ -407,6 +400,7 @@ client.on("messageReactionAdd", async (reaction, user) => { client.on('messageCreate', async(msg) => { if (!client.application?.owner) await client.application?.fetch(); if (msg.author.bot) return; + if (!msg.guild) return; const prefixes = JSON.parse(fs.readFileSync('./storage/prefixes.json', 'utf8')); diff --git a/commands/about.js b/commands/about.js index 7272b6a..0ae756d 100644 --- a/commands/about.js +++ b/commands/about.js @@ -17,7 +17,6 @@ * along with this program. If not, see . * * *************************************/ -const {MessageButton} = require("discord.js"); module.exports.run = async (client, message) => { const { MessageEmbed, MessageButton, MessageActionRow } = require('discord.js'); @@ -30,7 +29,7 @@ module.exports.run = async (client, message) => { .addField('About AleeBot', 'AleeBot is an all-in-one bot that\'s made from the Discord.JS API!') .addField('License', 'GNU General Public License v3.0') .addField('Contributors', Contributors) - .setFooter('© Copyright 2017-2023 Andrew Lee Projects') + .setFooter('© Copyright 2017-2025 Andrew Lee Projects') .setColor('#1fd619'); let Buttons = new MessageActionRow() diff --git a/commands/addquote.js b/commands/addquote.js index 5f2b9bc..52f7b21 100644 --- a/commands/addquote.js +++ b/commands/addquote.js @@ -17,105 +17,164 @@ * along with this program. If not, see . * * *************************************/ -const quoteDB = require('../models/quote'); +const { pendingQuote } = require('../models/quote'); const { MessageEmbed } = require("discord.js"); -module.exports.run = async (client, message, args) => { - if (!['242775871059001344'].includes(message.author.id)) return message.reply('**This command is disabled due to a new system being implemented.**'); - try { - let newAuthor; - let newAuthorImage; - let newQuote; - let newYear; - - let quoteOriginator; +module.exports.run = async (client, message) => { + try { + let newAuthor, newAuthorImage, newQuote, newYear; let isSetupRunning = false; const setupProcess = [ - 'Provide the name of the author.', - 'Submit the image of the author\nYou need to use a picture link that ends in .jpg or .png (like those from IMGUR or Google Images), and the picture should be either 128x128 pixels or 512x512 pixels in size.', - 'Enter the quote', - 'Specify the year from which the quote originates.' - ] - - let setupMessage = "Welcome to the AleeBot Quote Setup!\n" - setupMessage += "Please follow these rules when submitting quotes\n" - setupMessage += "```1. Do not use profanity or offensive language.\n" - setupMessage += "2. Do not send any personal information.\n" - setupMessage += "3. Only send noteworthy quotes.```\n" - setupMessage += "We reserve the right to reject any quotes that do not meet our criteria.\n" + 'Provide the name of the author:', + 'Submit the image of the author:\nYou need to use a picture link that ends in .jpg or .png (like those from IMGUR or Google Images), and the picture should be either 128x128 pixels or 512x512 pixels in size.', + 'Enter the quote:', + 'Specify the year from which the quote originates:' + ]; + + async function createQuote() { + await pendingQuote.create({ + author: newAuthor, + authorImage: newAuthorImage, + quote: newQuote, + year: newYear, + }); + } - let counter = 0 + let setupMessage = "Welcome to the AleeBot Quote Setup!\n"; + setupMessage += "Please follow these rules when submitting quotes:\n"; + setupMessage += "```1. Do not use profanity or offensive language.\n"; + setupMessage += "2. Do not send any personal information.\n"; + setupMessage += "3. Only send noteworthy quotes.```\n"; + setupMessage += "We reserve the right to reject any quotes that do not meet our criteria.\n"; if (isSetupRunning) { - return await message.reply('You are already setting up the quote.'); + return await message.reply('You are already setting up a quote.'); } - const filter = m => m.author.id === message.author.id + + const filter = (m) => m.author.id === message.author.id; isSetupRunning = true; - await message.reply(':arrow_left: Check your DMs to continue.') - await message.author.send(setupMessage); - await message.author.send(setupProcess[counter++]); + await message.reply(':arrow_left: Check DMs to continue.'); + + const dmChannel = await message.author.createDM(); + await dmChannel.send(setupMessage); + await dmChannel.send(setupProcess[0]); - const collector = message.channel.createMessageCollector({ + let counter = 1; + const collector = dmChannel.createMessageCollector({ filter, max: setupProcess.length, - time: 1000 * 60 + time: 1000 * 120 }); - collector.on('collect', message => { - console.log(`Collected ${message.content} from ${message.author.tag}`) - if (setupProcess.length > setupProcess.length + 1) { - message.author.send(setupProcess[counter++]); + collector.on('collect', async () => { + if (counter < setupProcess.length) { + await dmChannel.send(setupProcess[counter++]); } }); - collector.on('end', collected => { - if (collected.size === 0 && collected.size < 2) { - message.author.send('Quote setup was not completed, rerun the command.') + collector.on('end', async (collected) => { + if (collected.size < setupProcess.length) { + dmChannel.send('Quote setup was not completed. Please rerun the command.'); } else { - let quoteContent = []; - - collected.forEach((message) => { - quoteContent.push(message.content) - }) - - newAuthor = quoteContent[0] - newAuthorImage = quoteContent[1] - newQuote = quoteContent[2] - newYear = quoteContent[3] + const quoteContent = collected.map((m) => m.content); + newAuthor = quoteContent[0]; + newAuthorImage = quoteContent[1]; + newQuote = quoteContent[2]; + newYear = quoteContent[3]; const setupEmbed = new MessageEmbed() .setAuthor('AleeBot Quote Setup', client.user.avatarURL()) - .setDescription('Are you happy with this quote?\nThis quote will be sent for manual approval') + .setDescription('Are you happy with this quote?\nThis quote will be sent for manual approval automatically in 2 minutes.') .addField('Author', newAuthor) .addField('Author Image (URL)', newAuthorImage) .addField('Quote', newQuote) - .addField('Year', newYear); + .addField('Year', newYear) + .setColor('#1fd619'); + + let messageReact = await dmChannel.send({embeds: [setupEmbed]}); + await messageReact.react('🧑'); + await messageReact.react('📷'); + await messageReact.react('🖋️'); + await messageReact.react('📅'); + await messageReact.react('✅'); + await messageReact.react('❌'); + + const reactionFilter = (reaction, user) => { + return ['🧑', '📷', '🖋️', '📅', '✅', '❌'].includes(reaction.emoji.name) && user.id === message.author.id; + }; + + const reactionCollector = messageReact.createReactionCollector({ + filter: reactionFilter, + time: 1000 * 120 + }); + + reactionCollector.on('collect', async (reaction) => { + switch (reaction.emoji.name) { + case '🧑': + await dmChannel.send('You selected the author. Please provide the name of the author.'); + const authorResponse = await dmChannel.awaitMessages({ filter, max: 1, time: 60000 }); + if (authorResponse.size) newAuthor = authorResponse.first().content; + await dmChannel.send('Updated author name.'); + break; + case '📷': + await dmChannel.send('You selected the author image. Please provide the image URL.'); + const imageResponse = await dmChannel.awaitMessages({ filter, max: 1, time: 60000 }); + if (imageResponse.size) newAuthorImage = imageResponse.first().content; + await dmChannel.send('Updated author URL.'); + break; + case '🖋️': + await dmChannel.send('You selected the quote. Please provide the quote.'); + const quoteResponse = await dmChannel.awaitMessages({ filter, max: 1, time: 60000 }); + if (quoteResponse.size) newQuote = quoteResponse.first().content; + await dmChannel.send('Updated quote.'); + break; + case '📅': + await dmChannel.send('You selected the year. Please provide the year.'); + const yearResponse = await dmChannel.awaitMessages({ filter, max: 1, time: 60000 }); + if (yearResponse.size) newYear = yearResponse.first().content; + await dmChannel.send('Updated year.'); + break; + case '✅': + reactionCollector.stop('completed'); + break; + case '❌': + reactionCollector.stop('cancelled'); + break; + } + + const updatedEmbed = new MessageEmbed() + .setAuthor('AleeBot Quote Setup', client.user.avatarURL()) + .setDescription('Are you happy with this quote?\nThis quote will be sent for manual approval automatically in 2 minutes.') + .addField('Author', newAuthor) + .addField('Author Image (URL)', newAuthorImage) + .addField('Quote', newQuote) + .addField('Year', newYear) + .setColor('#1fd619'); + + await messageReact.edit({embeds: [updatedEmbed]}); + }); + + reactionCollector.on('end', async (collected, reason) => { + if (reason === 'cancelled') { + isSetupRunning = false; + dmChannel.send('Cancelling quote setup.'); + } else if (reason === 'completed') { + dmChannel.send('Sending this quote for manual approval.'); + isSetupRunning = false; + await createQuote(); + } else { + dmChannel.send('You have not responded. Sending this quote for manual approval.'); + isSetupRunning = false; + await createQuote(); + } + }); - message.author.send({embeds:[setupEmbed]}) - quoteOriginator = message.author.tag - console.log(`This quote has been originated from ${quoteOriginator}`) - isSetupRunning = false; } - }); - - /*await quoteDB.create({ - author: newAuthor, - authorImage: newAuthorImage, - quote: newQuote, - year: newYear, - });*/ - - //let messageReact = await message.author.send({embeds: [setupEmbed]}); - /*await messageReact.react('🧑'); - await messageReact.react('📷'); - await messageReact.react('🖋️'); - await messageReact.react('📅');*/ - } catch (error) { - console.log(error) + console.error(error); } }; @@ -123,6 +182,7 @@ exports.conf = { aliases: [], guildOnly: true, }; + exports.help = { name: 'addquote', description: 'Adds a quote to the database.', diff --git a/commands/quote.js b/commands/quote.js index 37f5714..02699cd 100644 --- a/commands/quote.js +++ b/commands/quote.js @@ -18,7 +18,7 @@ * * *************************************/ module.exports.run = async (client, message, args) => { - const quoteDB = require('../models/quote'); + const { quote: quoteDB } = require('../models/quote'); const { MessageEmbed } = require('discord.js'); let quoteID = args[0]; @@ -38,7 +38,7 @@ module.exports.run = async (client, message, args) => { .setColor('#1fd619') .setFooter('- ' + quote.year); - await message.reply({ content: 'Alright, here\'s your quote.', embeds: [quoteEmbed] }) + await message.reply({ embeds: [quoteEmbed] }) } else { message.reply('Cannot find quote, specify the correct quote id.'); } diff --git a/commands/setup.js b/commands/setup.js index 5c2f232..380e85e 100644 --- a/commands/setup.js +++ b/commands/setup.js @@ -20,14 +20,12 @@ module.exports.run = async (client, message) => { if (!['242775871059001344', message.guild.ownerId].includes(message.author.id)) return message.reply(':warning: You must be a server owner or be the creator of the bot to access this command.'); - message.reply('Look at your DMs.'); - //message.reply("This feature is coming soon. Stay tuned!"); + message.reply(':arrow_left: Check DMs to continue.'); const Discord = require('discord.js'); const setupEmbed = new Discord.MessageEmbed() .setTitle('AleeBot Setup', client.user.avatarURL()) .setDescription('Select the options') - .addField('Chat Logs', 'channelid', true) - .addField('Joining & Leaving Logs', 'placeholder', true) + .addField('Logging', 'channelid', true) .addField('Broadcast', 'placeholder', true) .addField('Broadcast', 'placeholder', true); diff --git a/deprecated/balance.js b/deprecated/balance.js deleted file mode 100644 index bf7618c..0000000 --- a/deprecated/balance.js +++ /dev/null @@ -1,50 +0,0 @@ -/** ************************************** - * - * Balance: Command for AleeBot - * Copyright (C) 2017-2021 Alee Productions - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * *************************************/ -module.exports.run = async (client, message) => { - const db = require('quick.db'); - const {MessageEmbed} = require('discord.js'); - - const user = message.mentions.users.first() || message.author; - - let balance = await db.fetch(`userBalance_${user.id}`); - - if (balance === null) { - db.set(`userBalance_${message.author.id}`, 0); - balance = 0; - } - const embed = new MessageEmbed() - .setDescription('**AleeCorp Bank**') - .addField('Account Holder: ', user.username, true) - .addField('Account Balance: ', balance, true) - .setColor('#1fd619'); - - message.channel.send({embed}); -}; - -exports.conf = { - aliases: ['bal', 'money'], - guildOnly: false, -}; -exports.help = { - name: 'balance', - description: 'Checks the balance of AleeBot', - usage: 'balance [@someone (optional)]', - category: '- Economy Commands', -}; diff --git a/deprecated/buy.js b/deprecated/buy.js deleted file mode 100644 index 98d4fcf..0000000 --- a/deprecated/buy.js +++ /dev/null @@ -1,114 +0,0 @@ -/** ************************************** - * - * Buy: Command for AleeBot - * Copyright (C) 2017-2021 Alee Productions - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * *************************************/ -module.exports.run = async (client, message, args) => { -const Discord = require('discord.js'); -const fs = require('fs') -const db = require('quick.db'); -const items = JSON.parse(fs.readFileSync('./storage/items.json', 'utf8')); - - let categories = []; - - if (!args.join(" ")) { - - - for (var i in items) { - - - if (!categories.includes(items[i].type)) { - categories.push(items[i].type) - } - - } - - - const embed = new Discord.MessageEmbed() - .setDescription(`Available Items`) - .setColor('#1fd619') - - for (var i = 0; i < categories.length; i++) { - - var tempDesc = ''; - - for (var c in items) { - if (categories[i] === items[c].type) { - - tempDesc += `${items[c].name} - ${items[c].price}$ - ${items[c].desc}\n`; - - } - - } - - embed.addField(categories[i], tempDesc); - - } - - - return message.channel.send({ - embed - }); - - - } - - let itemName = ''; - let itemPrice = 0; - let itemDesc = ''; - - for (var i in items) { - if (args.join(" ").trim().toUpperCase() === items[i].name.toUpperCase()) { - itemName = items[i].name; - itemPrice = items[i].price; - itemDesc = items[i].desc; - } - } - - - if (itemName === '') { - return message.channel.send(`Item ${args.join(" ").trim()} not found.`) - } - - let selfBalance = await db.fetch(`userBalance_${message.author.id}`); - - if (selfBalance === null) { - db.set(`userBalance_${message.author.id}`, 0); - selfBalance = 0 - } - - if (itemPrice > selfBalance) return message.reply('You don\'t have enough money for this item.') - - db.subtract(`userBalance_${message.author.id}`, itemPrice); - - if (itemName === 'Programmer Role') { - message.guild.members.get(message.author.id).addRole(message.guild.roles.find("name", "Programmers")); - } - - message.channel.send('You bought ' + itemName + '!'); -}; - -exports.conf = { - aliases: [], - guildOnly: false, -}; -exports.help = { - name: 'buy', - description: 'Buy things.', - usage: 'buy [item]', - category: '- Economy Commands', -}; diff --git a/deprecated/daily.js b/deprecated/daily.js deleted file mode 100644 index 4a38f26..0000000 --- a/deprecated/daily.js +++ /dev/null @@ -1,56 +0,0 @@ -/** ************************************** - * - * Daily: Command for AleeBot - * Copyright (C) 2017-2021 Alee Productions - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * *************************************/ -const db = require('quick.db'); -ms = require('parse-ms'); - -module.exports.run = async (client, message) => { - const cooldown = 8.64e+7; - const amount = 100; - - const lastDaily = await db.fetch(`lastDaily_${message.author.id}`); - - if (lastDaily !== null && cooldown - (Date.now() - lastDaily) > 0) { - const timeObj = ms(cooldown - (Date.now() - lastDaily)); - - message.reply(`You already collected your money, please wait **${timeObj.hours}h ${timeObj.minutes}m**!`); - } else { - message.channel.send(`You have successfully collected $${amount} dollars!`); - - const balance = await db.fetch(`userBalance_${message.author.id}`); - - if (balance == null) { - db.set(`userBalance_${message.author.id}`, 0); - } - - db.set(`lastDaily_${message.author.id}`, Date.now()); - db.add(`userBalance_${message.author.id}`, 100); - } -}; - -exports.conf = { - aliases: [], - guildOnly: false, -}; -exports.help = { - name: 'daily', - description: 'This gives you money everyday.', - usage: 'daily', - category: '- Economy Commands', -}; diff --git a/deprecated/pay.js b/deprecated/pay.js deleted file mode 100644 index 42e0f28..0000000 --- a/deprecated/pay.js +++ /dev/null @@ -1,60 +0,0 @@ -/** ************************************** - * - * Pay: Command for AleeBot - * Copyright (C) 2017-2021 Alee Productions - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * *************************************/ - -module.exports.run = async (client, message, args) => { - const db = require('quick.db'); - if (!message.mentions.members.first()) return message.reply('Please mention a user...'); - - const targetMember = message.mentions.members.first(); - const amount = parseInt(args.join(' ').replace(targetMember, '')); - - if (isNaN(amount)) return message.reply('Please define an amount.'); - - let targetBalance = await db.fetch(`userBalance_${targetMember.id}`); - let selfBalance = await db.fetch(`userBalance_${message.author.id}`); - - if (targetBalance === null) { - db.set(`userBalance_${targetMember.id}`, 0); - targetBalance = 0; - } - - if (selfBalance === null) { - db.set(`userBalance_${message.author.id}`, 0); - selfBalance = 0; - } - - if (amount > selfBalance) return message.reply('Sorry you don\'t have enough money.'); - - db.add(`userBalance_${targetMember.id}`, amount); - db.subtract(`userBalance_${message.author.id}`, amount); - - message.reply(`Successfully transfered $${amount} to ${targetMember.user}`); -}; - -exports.conf = { - aliases: ['transfer'], - guildOnly: false, -}; -exports.help = { - name: 'pay', - description: 'You can pay others!', - usage: 'pay [@user] [interger]', - category: '- Economy Commands', -}; diff --git a/models/quote.js b/models/quote.js index f31b472..eab4f57 100644 --- a/models/quote.js +++ b/models/quote.js @@ -26,4 +26,29 @@ const quote = sequelize.define('quotes', { }) -module.exports = quote +const pendingQuote = sequelize.define('pending-quotes', { + id: { + type: Sequelize.INTEGER, + autoIncrement: true, + primaryKey: true + }, + author: { + type: Sequelize.STRING, + allowNull: false + }, + authorImage: { + type: Sequelize.STRING, + allowNull: false + }, + quote: { + type: Sequelize.TEXT, + allowNull: false + }, + year: { + type: Sequelize.STRING, + allowNull: false + } + +}) + +module.exports = { quote, pendingQuote }; diff --git a/package.json b/package.json index 6e07caa..9584d19 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "dependencies": { "blessed": "^0.1.81", "colors": "^1.3.0", + "cors": "^2.8.5", "discord.js": "^13.0.1", "dotenv": "^16.3.1", "eslint": "^7.1.0", diff --git a/storage/activities.js b/storage/activities.js index 2b2a286..5d0161e 100644 --- a/storage/activities.js +++ b/storage/activities.js @@ -92,10 +92,8 @@ const activities = [ 'GNU\'s NOT UNIX!', 'Linux, but actually GNU/Linux', 'Praise RMS! (dont)', - 'Praying to St IGNUcius', 'Debloating my ThinkPad', 'Turbotastic!', - 'Goddamn Idiotic Truckload of Windows', `Now running on Discord.JS ${version}!` ]; diff --git a/storage/settings.json b/storage/settings.json index b53fd84..83932cc 100644 --- a/storage/settings.json +++ b/storage/settings.json @@ -1,4 +1,4 @@ { "abVersion": "2.13.0 Beta", - "prefix": "ab:" + "prefix": "abb:" } diff --git a/sync-database.js b/sync-database.js index 2462f29..f7b9211 100644 --- a/sync-database.js +++ b/sync-database.js @@ -1,9 +1,13 @@ -const quoteDB = require("./models/quote"); +const { quote, pendingQuote } = require("./models/quote"); const guildDB = require ('./models/guild-settings'); -quoteDB.sync({alter: true}).then(() => { +quote.sync({alter: true}).then(() => { console.log('Quote database synced!') }); +pendingQuote.sync({alter: true}).then(() => { + console.log('Pending Quote database synced!') +}); + guildDB.sync({alter: true}).then(() => { console.log('Guild database synced!') }); diff --git a/web/.gitignore b/web/.gitignore new file mode 100644 index 0000000..016b59e --- /dev/null +++ b/web/.gitignore @@ -0,0 +1,24 @@ +# build output +dist/ + +# generated types +.astro/ + +# dependencies +node_modules/ + +# logs +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* + +# environment variables +.env +.env.production + +# macOS-specific files +.DS_Store + +# jetbrains setting folder +.idea/ diff --git a/web/.vscode/extensions.json b/web/.vscode/extensions.json new file mode 100644 index 0000000..22a1505 --- /dev/null +++ b/web/.vscode/extensions.json @@ -0,0 +1,4 @@ +{ + "recommendations": ["astro-build.astro-vscode"], + "unwantedRecommendations": [] +} diff --git a/web/.vscode/launch.json b/web/.vscode/launch.json new file mode 100644 index 0000000..d642209 --- /dev/null +++ b/web/.vscode/launch.json @@ -0,0 +1,11 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "command": "./node_modules/.bin/astro dev", + "name": "Development server", + "request": "launch", + "type": "node-terminal" + } + ] +} diff --git a/web/astro.config.mjs b/web/astro.config.mjs new file mode 100644 index 0000000..53e49de --- /dev/null +++ b/web/astro.config.mjs @@ -0,0 +1,9 @@ +// @ts-check +import { defineConfig } from 'astro/config'; + +import react from '@astrojs/react'; + +// https://astro.build/config +export default defineConfig({ + integrations: [react()] +}); \ No newline at end of file diff --git a/web/bun.lockb b/web/bun.lockb new file mode 100644 index 0000000..b648049 Binary files /dev/null and b/web/bun.lockb differ diff --git a/web/package.json b/web/package.json new file mode 100644 index 0000000..811ab8b --- /dev/null +++ b/web/package.json @@ -0,0 +1,19 @@ +{ + "name": "aleebot-web", + "type": "module", + "version": "0.0.1", + "scripts": { + "dev": "astro dev", + "build": "astro build", + "preview": "astro preview", + "astro": "astro" + }, + "dependencies": { + "@astrojs/react": "^4.1.3", + "@types/react": "^19.0.4", + "@types/react-dom": "^19.0.2", + "astro": "^5.1.5", + "react": "^19.0.0", + "react-dom": "^19.0.0" + } +} diff --git a/web/public/favicon.svg b/web/public/favicon.svg new file mode 100644 index 0000000..f157bd1 --- /dev/null +++ b/web/public/favicon.svg @@ -0,0 +1,9 @@ + + + + diff --git a/web/src/components/Quotes.jsx b/web/src/components/Quotes.jsx new file mode 100644 index 0000000..1d563e7 --- /dev/null +++ b/web/src/components/Quotes.jsx @@ -0,0 +1,86 @@ +import { useState, useEffect } from 'react'; +import '../styles/Quote.css' + +export function PendingQuotes() { + const [quotes, setQuotes] = useState([]); + + const fetchQuotes = async () => { + try { + const response = await fetch('http://localhost:3000/api/pending-quotes'); + const data = await response.json(); + setQuotes(data); + } catch (error) { + console.error('Failed to fetch quotes:', error); + } + }; + + useEffect(() => { + fetchQuotes(); + }, []); + + const approveQuote = async (id) => { + try { + const response = await fetch('http://localhost:3000/api/approve-quote', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ id }), + }); + + if (response.ok) { + fetchQuotes(); // Refresh the listing after approving the quote + } else { + console.error('Failed to approve quote'); + } + } catch (error) { + console.error('Error approving quote:', error); + } + }; + + const rejectQuote = async (id) => { + try { + const response = await fetch('http://localhost:3000/api/reject-quote', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ id }), + }); + + if (response.ok) { + fetchQuotes(); // Refresh the listing after approving the quote + } else { + console.error('Failed to reject quote'); + } + } catch (error) { + console.error('Error rejecting quote:', error); + } + }; + + return ( +
+

Pending Quotes

+ {quotes.length > 0 ? ( +
    + {quotes.map((quote) => ( +
  • +
    +
    + No Profile +

    {quote.author}

    +
    +

    {quote.quote}

    + - {quote.year} +
    + + +
  • + ))} +
+ ) : ( +

No pending quotes available.

+ )} +
+ ); +} diff --git a/web/src/layouts/Layout.astro b/web/src/layouts/Layout.astro new file mode 100644 index 0000000..e455c61 --- /dev/null +++ b/web/src/layouts/Layout.astro @@ -0,0 +1,22 @@ + + + + + + + + Astro Basics + + + + + + + diff --git a/web/src/pages/index.astro b/web/src/pages/index.astro new file mode 100644 index 0000000..b5c607d --- /dev/null +++ b/web/src/pages/index.astro @@ -0,0 +1,29 @@ +--- +import Layout from '../layouts/Layout.astro'; +import { PendingQuotes } from '../components/Quotes'; + +const version = await fetch('http://localhost:3000/api/version').then(res => res.json()); +--- + + +
+

AleeBot {version}

+ +
+
+ + diff --git a/web/src/styles/Quote.css b/web/src/styles/Quote.css new file mode 100644 index 0000000..8adfb29 --- /dev/null +++ b/web/src/styles/Quote.css @@ -0,0 +1,33 @@ +.quote { + display: flex; + flex-direction: column; + background: #555555; + color: #FFFFFF; + padding: 1em; +} + +ul.quoteList { + margin: 0; + padding: 0; +} + +li.quoteList { + list-style-type: none; + margin-top: 1em; + margin-bottom: 1em; +} + +.author { + display: flex; + flex-direction: row; +} + +h1.quoteAuthor { + font-size: 1.5em; + padding: 0; + margin: 0 0 0 .5em; +} + +.quoteText { + margin: .5em 0; +} diff --git a/web/tsconfig.json b/web/tsconfig.json new file mode 100644 index 0000000..69c1600 --- /dev/null +++ b/web/tsconfig.json @@ -0,0 +1,14 @@ +{ + "extends": "astro/tsconfigs/strict", + "include": [ + ".astro/types.d.ts", + "**/*" + ], + "exclude": [ + "dist" + ], + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "react" + } +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 5942f18..d266f22 100644 --- a/yarn.lock +++ b/yarn.lock @@ -513,6 +513,14 @@ cookie@0.5.0: resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.5.0.tgz#d1f5d71adec6558c58f389987c366aa47e994f8b" integrity sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw== +cors@^2.8.5: + version "2.8.5" + resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29" + integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g== + dependencies: + object-assign "^4" + vary "^1" + cross-spawn@^7.0.2: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" @@ -1507,7 +1515,7 @@ npmlog@^6.0.0: gauge "^4.0.3" set-blocking "^2.0.0" -object-assign@^4.1.1: +object-assign@^4, object-assign@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== @@ -2100,7 +2108,7 @@ validator@^13.7.0: resolved "https://registry.yarnpkg.com/validator/-/validator-13.9.0.tgz#33e7b85b604f3bbce9bb1a05d5c3e22e1c2ff855" integrity sha512-B+dGG8U3fdtM0/aNK4/X8CXq/EcxU2WPrPEkJGslb47qyHsxmbggTWK0yEA4qnYVNF+nxNlN88o14hIcPmSIEA== -vary@~1.1.2: +vary@^1, vary@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== -- cgit v1.2.3 From 7e65ae0e135098acad76b8081f34478b4efc077f Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sat, 11 Jan 2025 18:02:05 -0500 Subject: Cleaned up some code, author image now support attachments --- api/routes/quotes.js | 58 +++++++++++++++++++++++++++++ api/server.js | 56 +--------------------------- commands/addquote.js | 87 ++++++++++++++++++++++++++----------------- commands/quote.js | 4 ++ commands/setup.js | 3 +- models/quote.js | 20 ++++++++++ storage/activities.js | 1 - web/astro.config.mjs | 2 +- web/src/components/Quotes.jsx | 1 + web/src/layouts/Layout.astro | 2 +- web/src/pages/index.astro | 19 +++++++++- 11 files changed, 159 insertions(+), 94 deletions(-) create mode 100644 api/routes/quotes.js (limited to 'storage') diff --git a/api/routes/quotes.js b/api/routes/quotes.js new file mode 100644 index 0000000..39aba7b --- /dev/null +++ b/api/routes/quotes.js @@ -0,0 +1,58 @@ +const express = require('express'); +const quoteDB = require('../../models/quote.js'); + +const router = express.Router(); + +const pendingQuote = quoteDB.pendingQuote; +const approvedQuote = quoteDB.quote; + +router.get('/pending-quotes', async (req, res) => { + try { + const quotes = await pendingQuote.findAll(); + res.json(quotes); + } catch (error) { + console.error('Error fetching quotes:', error); + res.status(500).send('Internal Server Error'); + } +}); + +router.post('/approve-quote', async (req, res) => { + const { id } = req.body; + try { + const quote = await pendingQuote.findByPk(id); + if (quote) { + await approvedQuote.create({ + author: quote.author, + authorImage: quote.authorImage, + quote: quote.quote, + year: quote.year, + submitter: quote.submitterID + }); + await pendingQuote.destroy({ where: { id } }); + res.status(200).send('Quote approved'); + } else { + res.status(404).send('Quote not found'); + } + } catch (error) { + console.error('Error approving quote:', error); + res.status(500).send('Internal Server Error'); + } +}); + +router.post('/reject-quote', async (req, res) => { + const { id } = req.body; + try { + const quote = await pendingQuote.findByPk(id); + if (quote) { + await pendingQuote.destroy({ where: { id } }); + res.status(200).send('Quote rejected'); + } else { + res.status(404).send('Quote not found'); + } + } catch (error) { + console.error('Error rejecting quote:', error); + res.status(500).send('Internal Server Error'); + } +}); + +module.exports = router; diff --git a/api/server.js b/api/server.js index a918308..a6cb48c 100644 --- a/api/server.js +++ b/api/server.js @@ -1,6 +1,6 @@ const express = require('express'); const cors = require('cors'); -const { pendingQuote, quote: approvedQuote } = require('../models/quote.js'); +const quotesRouter = require('./routes/quotes'); const app = express(); const PORT = 3000; @@ -9,54 +9,7 @@ const createServer = () => { app.use(cors()); // Allow cross-origin requests app.use(express.json()); - // Endpoint to get all pending quotes - app.get('/api/pending-quotes', async (req, res) => { - try { - const quotes = await pendingQuote.findAll(); - res.json(quotes); - } catch (error) { - console.error('Error fetching quotes:', error); - res.status(500).send('Internal Server Error'); - } - }); - - app.post('/api/approve-quote', async (req, res) => { - const { id } = req.body; - try { - const quote = await pendingQuote.findByPk(id); - if (quote) { - await approvedQuote.create({ - author: quote.author, - quote: quote.quote, - year: quote.year, - authorImage: quote.authorImage - }); - await pendingQuote.destroy({ where: { id } }); - res.status(200).send('Quote approved'); - } else { - res.status(404).send('Quote not found'); - } - } catch (error) { - console.error('Error approving quote:', error); - res.status(500).send('Internal Server Error'); - } - }); - - app.post('/api/reject-quote', async (req, res) => { - const { id } = req.body; - try { - const quote = await pendingQuote.findByPk(id); - if (quote) { - await pendingQuote.destroy({ where: { id } }); - res.status(200).send('Quote rejected'); - } else { - res.status(404).send('Quote not found'); - } - } catch (error) { - console.error('Error rejecting quote:', error); - res.status(500).send('Internal Server Error'); - } - }); + app.use('/api', quotesRouter); app.get('/api/version', (req, res) => { const { abVersion } = require('../storage/settings.json'); @@ -64,11 +17,6 @@ const createServer = () => { }); - app.get('/' , (req, res) => { - res.send('API for AleeBot'); - // Most likely going to redirect to the frontend - }); - // Start the server app.listen(PORT, () => { console.log(`Server is running on http://localhost:${PORT}`); diff --git a/commands/addquote.js b/commands/addquote.js index 52f7b21..f13d3c9 100644 --- a/commands/addquote.js +++ b/commands/addquote.js @@ -20,14 +20,21 @@ const { pendingQuote } = require('../models/quote'); const { MessageEmbed } = require("discord.js"); +const setupUsers = new Set(); + module.exports.run = async (client, message) => { try { let newAuthor, newAuthorImage, newQuote, newYear; - let isSetupRunning = false; + + if (setupUsers.has(message.author.id)) { + return await message.reply('You are already setting up a quote.'); + } + + setupUsers.add(message.author.id); const setupProcess = [ 'Provide the name of the author:', - 'Submit the image of the author:\nYou need to use a picture link that ends in .jpg or .png (like those from IMGUR or Google Images), and the picture should be either 128x128 pixels or 512x512 pixels in size.', + 'Submit the image of the author:\nYou can use an attachment or a link that ends in .jpg/.jpeg or .png (like those from IMGUR or Google Images), and the picture should be either 128x128 pixels or 512x512 pixels in size.', 'Enter the quote:', 'Specify the year from which the quote originates:' ]; @@ -38,23 +45,38 @@ module.exports.run = async (client, message) => { authorImage: newAuthorImage, quote: newQuote, year: newYear, + submitterAuthor: message.author.username, + submitterID: message.author.id }); } + async function imageCheck(message) { + const attachment = message.attachments.first(); + if (attachment) { + const fileExtension = attachment.name.split('.').pop().toLowerCase(); + if (['jpg', 'png', 'jpeg'].includes(fileExtension)) { + newAuthorImage = attachment.url.toString(); // Use the attachment's URL directly + } else { + await dmChannel.send('Invalid file type. Please attach a .jpg or .png image.'); + return await imageCheck(message); + } + } else if (msg.content.startsWith('http') && (message.content.endsWith('.jpg') || message.content.endsWith('.jpeg') || message.content.endsWith('.png'))) { + newAuthorImage = msg.content; // Use the provided URL + } else { + await dmChannel.send('Invalid input. Please provide an image URL or attach an image file.'); + return await imageCheck(message); + } + } + let setupMessage = "Welcome to the AleeBot Quote Setup!\n"; setupMessage += "Please follow these rules when submitting quotes:\n"; - setupMessage += "```1. Do not use profanity or offensive language.\n"; + setupMessage += "```1. No offensive content (NSFW, Racism, etc).\n"; setupMessage += "2. Do not send any personal information.\n"; setupMessage += "3. Only send noteworthy quotes.```\n"; setupMessage += "We reserve the right to reject any quotes that do not meet our criteria.\n"; - if (isSetupRunning) { - return await message.reply('You are already setting up a quote.'); - } - const filter = (m) => m.author.id === message.author.id; - isSetupRunning = true; await message.reply(':arrow_left: Check DMs to continue.'); const dmChannel = await message.author.createDM(); @@ -65,10 +87,14 @@ module.exports.run = async (client, message) => { const collector = dmChannel.createMessageCollector({ filter, max: setupProcess.length, - time: 1000 * 120 + time: 1000 * 1200 }); - collector.on('collect', async () => { + collector.on('collect', async (msg) => { + if (counter === 2) { // Collecting author image + await imageCheck(msg); + } + if (counter < setupProcess.length) { await dmChannel.send(setupProcess[counter++]); } @@ -77,20 +103,23 @@ module.exports.run = async (client, message) => { collector.on('end', async (collected) => { if (collected.size < setupProcess.length) { dmChannel.send('Quote setup was not completed. Please rerun the command.'); + setupUsers.delete(message.author.id); } else { const quoteContent = collected.map((m) => m.content); newAuthor = quoteContent[0]; - newAuthorImage = quoteContent[1]; + if (!newAuthorImage) { + newAuthorImage = quoteContent[1] || 'N/A'; + } newQuote = quoteContent[2]; newYear = quoteContent[3]; const setupEmbed = new MessageEmbed() .setAuthor('AleeBot Quote Setup', client.user.avatarURL()) - .setDescription('Are you happy with this quote?\nThis quote will be sent for manual approval automatically in 2 minutes.') - .addField('Author', newAuthor) - .addField('Author Image (URL)', newAuthorImage) - .addField('Quote', newQuote) - .addField('Year', newYear) + .setDescription('Are you happy with this quote?\nThis quote will be sent for manual approval automatically in 20 minutes.') + .addField('Author', newAuthor || 'N/A') + .addField('Author Image (URL)', newAuthorImage || 'N/A') + .addField('Quote', newQuote || 'N/A') + .addField('Year', newYear || 'N/A') .setColor('#1fd619'); let messageReact = await dmChannel.send({embeds: [setupEmbed]}); @@ -107,7 +136,7 @@ module.exports.run = async (client, message) => { const reactionCollector = messageReact.createReactionCollector({ filter: reactionFilter, - time: 1000 * 120 + time: 1000 * 1200 }); reactionCollector.on('collect', async (reaction) => { @@ -119,10 +148,10 @@ module.exports.run = async (client, message) => { await dmChannel.send('Updated author name.'); break; case '📷': - await dmChannel.send('You selected the author image. Please provide the image URL.'); + await dmChannel.send('You selected the author image. Please provide the image URL or attach an image file.'); const imageResponse = await dmChannel.awaitMessages({ filter, max: 1, time: 60000 }); - if (imageResponse.size) newAuthorImage = imageResponse.first().content; - await dmChannel.send('Updated author URL.'); + await imageCheck(imageResponse.first()); + await dmChannel.send('Updated author image.'); break; case '🖋️': await dmChannel.send('You selected the quote. Please provide the quote.'); @@ -144,36 +173,26 @@ module.exports.run = async (client, message) => { break; } - const updatedEmbed = new MessageEmbed() - .setAuthor('AleeBot Quote Setup', client.user.avatarURL()) - .setDescription('Are you happy with this quote?\nThis quote will be sent for manual approval automatically in 2 minutes.') - .addField('Author', newAuthor) - .addField('Author Image (URL)', newAuthorImage) - .addField('Quote', newQuote) - .addField('Year', newYear) - .setColor('#1fd619'); - - await messageReact.edit({embeds: [updatedEmbed]}); + await messageReact.edit({embeds: [setupEmbed]}); }); reactionCollector.on('end', async (collected, reason) => { if (reason === 'cancelled') { - isSetupRunning = false; dmChannel.send('Cancelling quote setup.'); } else if (reason === 'completed') { dmChannel.send('Sending this quote for manual approval.'); - isSetupRunning = false; await createQuote(); } else { dmChannel.send('You have not responded. Sending this quote for manual approval.'); - isSetupRunning = false; await createQuote(); } + setupUsers.delete(message.author.id); }); - } }); } catch (error) { + message.author.send('An error occurred while setting up the quote. Please try again.'); + setupUsers.delete(message.author.id); console.error(error); } }; diff --git a/commands/quote.js b/commands/quote.js index 02699cd..0d67b66 100644 --- a/commands/quote.js +++ b/commands/quote.js @@ -38,6 +38,10 @@ module.exports.run = async (client, message, args) => { .setColor('#1fd619') .setFooter('- ' + quote.year); + if (quote.url) { + quoteEmbed.setURL(quote.url); + } + await message.reply({ embeds: [quoteEmbed] }) } else { message.reply('Cannot find quote, specify the correct quote id.'); diff --git a/commands/setup.js b/commands/setup.js index 380e85e..c797f7d 100644 --- a/commands/setup.js +++ b/commands/setup.js @@ -27,7 +27,8 @@ module.exports.run = async (client, message) => { .setDescription('Select the options') .addField('Logging', 'channelid', true) .addField('Broadcast', 'placeholder', true) - .addField('Broadcast', 'placeholder', true); + .addField('Quote of the Day', 'placeholder', true) + .addField('QOTD Channel', 'channelid', true); message.author.send({embeds: [setupEmbed]}); }; diff --git a/models/quote.js b/models/quote.js index eab4f57..b68dfbc 100644 --- a/models/quote.js +++ b/models/quote.js @@ -22,6 +22,14 @@ const quote = sequelize.define('quotes', { year: { type: Sequelize.STRING, allowNull: false + }, + url: { + type: Sequelize.STRING, + allowNull: true + }, + submitter: { + type: Sequelize.STRING, + allowNull: false } }) @@ -47,6 +55,18 @@ const pendingQuote = sequelize.define('pending-quotes', { year: { type: Sequelize.STRING, allowNull: false + }, + url: { + type: Sequelize.STRING, + allowNull: true + }, + submitterAuthor: { + type: Sequelize.STRING, + allowNull: false + }, + submitterID: { + type: Sequelize.STRING, + allowNull: false } }) diff --git a/storage/activities.js b/storage/activities.js index 5d0161e..be28e58 100644 --- a/storage/activities.js +++ b/storage/activities.js @@ -91,7 +91,6 @@ const activities = [ 'What is Web3?', 'GNU\'s NOT UNIX!', 'Linux, but actually GNU/Linux', - 'Praise RMS! (dont)', 'Debloating my ThinkPad', 'Turbotastic!', `Now running on Discord.JS ${version}!` diff --git a/web/astro.config.mjs b/web/astro.config.mjs index 53e49de..515ddf0 100644 --- a/web/astro.config.mjs +++ b/web/astro.config.mjs @@ -6,4 +6,4 @@ import react from '@astrojs/react'; // https://astro.build/config export default defineConfig({ integrations: [react()] -}); \ No newline at end of file +}); diff --git a/web/src/components/Quotes.jsx b/web/src/components/Quotes.jsx index 1d563e7..831408d 100644 --- a/web/src/components/Quotes.jsx +++ b/web/src/components/Quotes.jsx @@ -72,6 +72,7 @@ export function PendingQuotes() {

{quote.quote}

- {quote.year} + Submitted by {quote.submitterAuthor} ({quote.submitterID}) diff --git a/web/src/layouts/Layout.astro b/web/src/layouts/Layout.astro index e455c61..2f6032d 100644 --- a/web/src/layouts/Layout.astro +++ b/web/src/layouts/Layout.astro @@ -5,7 +5,7 @@ - Astro Basics + AleeBot Web Interface diff --git a/web/src/pages/index.astro b/web/src/pages/index.astro index b5c607d..8136402 100644 --- a/web/src/pages/index.astro +++ b/web/src/pages/index.astro @@ -2,12 +2,11 @@ import Layout from '../layouts/Layout.astro'; import { PendingQuotes } from '../components/Quotes'; -const version = await fetch('http://localhost:3000/api/version').then(res => res.json()); ---
-

AleeBot {version}

+

AleeBot

@@ -27,3 +26,19 @@ const version = await fetch('http://localhost:3000/api/version').then(res => res } + + -- cgit v1.2.3 From de5ee661cad7b1fef0f319cbaccd888cb75a1dd4 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sun, 12 Jan 2025 00:45:51 -0500 Subject: Fixed environment variable, prefix using ab --- Dockerfile | 3 ++- api/server.js | 6 +++--- storage/settings.json | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'storage') diff --git a/Dockerfile b/Dockerfile index 3f4f771..44c3d57 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,4 +12,5 @@ RUN yarn install COPY . . -ENTRYPOINT ["node", "bot_discord.js", "--beta"] +ENTRYPOINT ["node", "bot_discord.js"] + diff --git a/api/server.js b/api/server.js index a6cb48c..2a2afad 100644 --- a/api/server.js +++ b/api/server.js @@ -1,9 +1,9 @@ const express = require('express'); const cors = require('cors'); const quotesRouter = require('./routes/quotes'); +require('dotenv').config() const app = express(); -const PORT = 3000; const createServer = () => { app.use(cors()); // Allow cross-origin requests @@ -18,8 +18,8 @@ const createServer = () => { }); // Start the server - app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); + app.listen(process.env.port, () => { + console.log(`Server is running on http://localhost:${process.env.port}`); }); }; diff --git a/storage/settings.json b/storage/settings.json index 83932cc..b53fd84 100644 --- a/storage/settings.json +++ b/storage/settings.json @@ -1,4 +1,4 @@ { "abVersion": "2.13.0 Beta", - "prefix": "abb:" + "prefix": "ab:" } -- cgit v1.2.3 From 5777f96394444dab18a81d6f085ac81df3e62008 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Tue, 25 Feb 2025 23:13:39 -0500 Subject: 2.13 Release (finally); Added more API entries; Proper logging --- api/server.js | 51 +++++++++++++++++++- bot_discord.js | 108 ++++++++++++++++++++++++------------------ commands/addquote.js | 4 +- commands/quote.js | 3 +- commands/setlogchannel.js | 25 ++++++---- models/guild-settings.js | 25 ++++++---- package.json | 2 +- storage/settings.json | 2 +- sync-database.js | 4 +- web/astro.config.mjs | 10 +++- web/src/components/Quotes.jsx | 7 +-- web/src/pages/index.astro | 3 +- 12 files changed, 165 insertions(+), 79 deletions(-) (limited to 'storage') diff --git a/api/server.js b/api/server.js index 2a2afad..acfe528 100644 --- a/api/server.js +++ b/api/server.js @@ -5,7 +5,7 @@ require('dotenv').config() const app = express(); -const createServer = () => { +const apiServer = (client) => { app.use(cors()); // Allow cross-origin requests app.use(express.json()); @@ -17,10 +17,57 @@ const createServer = () => { }); + app.get('/api/uptime', (req, res) => { + res.json(client.uptime); + }); + + app.get('/api/servers', (req, res) => { + const guildsInfo = []; + + if (client.guilds.cache.size === 0) { + res.json({ + message: 'No servers found' + }) + } else { + client.guilds.cache.forEach((guild) => { + const guildInfo = { + name: guild.name, + members: guild.memberCount, + id: guild.id + }; + guildsInfo.push(guildInfo); + }); + } + + res.json(guildsInfo); + + }); + + app.post('/api/leave', (req, res) => { + const { id } = req.body; + let guild = client.guilds.cache.get(id); + + try { + guild.leave().then(guild => { + res.json({ + guild: guild.name, + left: true + }) + }); + + } catch (error) { + console.error('Error leaving server:', error); + res.status(500).res.json({ + guild: guild.name, + left: false + }) + } + }); + // Start the server app.listen(process.env.port, () => { console.log(`Server is running on http://localhost:${process.env.port}`); }); }; -module.exports = createServer; +module.exports = apiServer; diff --git a/bot_discord.js b/bot_discord.js index 5a38940..1a87074 100644 --- a/bot_discord.js +++ b/bot_discord.js @@ -33,12 +33,15 @@ const colors = require('colors'); //const i18next = require('i18next'); const settings = require('./storage/settings.json'); const { activity } = require('./storage/activities'); -const createServer = require("./api/server"); +const apiServer = require("./api/server"); const active = new Map(); let autoRole = true; let readyEmbedMessage = true; + +const { guildSettings } = require('./models/guild-settings'); + const ownerID = '242775871059001344'; -let logChannel = '318874545593384970'; +//let logChannel = '318874545593384970'; let statusChannelID = '606602551634296968'; let serverWhitelist = "243022206437687296"; let roleWhitelist = "657426918416580614"; @@ -218,7 +221,7 @@ client.on('ready', async () => { botPresence(); - createServer(); + apiServer(client); setInterval(function() { botPresence(); @@ -238,8 +241,10 @@ client.on('ready', async () => { rl.prompt(); }); -client.on('guildMemberAdd', (member) => { - if (member.guild.id !== serverWhitelist) return; +client.on('guildMemberAdd', async (member) => { + const guildSetting = await guildSettings.findOne({ where: { guildID: member.guild.id } }); + if (!guildSetting || !guildSetting.logChannelID) return; + const logEmbed = new Discord.MessageEmbed() .setAuthor('AleeBot Logging', client.user.avatarURL()) .setDescription(`A user has joined this server!`) @@ -249,7 +254,7 @@ client.on('guildMemberAdd', (member) => { .setColor('#4bff31') .setTimestamp(); - let guildMember = client.channels.cache.get(logChannel); + let guildMember = client.channels.cache.get(guildSetting.logChannelID); if (!guildMember) return; guildMember.send({ embeds: [logEmbed]}); @@ -261,8 +266,10 @@ client.on('guildMemberAdd', (member) => { } }); -client.on('guildMemberRemove', (member) => { - if (member.guild.id !== serverWhitelist) return; +client.on('guildMemberRemove', async (member) => { + const guildSetting = await guildSettings.findOne({ where: { guildID: member.guild.id } }); + if (!guildSetting || !guildSetting.logChannelID) return; + const logEmbed = new Discord.MessageEmbed() .setAuthor('AleeBot Logging', client.user.avatarURL()) .setDescription(`A user has left this server!`) @@ -271,7 +278,7 @@ client.on('guildMemberRemove', (member) => { .setColor('#ec2727') .setTimestamp(); - let guildMember = client.channels.cache.get(logChannel); + let guildMember = client.channels.cache.get(guildSetting.logChannelID); if (!guildMember) return; guildMember.send({ embeds: [logEmbed]}); @@ -279,7 +286,10 @@ client.on('guildMemberRemove', (member) => { client.on('messageUpdate', async (oldMessage, newMessage) => { - if (!oldMessage.guild || oldMessage.guild.id !== serverWhitelist) return; + const guildSetting = await guildSettings.findOne({ where: { guildID: oldMessage.guild.id } }); + if (!oldMessage.guild || !guildSetting || !guildSetting.logChannelID) return; + + //if (!oldMessage.guild || oldMessage.guild.id !== serverWhitelist) return; if (oldMessage.content === newMessage.content) { return; } @@ -292,14 +302,18 @@ client.on('messageUpdate', async (oldMessage, newMessage) => { .setTimestamp() .setFooter(`Author ID: ${oldMessage.author.id}`); - let editMessage = client.channels.cache.get(logChannel); + let editMessage = client.channels.cache.get(guildSetting.logChannelID); if (!editMessage) return; editMessage.send({ embeds: [logEmbed]}); }); -client.on('messageDelete', (message) => { - if (message.guild.id !== serverWhitelist) return; +client.on('messageDelete', async (message) => { + if (!message.content) return; + + const guildSetting = await guildSettings.findOne({ where: { guildID: message.guild.id } }); + if (!guildSetting || !guildSetting.logChannelID) return; + const logEmbed = new Discord.MessageEmbed() .setAuthor('AleeBot Logging', client.user.avatarURL()) .setDescription(`A message from ${message.author.username} was deleted in <#${message.channel.id}>`) @@ -308,43 +322,47 @@ client.on('messageDelete', (message) => { .setTimestamp() .setFooter(`Author ID: ${message.author.id}`); - let deleteMessage = client.channels.cache.get(logChannel); + let deleteMessage = client.channels.cache.get(guildSetting.logChannelID); if (!deleteMessage) return; deleteMessage.send({ embeds: [logEmbed]}); }); -client.on('guildBanAdd', (guild, user) => { - if (guild.id !== serverWhitelist) return; - const logEmbed = new Discord.MessageEmbed() - .setAuthor('AleeBot Logging', client.user.avatarURL()) - .setDescription(`This user got banned from ${guild.name}`) - .addField('User:', `${user.tag}`) - .addField('User ID:', `${user.id}`) - .setColor('#ff021b') - .setTimestamp(); - - let banMessage = client.channels.cache.get(logChannel); - if (!banMessage) return; - - banMessage.send({ embeds: [logEmbed]}); -}); - -client.on('guildBanRemove', (guild, user) => { - if (guild.id !== serverWhitelist) return; - const logEmbed = new Discord.MessageEmbed() - .setAuthor('AleeBot Logging', client.user.avatarURL()) - .setDescription(`This user got unbanned from ${guild.name}`) - .addField('User:', `${user.tag}`) - .addField('User ID:', `${user.id}`) - .setColor('#ff021b') - .setTimestamp(); - - let banMessage = client.channels.cache.get(logChannel); - if (!banMessage) return; - - banMessage.send({ embeds: [logEmbed]}); -}); +// client.on('guildBanAdd', async (guild, user) => { +// const guildSetting = await guildSettings.findOne({ where: { guildID: guild.id } }); +// if (!guildSetting || !guildSetting.logChannelID) return; +// +// const logEmbed = new Discord.MessageEmbed() +// .setAuthor('AleeBot Logging', client.user.avatarURL()) +// .setDescription(`This user got banned from ${guild.name}`) +// .addField('User:', `${user.tag}`) +// .addField('User ID:', `${user.id}`) +// .setColor('#ff021b') +// .setTimestamp(); +// +// let banMessage = client.channels.cache.get(guildSetting.logChannelID); +// if (!banMessage) return; +// +// banMessage.send({ embeds: [logEmbed]}); +// }); +// +// client.on('guildBanRemove', async (guild, user) => { +// const guildSetting = await guildSettings.findOne({ where: { guildID: guild.id } }); +// if (!guildSetting || !guildSetting.logChannelID) return; +// +// const logEmbed = new Discord.MessageEmbed() +// .setAuthor('AleeBot Logging', client.user.avatarURL()) +// .setDescription(`This user got unbanned from ${guild.name}`) +// .addField('User:', `${user.tag}`) +// .addField('User ID:', `${user.id}`) +// .setColor('#ff021b') +// .setTimestamp(); +// +// let banMessage = client.channels.cache.get(guildSetting.logChannelID); +// if (!banMessage) return; +// +// banMessage.send({ embeds: [logEmbed]}); +// }); client.on('guildCreate', (guild) => { log(`[i] New guild joined: ${guild.name} (${guild.id}). This guild has ${guild.memberCount} members!`.blue); diff --git a/commands/addquote.js b/commands/addquote.js index cedee4d..6eae015 100644 --- a/commands/addquote.js +++ b/commands/addquote.js @@ -85,7 +85,7 @@ module.exports.run = async (client, message) => { return; } } else if (msg.content.startsWith('http') && (msg.content.endsWith('.jpg') || msg.content.endsWith('.jpeg') || msg.content.endsWith('.png'))) { - newAuthorImage = message.content; + newAuthorImage = msg.content; } else { await dmChannel.send('Invalid input. Please provide an image URL or attach an image file.'); collector.stop(); @@ -157,7 +157,7 @@ module.exports.run = async (client, message) => { await dmChannel.send('Invalid file type. Please attach a .jpg or .png image.'); } } else if (imageResponse.first().content.startsWith('http') && (imageResponse.first().content.endsWith('.jpg') || imageResponse.first().content.endsWith('.jpeg') || imageResponse.first().content.endsWith('.png'))) { - newAuthorImage = message.content; + newAuthorImage = imageResponse.first().content; } else { await dmChannel.send('Invalid input. Please provide an image URL or attach an image file.'); } diff --git a/commands/quote.js b/commands/quote.js index 02699cd..f19675f 100644 --- a/commands/quote.js +++ b/commands/quote.js @@ -30,13 +30,12 @@ module.exports.run = async (client, message, args) => { const quote = await quoteDB.findOne({ where: { id: quoteID } }) - if (quote) { const quoteEmbed = new MessageEmbed() .setAuthor({ name: quote.author, iconURL: quote.authorImage }) .setDescription(quote.quote) .setColor('#1fd619') - .setFooter('- ' + quote.year); + .setFooter(`- ${quote.year}\nSubmitted by ${quote.submitter}`); await message.reply({ embeds: [quoteEmbed] }) } else { diff --git a/commands/setlogchannel.js b/commands/setlogchannel.js index c04e926..d989f8b 100644 --- a/commands/setlogchannel.js +++ b/commands/setlogchannel.js @@ -17,21 +17,30 @@ * along with this program. If not, see . * * *************************************/ -const guildDB = require ('../models/guild-settings') -module.exports.run = async (client, message) => { +const { guildSettings } = require ('../models/guild-settings') +module.exports.run = async (client, message, args) => { //This will be replaced in the future possibly if (!message.member.permissions.has('MANAGE_GUILD')) return message.reply('It looks like that you can\'t manage this server.'); - const channel = await message.mentions.channels.first().id; - const [ guild ] = await guildDB.findOrCreate({ where: { id: message.guild.id } } ) + + let channel; + + if (message.mentions.channels.first()) { + channel = message.mentions.channels.first().id; + } else if (args[0] && message.guild.channels.cache.has(args[0])) { + channel = args[0]; + } else { + return await message.reply('Please enter a valid channel ID.') + } + + const [ guild ] = await guildSettings.findOrCreate({ where: { guildID: message.guild.id } } ) if (!channel) { message.reply('No channel has been set, disabling the logging channel feature...'); - await guild.update({ channelId: null } ); + await guild.update({ logChannelID: null } ); } else { - await guild.update({ channelId: message.guild.id } ) ; + await guild.update({ logChannelID: channel } ); + await message.reply(`Logging channel has been set to <#${channel}>`); } - - await message.reply(`Logging channel has been set to <#${channel}>`); }; exports.conf = { diff --git a/models/guild-settings.js b/models/guild-settings.js index 2e4f8ef..8cc7478 100644 --- a/models/guild-settings.js +++ b/models/guild-settings.js @@ -3,22 +3,27 @@ const sequelize = require('../utils/sequelize'); const guildSettings = sequelize.define('guild-settings', { id: { - type: Sequelize.STRING, - primaryKey: true + type: Sequelize.INTEGER, + primaryKey: true, + autoIncrement: true, }, - logChannelID: { + guildID: { type: Sequelize.STRING, - allowNull: true + allowNull: false }, - autoRoleToggle: { - type: Sequelize.BOOLEAN, - allowNull: true - }, - autoRoleID: { + logChannelID: { type: Sequelize.STRING, allowNull: true } + // qotdChannelID: { + // type: Sequelize.STRING, + // allowNull: true + // }, + // qotdToggle: { + // type: Sequelize.BOOLEAN, + // allowNull: true + // } }) -module.exports = guildSettings +module.exports = { guildSettings } diff --git a/package.json b/package.json index b300082..404b4a5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aleebot", - "version": "2.13.0b", + "version": "2.13.0", "description": "A chat bot for discord written in discord.js.", "main": "bot_discord.js", "scripts": { diff --git a/storage/settings.json b/storage/settings.json index b53fd84..4a6911c 100644 --- a/storage/settings.json +++ b/storage/settings.json @@ -1,4 +1,4 @@ { - "abVersion": "2.13.0 Beta", + "abVersion": "2.13.0", "prefix": "ab:" } diff --git a/sync-database.js b/sync-database.js index f7b9211..7a9271c 100644 --- a/sync-database.js +++ b/sync-database.js @@ -1,5 +1,5 @@ const { quote, pendingQuote } = require("./models/quote"); -const guildDB = require ('./models/guild-settings'); +const { guildSettings } = require ('./models/guild-settings'); quote.sync({alter: true}).then(() => { console.log('Quote database synced!') }); @@ -8,6 +8,6 @@ pendingQuote.sync({alter: true}).then(() => { console.log('Pending Quote database synced!') }); -guildDB.sync({alter: true}).then(() => { +guildSettings.sync({alter: true}).then(() => { console.log('Guild database synced!') }); diff --git a/web/astro.config.mjs b/web/astro.config.mjs index c0fd9ad..d32e23b 100644 --- a/web/astro.config.mjs +++ b/web/astro.config.mjs @@ -1,5 +1,5 @@ // @ts-check -import { defineConfig } from 'astro/config'; +import { defineConfig, envField } from 'astro/config'; import react from '@astrojs/react'; @@ -11,5 +11,11 @@ export default defineConfig({ adapter: node({ mode: 'standalone' - }) + }), + + env: { + schema: { + API_URL: envField.string({ context: 'client', access: 'public' }), + } + } }); diff --git a/web/src/components/Quotes.jsx b/web/src/components/Quotes.jsx index 831408d..1eb258a 100644 --- a/web/src/components/Quotes.jsx +++ b/web/src/components/Quotes.jsx @@ -1,12 +1,13 @@ import { useState, useEffect } from 'react'; import '../styles/Quote.css' +import { API_URL } from "astro:env/client"; export function PendingQuotes() { const [quotes, setQuotes] = useState([]); const fetchQuotes = async () => { try { - const response = await fetch('http://localhost:3000/api/pending-quotes'); + const response = await fetch(`${API_URL}/api/pending-quotes`); const data = await response.json(); setQuotes(data); } catch (error) { @@ -20,7 +21,7 @@ export function PendingQuotes() { const approveQuote = async (id) => { try { - const response = await fetch('http://localhost:3000/api/approve-quote', { + const response = await fetch(`${API_URL}/api/approve-quote`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -40,7 +41,7 @@ export function PendingQuotes() { const rejectQuote = async (id) => { try { - const response = await fetch('http://localhost:3000/api/reject-quote', { + const response = await fetch(`${API_URL}/api/reject-quote`, { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/web/src/pages/index.astro b/web/src/pages/index.astro index 8136402..f1dc6e7 100644 --- a/web/src/pages/index.astro +++ b/web/src/pages/index.astro @@ -28,9 +28,10 @@ import { PendingQuotes } from '../components/Quotes';