-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added new commands: system, debug - system: displays information about your os. - debug: displays information about outside dependencies. - removed old commands - finance: its been gone, but now bear no longer requires the yahoo-finance package - shibe: the site is dead (azrogers/ShibeOnline#3). D: - moved some commands around, added some small features - handle outside dependency requirements """better\""" - there is now a function that checks for them; they're handled in a more unified way now. - in the future, there should be a property of the command block that defines and handles these. - update package.json to use a specific version of whatwg-url that doesn't directly require punycode (gets around DEP0040). this is a jump from v5 to v14, but there have been no issues in testing, so hopefully things continue to just work...
- Loading branch information
1 parent
3b9cc78
commit 2f2c2ab
Showing
19 changed files
with
542 additions
and
781 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const CommandBlock = require("../../modules/CommandBlock"); | ||
const fetch = require("node-fetch"); | ||
const { weightedRandom } = require("../../modules/miscellaneous"); | ||
const { MessageEmbed } = require("discord.js"); | ||
|
||
/** | ||
* Polar bear weights. The keys correspond to the images in `assets/bears/`. Higher numbers correspond to more common bears. | ||
* @todo I would like to credit whoever made these edits but I'm genuinely uncertain who did. I will look into it. | ||
*/ | ||
const bears = { | ||
"bear.gif": 1000, | ||
"speedy.gif": 50, | ||
"child.gif": 10, | ||
"gay.gif": 10, | ||
"corrupted.gif": 10, | ||
"sugoi.gif": 1, | ||
}; | ||
|
||
module.exports = [ | ||
new CommandBlock({ | ||
names: ["bear"], | ||
description: "<a:_:588518103814504490>\n\n**Tip:** Try your luck to get a rare bear.", | ||
clientChannelPermissions: ["ATTACH_FILES"], | ||
}, function(client, message, content, args) { | ||
if(!client.storage.has("local.bear")) { | ||
client.storage.set("local.bear", { points: 0 }); | ||
} | ||
let bearpoints = client.storage.get("local.bear.points"); | ||
bearpoints++; | ||
|
||
const img = weightedRandom(Object.keys(bears), bears); | ||
const embed = new MessageEmbed() | ||
.setColor("#FEFEFE") | ||
.setTitle("he's here...") | ||
.setImage(`attachment://${img}`) | ||
.setFooter({ text: `\uD83D\uDC3B ${bearpoints}` }); | ||
message.reply({ embeds: [embed], files: [`assets/bears/${img}`], allowedMentions: { repliedUser: false } }); | ||
|
||
client.storage.set("local.bear.points", bearpoints); | ||
}), | ||
new CommandBlock({ | ||
names: ["httpcat", "cattp", "http"], | ||
description: "Gets an HTTP cat code. Images fetched from [http.cat](https://http.cat).", | ||
usage: "(code)", | ||
clientChannelPermissions: ["ATTACH_FILES"], | ||
}, async function(client, message, content, [code]) { | ||
try { | ||
await message.reply({ files: [`https://http.cat/${code}.jpg`], allowedMentions: { repliedUser: false } }); | ||
} catch(e) { // just in case ;) | ||
message.reply({ files: [{ attachment: "../../assets/service_unavailable.jpg", name: "service_unavailable.jpg" }], allowedMentions: { repliedUser: false } }); | ||
} | ||
}), | ||
]; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
const CommandBlock = require("../../modules/CommandBlock"); | ||
const { sleep } = require("../../modules/miscellaneous"); | ||
const fetch = require("node-fetch"); | ||
|
||
const ball_responses = ["As I see it, yes.", "Ask again later.", "Better not tell you now.", "Cannot predict now.", "Concentrate and ask again.", "Don't count on it.", "It is certain.", "It is decidedly so.", "Most likely.", "My reply is no.", "My sources say no.", "Outlook not so good.", "Outlook good.", "Reply hazy, try again.", "Signs point to yes.", "Very doubtful.", "Without a doubt.", "Yes.", "Yes - definitely.", "You may rely on it."]; | ||
const cooltext_font_endpoints = require("../../data/cooltext_font_endpoints.json"); /** A list of fonts and font endpoints from cooltext.com. */ | ||
const cooltext_settings = { | ||
charlimit: 256, /** (Very arbitrary) character limit for each image. */ | ||
cooldown: 500, /** Cooldown in ms. */ | ||
}; | ||
|
||
module.exports = [ | ||
new CommandBlock({ | ||
names: ["2b2t"], | ||
summary: "Gets the current queue length of 2b2t.", | ||
description: "Gets the current queue length of 2b2t. Data fetched from [2b2t.io](https://2b2t.io/).", | ||
}, async function(client, message, content, args) { | ||
try { | ||
const resp = await fetch("https://2b2t.io/api/queue?last=true"); | ||
if(!resp.ok) throw new Error(resp.statusText); | ||
|
||
const json = await resp.json(); | ||
if(!json || !json[0] || !json[0][1]) throw new Error("Recieved malformed json."); | ||
|
||
return message.reply({ content: `The 2b2t.org queue is **${json[0][1]}** users long.`, allowedMentions: { repliedUser: false } }); | ||
} catch(e) { | ||
return message.reply({ content: `${client.reactions.negative.emote} An error occured;\`\`\`\n${e.message}\`\`\`` }); | ||
} | ||
}), | ||
new CommandBlock({ | ||
names: ["8ball", "8"], | ||
description: "Shakes a magic 8 ball.", | ||
usage: "[query]", | ||
}, async function(client, message, content, args) { | ||
if(!content) return message.reply(`${client.reactions.negative.emote} You need to ask it something!`); | ||
return message.reply({ content: `\uD83C\uDFB1 ${ball_responses[Math.floor(Math.random() * ball_responses.length)]}`, allowedMentions: { repliedUser: false } }); // if you're reading this, im sorry for ruining the magic | ||
}), | ||
new CommandBlock({ | ||
names: ["cooltext"], | ||
description: `Creates cool text. Images are generated from https://cooltext.com.\n\nSupported fonts;\`\`\`${Object.keys(cooltext_font_endpoints).join(", ")}\`\`\`\nNote there is a character limit of ${cooltext_settings.charlimit} per image.`, | ||
usage: "[font] [...text]", | ||
clientChannelPermissions: ["ATTACH_FILES"], | ||
}, async function(client, message, content, [font, ...args]) { | ||
if(!content) return message.reply(`${client.reactions.negative.emote} You must input a piece of text to render!`); | ||
|
||
const text = args.join(" "); | ||
if(text.length > cooltext_settings.charlimit) return message.reply(`${client.reactions.negative.emote} There is a character limit of ${cooltext_settings.charlimit} per image.`); | ||
|
||
const _now = Date.now(); | ||
client.cookies["cooltext_cooldown"] = client.cookies["cooltext_cooldown"] ?? _now; | ||
if(client.cookies["cooltext_cooldown"] > _now) { | ||
await sleep(client.cookies["cooltext_cooldown"] - _now); | ||
} | ||
client.cookies["cooltext_cooldown"] = Date.now() + cooltext_settings.cooldown; | ||
|
||
if(!(font in cooltext_font_endpoints)) return message.reply(`${client.reactions.negative.emote} The provided font does not exist.`); | ||
|
||
const serialized_text = encodeURIComponent(text).replace(/%20/g, "+"); | ||
const data = cooltext_font_endpoints[font] + `&Text=${serialized_text}`; | ||
|
||
// This API isn't public, so this will probably break eventually. | ||
try { | ||
const resp = await fetch("https://cooltext.com/PostChange", { | ||
method: "post", | ||
body: data, | ||
headers: { | ||
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", | ||
"Content-Length": data.length, | ||
}, | ||
}); | ||
|
||
if(!resp.ok) { | ||
throw new Error(resp.statusText); | ||
} | ||
|
||
const json = await resp.json(); | ||
if(!json || !json.renderLocation) throw new Error("Recieved malformed json."); | ||
|
||
return message.reply({ files: [json.renderLocation.replace("https", "http")], allowedMentions: { repliedUser: false } }); // They dont encrypt things correctly on their end, requiring us to use HTTP. | ||
} catch(e) { | ||
return message.reply(`${client.reactions.negative.emote} An error occured;\`\`\`\n${e.message}\`\`\``); | ||
} | ||
}), | ||
new CommandBlock({ | ||
names: ["burning"], | ||
description: "Makes really awesome burning text, generated from https://cooltext.com. \n\nThis command is an alias of `cooltext burning`.", | ||
usage: "[text]", | ||
clientChannelPermissions: ["ATTACH_FILES"] | ||
}, async function(client, message, content, args) { | ||
return client.commands.runByName("cooltext", message, "burning", ["burning", ...args]); | ||
}) | ||
]; |
Oops, something went wrong.