✨ add plugin fun and module meme
This commit is contained in:
parent
7837a24a57
commit
b924ab9f3d
4 changed files with 66 additions and 1 deletions
|
@ -30,7 +30,7 @@
|
|||
"@crowdin/ota-client": "^0.7.0",
|
||||
"@discordjs/builders": "^0.13.0",
|
||||
"@discordjs/rest": "^0.4.0",
|
||||
"axios": "^0.26.0",
|
||||
"axios": "^0.26.1",
|
||||
"chance": "^1.1.8",
|
||||
"common": "^0.2.5",
|
||||
"crypto": "^1.0.1",
|
||||
|
|
25
src/plugins/fun/index.ts
Normal file
25
src/plugins/fun/index.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
import { SlashCommandBuilder } from "@discordjs/builders";
|
||||
import { CommandInteraction } from "discord.js";
|
||||
import logger from "@logger";
|
||||
|
||||
import modules from "@plugins/fun/modules";
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("fun")
|
||||
.setDescription("Fun commands.")
|
||||
|
||||
.addSubcommand(modules.meme.data),
|
||||
|
||||
async execute(interaction: CommandInteraction) {
|
||||
const { options } = interaction;
|
||||
|
||||
switch (options.getSubcommand()) {
|
||||
case "meme":
|
||||
await modules.meme.execute(interaction);
|
||||
break;
|
||||
default:
|
||||
logger.verbose(`Unknown subcommand ${options.getSubcommand()}`);
|
||||
}
|
||||
},
|
||||
};
|
5
src/plugins/fun/modules/index.ts
Normal file
5
src/plugins/fun/modules/index.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
import meme from "@plugins/fun/modules/meme";
|
||||
|
||||
export default {
|
||||
meme,
|
||||
};
|
35
src/plugins/fun/modules/meme.ts
Normal file
35
src/plugins/fun/modules/meme.ts
Normal file
|
@ -0,0 +1,35 @@
|
|||
import { successColor, footerText, footerIcon } from "@config/embed";
|
||||
|
||||
import axios from "axios";
|
||||
import { CommandInteraction, MessageEmbed } from "discord.js";
|
||||
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||
import logger from "@logger";
|
||||
|
||||
export default {
|
||||
data: (command: SlashCommandSubcommandBuilder) => {
|
||||
return command.setName("meme").setDescription("Get a meme from r/memes)");
|
||||
},
|
||||
execute: async (interaction: CommandInteraction) => {
|
||||
await axios
|
||||
.get("https://www.reddit.com/r/memes/random/.json")
|
||||
.then(async (res) => {
|
||||
const response = res.data[0].data.children;
|
||||
const content = response[0].data;
|
||||
|
||||
const embed = new MessageEmbed()
|
||||
.setTitle(content.title)
|
||||
.setTimestamp(new Date())
|
||||
.setImage(content.url)
|
||||
.setFooter({
|
||||
text: `👍 ${content.ups}︱👎 ${content.downs}\n${footerText}`,
|
||||
iconURL: footerIcon,
|
||||
})
|
||||
.setColor(successColor);
|
||||
|
||||
return interaction.editReply({ embeds: [embed] });
|
||||
})
|
||||
.catch((error) => {
|
||||
logger.error(`${error}`);
|
||||
});
|
||||
},
|
||||
};
|
Loading…
Add table
Reference in a new issue