-
- diff --git a/README.md b/README.md index 2aff3c97..9749cb6e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # XiaoBot [](https://discord.gg/fqQF8mc) -[](https://www.codacy.com/app/dragonfire535/xiaobot) Public Source Code for the Discord Bot XiaoBot, a Discord bot coded in JavaScript with [discord.js](https://github.com/hydrabolt/discord.js) using the diff --git a/Shard.js b/Shard.js index 5c6a2e9c..17add350 100644 --- a/Shard.js +++ b/Shard.js @@ -1,5 +1,5 @@ const { ShardingManager } = require('discord.js'); const path = require('path'); -const { token } = require('./config'); -const manager = new ShardingManager(path.join(__dirname, 'XiaoBot.js'), { token }); +const { TOKEN } = process.env; +const manager = new ShardingManager(path.join(__dirname, 'XiaoBot.js'), { token: TOKEN }); manager.spawn(undefined, 1000); diff --git a/XiaoBot.js b/XiaoBot.js index 28fcc947..30e89f86 100644 --- a/XiaoBot.js +++ b/XiaoBot.js @@ -1,10 +1,10 @@ -const { token, owner, prefix, invite } = require('./config'); +const { TOKEN, OWNER, PREFIX, INVITE } = process.env; const path = require('path'); const { CommandoClient } = require('discord.js-commando'); const client = new CommandoClient({ - commandPrefix: prefix, - owner, - invite, + commandPrefix: PREFIX, + owner: OWNER, + invite: INVITE, disableEveryone: true, unknownCommandResponse: false, disabledEvents: [ @@ -46,7 +46,7 @@ client.registry client.on('ready', () => { console.log(`[READY] Shard ${client.shard.id} Logged in as ${client.user.tag} (${client.user.id})!`); - client.user.setGame(`${prefix}help | Shard ${client.shard.id}`); + client.user.setGame(`${PREFIX}help | Shard ${client.shard.id}`); }); client.on('disconnect', event => { @@ -112,6 +112,6 @@ client.on('guildDelete', async guild => { client.setTimeout(() => process.exit(0), 7200000); -client.login(token); +client.login(TOKEN); process.on('unhandledRejection', console.error); diff --git a/commands/games/hangman.js b/commands/games/hangman.js index 2d3ac382..e0c51b1f 100644 --- a/commands/games/hangman.js +++ b/commands/games/hangman.js @@ -1,7 +1,7 @@ const Command = require('../../structures/Command'); const snekfetch = require('snekfetch'); const { stripIndents } = require('common-tags'); -const { wordnikKey } = require('../../config'); +const { WORDNIK_KEY } = process.env; module.exports = class HangmanCommand extends Command { constructor(client) { @@ -30,7 +30,7 @@ module.exports = class HangmanCommand extends Command { maxDictionaryCount: -1, minLength: -1, maxLength: -1, - api_key: wordnikKey + api_key: WORDNIK_KEY }); const word = body.word.toLowerCase().replace(/[ ]/g, '-'); let points = 0; diff --git a/commands/search/anime.js b/commands/search/anime.js index 4f5c25ea..a2771afd 100644 --- a/commands/search/anime.js +++ b/commands/search/anime.js @@ -4,7 +4,7 @@ const snekfetch = require('snekfetch'); const { cleanXML } = require('../../structures/Util'); const { promisifyAll } = require('tsubaki'); const xml = promisifyAll(require('xml2js')); -const { animelistLogin } = require('../../config'); +const { ANIMELIST_LOGIN } = process.env; module.exports = class AnimeCommand extends Command { constructor(client) { @@ -28,7 +28,7 @@ module.exports = class AnimeCommand extends Command { const { query } = args; try { const { text } = await snekfetch - .get(`https://${animelistLogin}@myanimelist.net/api/anime/search.xml`) + .get(`https://${ANIMELIST_LOGIN}@myanimelist.net/api/anime/search.xml`) .query({ q: query }); const { anime } = await xml.parseStringAsync(text); const synopsis = cleanXML(anime.entry[0].synopsis[0].substr(0, 2048)); diff --git a/commands/search/bot-info.js b/commands/search/bot-info.js index 74529fbf..75b23abf 100644 --- a/commands/search/bot-info.js +++ b/commands/search/bot-info.js @@ -1,7 +1,7 @@ const Command = require('../../structures/Command'); const { MessageEmbed } = require('discord.js'); const snekfetch = require('snekfetch'); -const { dbotsKey } = require('../../config'); +const { DBOTS_KEY } = process.env; module.exports = class BotSearchCommand extends Command { constructor(client) { @@ -26,7 +26,7 @@ module.exports = class BotSearchCommand extends Command { try { const { body } = await snekfetch .get(`https://bots.discord.pw/api/bots/${bot.id}`) - .set({ Authorization: dbotsKey }); + .set({ Authorization: DBOTS_KEY }); const embed = new MessageEmbed() .setColor(0x9797FF) .setAuthor('Discord Bots', 'https://i.imgur.com/lrKYBQi.jpg') diff --git a/commands/search/define.js b/commands/search/define.js index 909f990e..1ac7af85 100644 --- a/commands/search/define.js +++ b/commands/search/define.js @@ -1,7 +1,7 @@ const Command = require('../../structures/Command'); const { MessageEmbed } = require('discord.js'); const snekfetch = require('snekfetch'); -const { wordnikKey } = require('../../config'); +const { WORDNIK_KEY } = process.env; module.exports = class DefineCommand extends Command { constructor(client) { @@ -30,7 +30,7 @@ module.exports = class DefineCommand extends Command { limit: 1, includeRelated: false, useCanonical: false, - api_key: wordnikKey + api_key: WORDNIK_KEY }); if (!body.length) return msg.say('No Results.'); const embed = new MessageEmbed() diff --git a/commands/search/giphy.js b/commands/search/giphy.js index cb4b79e2..8cd6866f 100644 --- a/commands/search/giphy.js +++ b/commands/search/giphy.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const snekfetch = require('snekfetch'); -const { giphyKey } = require('../../config'); +const { GIPHY_KEY } = process.env; module.exports = class GiphyCommand extends Command { constructor(client) { @@ -25,7 +25,7 @@ module.exports = class GiphyCommand extends Command { .get('http://api.giphy.com/v1/gifs/search') .query({ q: query, - api_key: giphyKey, + api_key: GIPHY_KEY, rating: msg.channel.nsfw ? 'r' : 'pg' }); if (!body.data.length) return msg.say('No Results.'); diff --git a/commands/search/manga.js b/commands/search/manga.js index c42a2c23..8a86fa8d 100644 --- a/commands/search/manga.js +++ b/commands/search/manga.js @@ -4,7 +4,7 @@ const snekfetch = require('snekfetch'); const { cleanXML } = require('../../structures/Util'); const { promisifyAll } = require('tsubaki'); const xml = promisifyAll(require('xml2js')); -const { animelistLogin } = require('../../config'); +const { ANIMELIST_LOGIN } = process.env; module.exports = class MangaCommand extends Command { constructor(client) { @@ -28,7 +28,7 @@ module.exports = class MangaCommand extends Command { const { query } = args; try { const { text } = await snekfetch - .get(`https://${animelistLogin}@myanimelist.net/api/manga/search.xml`) + .get(`https://${ANIMELIST_LOGIN}@myanimelist.net/api/manga/search.xml`) .query({ q: query }); const { manga } = await xml.parseStringAsync(text); const synopsis = cleanXML(manga.entry[0].synopsis[0].substr(0, 2048)); diff --git a/commands/search/map.js b/commands/search/map.js index a38a8d3b..2962de5a 100644 --- a/commands/search/map.js +++ b/commands/search/map.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const snekfetch = require('snekfetch'); -const { googleKey } = require('../../config'); +const { GOOGLE_KEY } = process.env; module.exports = class MapCommand extends Command { constructor(client) { @@ -38,7 +38,7 @@ module.exports = class MapCommand extends Command { center: query, zoom, size: '500x500', - key: googleKey + key: GOOGLE_KEY }); return msg.say({ files: [{ attachment: body, name: 'map.png' }] }); } diff --git a/commands/search/osu.js b/commands/search/osu.js index eff3c20c..2df48c75 100644 --- a/commands/search/osu.js +++ b/commands/search/osu.js @@ -1,7 +1,7 @@ const Command = require('../../structures/Command'); const { MessageEmbed } = require('discord.js'); const snekfetch = require('snekfetch'); -const { osuKey } = require('../../config'); +const { OSU_KEY } = process.env; module.exports = class OsuCommand extends Command { constructor(client) { @@ -26,7 +26,7 @@ module.exports = class OsuCommand extends Command { const { body } = await snekfetch .get('https://osu.ppy.sh/api/get_user') .query({ - k: osuKey, + k: OSU_KEY, u: query, type: 'string' }); diff --git a/commands/search/soundcloud.js b/commands/search/soundcloud.js index d6fb5281..de24fad0 100644 --- a/commands/search/soundcloud.js +++ b/commands/search/soundcloud.js @@ -1,7 +1,7 @@ const Command = require('../../structures/Command'); const { MessageEmbed } = require('discord.js'); const snekfetch = require('snekfetch'); -const { soundcloudKey } = require('../../config'); +const { SOUNDCLOUD_KEY } = process.env; module.exports = class SoundCloudCommand extends Command { constructor(client) { @@ -27,7 +27,7 @@ module.exports = class SoundCloudCommand extends Command { .get('https://api.soundcloud.com/tracks') .query({ q: query, - client_id: soundcloudKey + client_id: SOUNDCLOUD_KEY }); if (!body.length) return msg.say('No Results.'); const embed = new MessageEmbed() diff --git a/commands/search/wattpad.js b/commands/search/wattpad.js index 769ed03b..5b8e6a95 100644 --- a/commands/search/wattpad.js +++ b/commands/search/wattpad.js @@ -2,7 +2,7 @@ const Command = require('../../structures/Command'); const { MessageEmbed } = require('discord.js'); const snekfetch = require('snekfetch'); const moment = require('moment'); -const { wattpadKey } = require('../../config'); +const { WATTPAD_KEY } = process.env; module.exports = class WattpadCommand extends Command { constructor(client) { @@ -30,7 +30,7 @@ module.exports = class WattpadCommand extends Command { query, limit: 1 }) - .set({ Authorization: `Basic ${wattpadKey}` }); + .set({ Authorization: `Basic ${WATTPAD_KEY}` }); if (!body.stories.length) return msg.say('No Results.'); const embed = new MessageEmbed() .setColor(0xF89C34) diff --git a/commands/search/youtube.js b/commands/search/youtube.js index 35223af5..c3996456 100644 --- a/commands/search/youtube.js +++ b/commands/search/youtube.js @@ -1,7 +1,7 @@ const Command = require('../../structures/Command'); const { MessageEmbed } = require('discord.js'); const snekfetch = require('snekfetch'); -const { googleKey } = require('../../config'); +const { GOOGLE_KEY } = process.env; module.exports = class YouTubeCommand extends Command { constructor(client) { @@ -30,7 +30,7 @@ module.exports = class YouTubeCommand extends Command { type: 'video', maxResults: 1, q: query, - key: googleKey + key: GOOGLE_KEY }); if (!body.items.length) return msg.say('No Results.'); const embed = new MessageEmbed() diff --git a/commands/text-edit/translate.js b/commands/text-edit/translate.js index 296efdfb..7456471a 100644 --- a/commands/text-edit/translate.js +++ b/commands/text-edit/translate.js @@ -2,7 +2,7 @@ const Command = require('../../structures/Command'); const { MessageEmbed } = require('discord.js'); const snekfetch = require('snekfetch'); const codes = require('../../assets/json/translate'); -const { yandexKey } = require('../../config'); +const { YANDEX_KEY } = process.env; module.exports = class TranslateCommand extends Command { constructor(client) { @@ -53,7 +53,7 @@ module.exports = class TranslateCommand extends Command { const { body } = await snekfetch .get('https://translate.yandex.net/api/v1.5/tr.json/translate') .query({ - key: yandexKey, + key: YANDEX_KEY, text, lang: from ? `${from}-${to}` : to }); diff --git a/commands/text-edit/webhook.js b/commands/text-edit/webhook.js index 8f1115e3..9c69f9d3 100644 --- a/commands/text-edit/webhook.js +++ b/commands/text-edit/webhook.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const snekfetch = require('snekfetch'); -const { webhookURL } = require('../../config'); +const { WEBHOOK_URL } = process.env; module.exports = class WebhookCommand extends Command { constructor(client) { @@ -9,7 +9,7 @@ module.exports = class WebhookCommand extends Command { aliases: ['rin', 'rin-say'], group: 'text-edit', memberName: 'webhook', - description: 'Posts a message to the webhook defined in your `config.json`.', + description: 'Posts a message to the webhook defined in your `process.env`.', guildOnly: true, ownerOnly: true, clientPermissions: ['MANAGE_MESSAGES'], @@ -27,7 +27,7 @@ module.exports = class WebhookCommand extends Command { const { content } = args; msg.delete(); await snekfetch - .post(webhookURL) + .post(WEBHOOK_URL) .send({ content }); return null; } diff --git a/commands/util/upvote.js b/commands/util/upvote.js index 5f356ed3..094675f3 100644 --- a/commands/util/upvote.js +++ b/commands/util/upvote.js @@ -1,7 +1,7 @@ const Command = require('../../structures/Command'); const snekfetch = require('snekfetch'); const { stripIndents } = require('common-tags'); -const { dbotsOrgKey } = require('../../config'); +const { DBOTSORG_KEY } = process.env; module.exports = class UpvoteCommand extends Command { constructor(client) { @@ -18,7 +18,7 @@ module.exports = class UpvoteCommand extends Command { async run(msg) { const { body } = await snekfetch .get(`https://discordbots.org/api/bots/${this.client.user.id}/votes`) - .set({ Authorization: dbotsOrgKey }); + .set({ Authorization: DBOTSORG_KEY }); const haste = await snekfetch .post('https://hastebin.com/documents') .send(body.map(user => `${user.username}#${user.discriminator}`).join('\n')); diff --git a/html/carbondesc.html b/html/carbondesc.html deleted file mode 100644 index 3afac129..00000000 --- a/html/carbondesc.html +++ /dev/null @@ -1,25 +0,0 @@ -
-
-
-