diff --git a/Shard.js b/Shard.js index 5600aa1a..87612afd 100644 --- a/Shard.js +++ b/Shard.js @@ -1,4 +1,4 @@ const { ShardingManager } = require('discord.js'); -const { TOKEN } = process.env; -const Manager = new ShardingManager('./XiaoBot.js', { token: TOKEN }); +const { token } = require('./config'); +const Manager = new ShardingManager('./XiaoBot.js', { token }); Manager.spawn(); diff --git a/XiaoBot.js b/XiaoBot.js index 458a792e..405e78e6 100644 --- a/XiaoBot.js +++ b/XiaoBot.js @@ -1,10 +1,10 @@ -const { TOKEN, OWNER, PREFIX, INVITE } = process.env; +const { token, owner, prefix, invite } = require('./config'); const path = require('path'); const { CommandoClient } = require('discord.js-commando'); const client = new CommandoClient({ - commandPrefix: PREFIX, - owner: OWNER, - invite: INVITE, + commandPrefix: prefix, + owner, + invite, disableEveryone: true, unknownCommandResponse: false, disabledEvents: [ @@ -47,7 +47,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) => { @@ -128,6 +128,6 @@ client.on('guildDelete', async (guild) => { dBots(count, client.user.id); }); -client.login(TOKEN); +client.login(token); process.on('unhandledRejection', console.error); diff --git a/commands/games/hangman.js b/commands/games/hangman.js index 75848ef4..5152b2b0 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 { WORDNIK_KEY } = process.env; +const { wordnikKey } = require('../../config'); 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: WORDNIK_KEY + api_key: wordnikKey }); const word = body.word.toLowerCase().replace(/[ ]/g, '-'); let points = 0; diff --git a/commands/search/anime.js b/commands/search/anime.js index a656630d..9dafe7a1 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 { ANIMELIST_LOGIN } = process.env; +const { animelistLogin } = require('../../config'); 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://${ANIMELIST_LOGIN}@myanimelist.net/api/anime/search.xml`) + .get(`https://${animelistLogin}@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, 2000)); diff --git a/commands/search/bot-info.js b/commands/search/bot-info.js index 2bc79fe5..5a4ed368 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 { DBOTS_KEY } = process.env; +const { dbotsKey } = require('../../config'); 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: DBOTS_KEY }); + .set({ Authorization: dbotsKey }); 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 9228d0ce..e05460e8 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 { WORDNIK_KEY } = process.env; +const { wordnikKey } = require('../../config'); 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: WORDNIK_KEY + api_key: wordnikKey }); 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 dcf5ff26..760abee7 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 { GIPHY_KEY } = process.env; +const { giphyKey } = require('../../config'); 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: GIPHY_KEY, + api_key: giphyKey, rating: msg.channel.nsfw ? 'r' : 'pg' }); if (!body.data.length) return msg.say('No Results.'); diff --git a/commands/search/github.js b/commands/search/github.js index 5ee462a2..1770f77c 100644 --- a/commands/search/github.js +++ b/commands/search/github.js @@ -2,7 +2,7 @@ const Command = require('../../structures/Command'); const { MessageEmbed } = require('discord.js'); const snekfetch = require('snekfetch'); const moment = require('moment'); -const { GITHUB_LOGIN } = process.env; +const { githubLogin } = require('../../config'); module.exports = class GithubCommand extends Command { constructor(client) { @@ -26,7 +26,7 @@ module.exports = class GithubCommand extends Command { const { repo } = args; try { const { body } = await snekfetch - .get(`https://${GITHUB_LOGIN}@api.github.com/repos/${repo}`); + .get(`https://${githubLogin}@api.github.com/repos/${repo}`); const embed = new MessageEmbed() .setColor(0xFFFFFF) .setAuthor('Github', 'https://i.imgur.com/ajcPgJG.png') diff --git a/commands/search/manga.js b/commands/search/manga.js index 09bd5081..a1c9dea1 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 { ANIMELIST_LOGIN } = process.env; +const { animelistLogin } = require('../../config'); 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://${ANIMELIST_LOGIN}@myanimelist.net/api/manga/search.xml`) + .get(`https://${animelistLogin}@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, 2000)); diff --git a/commands/search/map.js b/commands/search/map.js index 485d3a5a..77223fb6 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 { GOOGLE_KEY } = process.env; +const { googleKey } = require('../../config'); module.exports = class MapCommand extends Command { constructor(client) { @@ -38,7 +38,7 @@ module.exports = class MapCommand extends Command { center: query, zoom, size: '500x500', - key: GOOGLE_KEY + key: googleKey }); return msg.say({ files: [{ attachment: body, name: 'map.png' }] }); } diff --git a/commands/search/osu.js b/commands/search/osu.js index 43c25128..4250a1dc 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 { OSU_KEY } = process.env; +const { osuKey } = require('../../config'); 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: OSU_KEY, + k: osuKey, u: query, type: 'string' }); diff --git a/commands/search/soundcloud.js b/commands/search/soundcloud.js index a694eccc..ddc95d48 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 { SOUNDCLOUD_KEY } = process.env; +const { soundcloudKey } = require('../../config'); 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: SOUNDCLOUD_KEY + client_id: soundcloudKey }); 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 7c59b08d..4a3f7c8f 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 { WATTPAD_KEY } = process.env; +const { wattpadKey } = require('../../config'); module.exports = class WattpadCommand extends Command { constructor(client) { @@ -30,7 +30,7 @@ module.exports = class WattpadCommand extends Command { query, limit: 1 }) - .set({ Authorization: `Basic ${WATTPAD_KEY}` }); + .set({ Authorization: `Basic ${wattpadKey}` }); 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 7471156c..f5f8b40b 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 { GOOGLE_KEY } = process.env; +const { googleKey } = require('../../config'); 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: GOOGLE_KEY + key: googleKey }); 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 7581969e..97ae644f 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 { YANDEX_KEY } = process.env; +const { yandexKey } = require('../../config'); 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: YANDEX_KEY, + key: yandexKey, text, lang: from ? `${from}-${to}` : to }); diff --git a/commands/text-edit/webhook.js b/commands/text-edit/webhook.js index a36538d6..a1272bde 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 { WEBHOOK_URL } = process.env; +const { webhookURL } = require('../../config'); 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 `process.env`.', + description: 'Posts a message to the webhook defined in your `config.json`.', 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(WEBHOOK_URL) + .post(webhookURL) .send({ content }); return null; } diff --git a/package.json b/package.json index bafbb66a..0598f2f1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "26.2.1", + "version": "26.2.2", "description": "Your personal server companion.", "main": "Shard.js", "scripts": { diff --git a/structures/Util.js b/structures/Util.js index 86e6ee65..9099eaba 100644 --- a/structures/Util.js +++ b/structures/Util.js @@ -1,5 +1,5 @@ const snekfetch = require('snekfetch'); -const { CARBON_KEY, DBOTS_KEY } = process.env; +const { carbonKey, dbotsKey } = require('../config'); class Util { static cleanXML(str) { @@ -14,7 +14,7 @@ class Util { static dBots(count, id) { snekfetch .post(`https://bots.discord.pw/api/bots/${id}/stats`) - .set({ Authorization: DBOTS_KEY }) + .set({ Authorization: dbotsKey }) .send({ server_count: count }) .then(() => console.log('[CARBON] Successfully posted to Carbon.')) .catch((err) => console.error(`[CARBON] Failed to post to Carbon. ${err}`)); @@ -24,7 +24,7 @@ class Util { snekfetch .post('https://www.carbonitex.net/discord/data/botdata.php') .send({ - key: CARBON_KEY, + key: carbonKey, servercount: count }) .then(() => console.log('[DBOTS] Successfully posted to Discord Bots.'))