mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-27 15:34:26 -04:00
feat: rename CuteAnimeGirls plugin to Memes and update functionality to send Reddit memes
This commit is contained in:
parent
3b7e853eb0
commit
8edb31478e
1 changed files with 6 additions and 15 deletions
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { EquicordDevs } from "@utils/constants";
|
||||
|
||||
import { ApplicationCommandOptionType } from "../../api/Commands";
|
||||
import definePlugin from "../../utils/types";
|
||||
|
||||
function rand(min, max) {
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
}
|
||||
|
||||
async function fetchReddit(sub: string) {
|
||||
const res = await fetch(`https://www.reddit.com/r/${sub}/top.json?limit=100&t=all`);
|
||||
const resp = await res.json();
|
||||
try {
|
||||
const { children } = resp.data;
|
||||
const r = rand(0, children.length - 1);
|
||||
return children[r].data.url;
|
||||
} catch (err) {
|
||||
console.error(resp);
|
||||
console.error(err);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
export default definePlugin({
|
||||
name: "CuteAnimeGirls",
|
||||
authors: [EquicordDevs.ShadyGoat],
|
||||
description: "Add a command to send cute anime girls in the chat",
|
||||
commands: [{
|
||||
name: "anime-girls",
|
||||
description: "Send cute anime girls",
|
||||
options: [
|
||||
{
|
||||
name: "cat",
|
||||
description: "If set, this will send exclusively cute anime cat girls",
|
||||
type: ApplicationCommandOptionType.BOOLEAN,
|
||||
required: false,
|
||||
},
|
||||
],
|
||||
|
||||
async execute(args) {
|
||||
let sub = "cuteanimeboys";
|
||||
if (args.length > 0) {
|
||||
const v = args[0].value as any as boolean;
|
||||
if (v) {
|
||||
sub = "animecatboys";
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
content: await fetchReddit(sub),
|
||||
};
|
||||
},
|
||||
}]
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue