Change to process.env

This commit is contained in:
Daniel Odendahl Jr
2017-08-13 01:33:56 +00:00
parent e75251b3f9
commit 71c9691419
23 changed files with 46 additions and 248 deletions
-1
View File
@@ -1,6 +1,5 @@
# XiaoBot
[![Discord](https://discordapp.com/api/guilds/252317073814978561/embed.png)](https://discord.gg/fqQF8mc)
[![Codacy](https://api.codacy.com/project/badge/Grade/2be44c0fadf64597b4e07f95d0f6a8ef)](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
+2 -2
View File
@@ -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);
+6 -6
View File
@@ -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);
+2 -2
View File
@@ -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;
+2 -2
View File
@@ -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));
+2 -2
View File
@@ -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')
+2 -2
View File
@@ -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()
+2 -2
View File
@@ -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.');
+2 -2
View File
@@ -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));
+2 -2
View File
@@ -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' }] });
}
+2 -2
View File
@@ -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'
});
+2 -2
View File
@@ -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()
+2 -2
View File
@@ -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)
+2 -2
View File
@@ -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()
+2 -2
View File
@@ -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
});
+3 -3
View File
@@ -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;
}
+2 -2
View File
@@ -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'));
-25
View File
@@ -1,25 +0,0 @@
<div class="content">
<style>
.xiaobox {
border-radius: 5px;
padding: 15px;
font-size: 100%;
border-style: solid;
border-color: lime;
background-image: url("https://i.imgur.com/LJsgebW.jpg");
box-shadow: 10px 10px 5px #888888;
text-shadow: 2px 2px #3333ff;
}
</style>
<marquee behavior="scroll" direction="left">
XiaoBot, your personal server companion...
</marquee>
<center>
<a href="https://discord.gg/fqQF8mc"><img src="https://discordapp.com/api/guilds/252317073814978561/embed.png" alt="Discord Server"></img>
</a>
</center>
<h3></h3>
<div class="xiaobox">
<font size="10">Moderation, Site Searching, Soundboard, Avatar Editing, Games, and more!</font>
</div>
</div>
-75
View File
@@ -1,75 +0,0 @@
<div class="content">
<style>
.xiaobox2 {
border-radius: 5px;
padding: 15px;
font-size: 100%;
border-style: solid;
border-color: lime;
box-shadow: 10px 10px 5px #888888;
}
</style>
<div class="xiaobox2">
<h2>Features</h2>
<ol>
<li>Avatar image Editing, including Bob Ross, RIP, Wanted, Triggered, Steam Card, and more!</li>
<li>Profile Trading Cards, with random rarity!</li>
<li>Battle! Challenge your friends or the AI in real turn-based matches!</li>
<li>Fun Games including Hangman, Lottery, Math, Quiz, Rock Paper Scissors, Slots, and Typing!</li>
<li>Server, User, and Role Information!</li>
<li>Minecraft Achievement Generation!</li>
<li>Meme Generation!</li>
<li>Pokémon Fusion!</li>
<li>Moderation Commands including Ban/Kick/Softban/Unban/Warn, Lockdown, and Prune, with Logging!</li>
<li>Currency and Temperature Conversion!</li>
<li>Math Calculator!</li>
<li>Tons of Secret Easter Eggs to discover!</li>
<li>Horoscopes!</li>
<li>LMGTFY Link Generation!</li>
<li>Strawpoll Generation!</li>
<li>Events that Happened today in history!</li>
<li>Would you rather questions!</li>
<li>Random Cats, Dogs, and Xiao Pai Images!</li>
<li>8 Ball, Choose, Coin Flip, Magic Conch, Roll, and Member Roulette!</li>
<li>Waifu and Ship Rating!</li>
<li>Random Compliments, Chuck Norris Jokes, Quotes, Fact Core Quotes, Fortunes, Names, and Roasts!</li>
<li>Roleplay Commands!</li>
<li>Search Various sites including:</li>
<ol>
<li>My Anime List</li>
<li>Discord Bots</li>
<li>Bulbapedia</li>
<li>Danbooru</li>
<li>Wordnik</li>
<li>Yahoo Weather</li>
<li>Gelbooru</li>
<li>Giphy</li>
<li>Konachan</li>
<li>Google Maps</li>
<li>Neopets</li>
<li>NPM</li>
<li>osu!</li>
<li>Pokédex</li>
<li>Recipe Puppy</li>
<li>Reddit</li>
<li>Rule34</li>
<li>SoundCloud</li>
<li>Steam</li>
<li>Urban Dictionary</li>
<li>VocaDB</li>
<li>Wattpad</li>
<li>Wikia (Any Wiki)</li>
<li>Wikipedia</li>
<li>YouTube</li>
<li>Yu-Gi-Oh!</li>
</ol>
<li>Random, Daily, and Specific XKCD Comics!</li>
<li>Translate Text to almost 100 languages!</li>
<li>Binary, Morse, Pirate, and Temmie Translators!</li>
<li>Cowsay, Embed, Reverse, Upside Down, and Zalgo Text!</li>
<li>Member Join/Leave Logging (with Customization)!</li>
<li>Invite Protection!</li>
<li>And so so so much more!</li>
</ol>
</div>
</div>
-22
View File
@@ -1,22 +0,0 @@
<div class="content">
<style>
.xiaobox2 {
border-radius: 5px;
padding: 15px;
font-size: 100%;
border-style: solid;
border-color: lime;
box-shadow: 10px 10px 5px #888888;
}
</style>
<div class="xiaobox2">
<h2>Notes</h2>
<ol>
<li>Moderation commands require a channel with &lt;modlog&gt; in the topic to send Ban/Kick/Softban/Unban/Warn logs.</li>
<li>To use member join/leave logging, place &lt;memberlog&gt; in the channel topic. Custom messages can be set with &lt;joinmessage&gt;messagegoeshere&lt;/joinmessage&gt; and &lt;leavemessage&gt;messagegoeshere&lt;/leavemessage&gt;</li>
<li>To use invite guard, place &lt;inviteguard&gt; in the default channel topic.</li>
<li>Use x;help to view a command list</li>
<li>Visit my <a href="https://discord.gg/fqQF8mc">home server</a> for more support, or for updates, or if you just want to hang out.</li>
</ol>
</div>
</div>
-80
View File
@@ -1,80 +0,0 @@
<div class="content">
<marquee behavior="scroll" direction="left">
<font size="25">XiaoBot, your personal server companion...</font>
</marquee>
<h3></h3>
<center>
<h1><a href="https://github.com/dragonfire535/xiaobot">Source Code</a></h1>
<a href="https://discord.gg/fqQF8mc"><img src="https://discordapp.com/api/guilds/252317073814978561/embed.png" alt="Discord Server"></img></a>
</center>
<h2>Features</h2>
<ol>
<li>Avatar image Editing, including Bob Ross, RIP, Wanted, Triggered, Steam Card, and more!</li>
<li>Profile Trading Cards, with random rarity!</li>
<li>Battle! Challenge your friends or the AI in real turn-based matches!</li>
<li>Fun Games including Hangman, Lottery, Math, Quiz, Rock Paper Scissors, Slots, and Typing!</li>
<li>Server, User, and Role Information!</li>
<li>Minecraft Achievement Generation!</li>
<li>Meme Generation!</li>
<li>Pokémon Fusion!</li>
<li>Moderation Commands including Ban/Kick/Softban/Unban/Warn, Lockdown, and Prune, with Logging!</li>
<li>Currency and Temperature Conversion!</li>
<li>Math Calculator!</li>
<li>Tons of Secret Easter Eggs to discover!</li>
<li>Horoscopes!</li>
<li>LMGTFY Link Generation!</li>
<li>Strawpoll Generation!</li>
<li>Events that Happened today in history!</li>
<li>Would you rather questions!</li>
<li>Random Cats, Dogs, VOCALOID Songs, and Xiao Pai Images!</li>
<li>8 Ball, Choose, Coin Flip, Magic Conch, Roll, and Member Roulette!</li>
<li>Waifu and Ship Rating!</li>
<li>Random Compliments, Chuck Norris Jokes, Quotes, Fact Core Quotes, Fortunes, Names, and Roasts!</li>
<li>Roleplay Commands!</li>
<li>Search Various sites including:</li>
<ol>
<li>My Anime List</li>
<li>Discord Bots</li>
<li>Bulbapedia</li>
<li>Danbooru</li>
<li>Wordnik</li>
<li>Yahoo Weather</li>
<li>Gelbooru</li>
<li>Giphy</li>
<li>Konachan</li>
<li>Google Maps</li>
<li>Neopets</li>
<li>NPM</li>
<li>osu!</li>
<li>Pokédex</li>
<li>Recipe Puppy</li>
<li>Reddit</li>
<li>Rule34</li>
<li>SoundCloud</li>
<li>Steam</li>
<li>Urban Dictionary</li>
<li>VocaDB</li>
<li>Wattpad</li>
<li>Wikia (Any Wiki)</li>
<li>Wikipedia</li>
<li>YouTube</li>
<li>Yu-Gi-Oh!</li>
</ol>
<li>Random, Daily, and Specific XKCD Comics!</li>
<li>Translate Text to almost 100 languages!</li>
<li>Binary, Morse, Pirate, and Temmie Translators!</li>
<li>Cowsay, Embed, Reverse, Upside Down, and Zalgo Text!</li>
<li>Member Join/Leave Logging (with Customization)!</li>
<li>Invite Protection!</li>
<li>And so so so much more!</li>
</ul>
</ol>
<h2>Notes</h2>
<ol>
<li>Moderation commands require a channel with &lt;modlog&gt; in the topic to send Ban/Kick/Softban/Unban/Warn logs.</li>
<li>To use member join/leave logging, place &lt;memberlog&gt; in the channel topic. Custom messages can be set with &lt;joinmessage&gt;messagegoeshere&lt;/joinmessage&gt; and &lt;leavemessage&gt;messagegoeshere&lt;/leavemessage&gt;</li>
<li>To use invite guard, place &lt;inviteguard&gt; in the default channel topic.</li>
<li>Use x;help to view a command list</li>
<li>Visit my <a href="https://discord.gg/fqQF8mc">home server</a> for more support, or for updates, or if you just want to hang out.</li>
</ol>
</div>
+5 -4
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "29.2.0",
"version": "30.0.0",
"description": "Your personal server companion.",
"main": "Shard.js",
"scripts": {
@@ -36,7 +36,7 @@
"discord.js": "github:hydrabolt/discord.js",
"discord.js-commando": "github:gawdl3y/discord.js-commando",
"erlpack": "github:hammerandchisel/erlpack",
"mathjs": "^3.16.0",
"mathjs": "^3.16.1",
"moment": "^2.18.1",
"moment-duration-format": "^1.3.0",
"snekfetch": "^3.2.9",
@@ -46,7 +46,7 @@
"zalgolize": "^1.2.4"
},
"devDependencies": {
"eslint": "^4.4.0",
"eslint": "^4.4.1",
"eslint-config-aqua": "^1.4.1"
},
"eslintConfig": {
@@ -55,7 +55,8 @@
"camelcase": "off",
"id-length": "off",
"no-await-in-loop": "off",
"no-console": "off"
"no-console": "off",
"no-process-env": "off"
}
}
}
+4 -4
View File
@@ -1,5 +1,5 @@
const snekfetch = require('snekfetch');
const { carbonKey, dbotsKey, dbotsOrgKey } = require('../config');
const { CARBON_KEY, DBOTS_KEY, DBOTSORG_KEY } = process.env;
class Util {
static cleanXML(str) {
@@ -15,7 +15,7 @@ class Util {
static dBots(count, id) {
snekfetch
.post(`https://bots.discord.pw/api/bots/${id}/stats`)
.set({ Authorization: dbotsKey })
.set({ Authorization: DBOTS_KEY })
.send({ server_count: count })
.then(() => console.log('[DBOTS] Successfully posted to Discord Bots.'))
.catch(err => console.error(`[DBOTS] Failed to post to Discord Bots. ${err}`));
@@ -25,7 +25,7 @@ class Util {
snekfetch
.post('https://www.carbonitex.net/discord/data/botdata.php')
.send({
key: carbonKey,
key: CARBON_KEY,
servercount: count
})
.then(() => console.log('[CARBON] Successfully posted to Carbon.'))
@@ -35,7 +35,7 @@ class Util {
static dBotsOrg(count, id) {
snekfetch
.post(`https://discordbots.org/api/bots/${id}/stats`)
.set({ Authorization: dbotsOrgKey })
.set({ Authorization: DBOTSORG_KEY })
.send({ server_count: count })
.then(() => console.log('[DBOTSORG] Successfully posted to Discord Bots Org.'))
.catch(err => console.error(`[DBOTSORG] Failed to post to Discord Bots Org. ${err}`));