aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app.js12
-rw-r--r--command_impls.js14
-rw-r--r--commands.js7
3 files changed, 31 insertions, 2 deletions
diff --git a/app.js b/app.js
index 48b58ea..627dc3f 100644
--- a/app.js
+++ b/app.js
@@ -6,7 +6,14 @@ import {
verifyKeyMiddleware,
} from "discord-interactions";
import { Client, GatewayIntentBits, ActivityType } from "discord.js";
-import { blep, help, pet, schedule_message, catfact } from "./command_impls.js";
+import {
+ blep,
+ help,
+ pet,
+ schedule_message,
+ catfact,
+ fomx,
+} from "./command_impls.js";
import { MessageSchedule } from "./message-scheduler.js";
class State {
@@ -40,6 +47,9 @@ function handle_application_command(state, data, channel_id) {
case "catfact":
return catfact(state);
+ case "fomx":
+ return fomx(state);
+
default:
console.error(`unknown command: ${name}`);
return res.status(400).json({ error: "unknown command" });
diff --git a/command_impls.js b/command_impls.js
index ee2db6d..4665044 100644
--- a/command_impls.js
+++ b/command_impls.js
@@ -50,7 +50,6 @@ export function blep(state) {
export function catfact(state) {
get("https://meowfacts.herokuapp.com/", (res) => {
res.on("data", (d) => {
- process.stdout.write(d);
const obj = JSON.parse(d);
const fact = obj.data[0];
return send(state, { content: fact });
@@ -60,3 +59,16 @@ export function catfact(state) {
return send(state, { content: "failed to request fact" });
});
}
+
+export function fomx(state) {
+ get("https://randomfox.ca/floof/", (res) => {
+ res.on("data", (d) => {
+ const obj = JSON.parse(d);
+ const fomx = obj.image;
+ return send(state, { content: fomx });
+ });
+ }).on("error", (e) => {
+ console.error(e);
+ return send(state, { content: "failed to get fomx" });
+ });
+}
diff --git a/commands.js b/commands.js
index 31f7b34..0fad456 100644
--- a/commands.js
+++ b/commands.js
@@ -32,6 +32,13 @@ const commands = [
contexts: [0],
},
{
+ name: "fomx",
+ description: "get a fomx picture",
+ type: 1,
+ integration_types: [0],
+ contexts: [0],
+ },
+ {
name: "schedule_message",
description: "Register a message to run as a cron job",
type: 1,