Skip to content

Commit

Permalink
feat: Added new Commands
Browse files Browse the repository at this point in the history
feat(Fun): /pixelate
feat(Fun): /meme

fix(Fun): fetch now doesn't spam console
  • Loading branch information
Cunga0X committed Dec 25, 2022
1 parent 4700091 commit 28bf36c
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,5 @@ dist

# TernJS port file
.tern-port
# Configuration
config.json
3 changes: 1 addition & 2 deletions Commands/Fun/joke.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/*jshint esversion: 6 */

const { ChatInputCommandInteraction, EmbedBuilder } = require("discord.js");
const fetch = (...args) => import("node-fetch").then(({ default: fetch }) => fetch(...args));

module.exports = {
name: "joke",
Expand Down
33 changes: 33 additions & 0 deletions Commands/Fun/meme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const { ChatInputCommandInteraction, EmbedBuilder } = require("discord.js");
const fetch = (...args) => import("node-fetch").then(({ default: fetch }) => fetch(...args)); // since require is not supported, we will use this
//workaround to import node-fetch

module.exports = {
name: "meme",
description: "Get random meme",
category: "Fun",

/**
*
* @param {ChatInputCommandInteraction} interaction
*/

async execute(interaction) {
interaction.deferReply();
const embed = new EmbedBuilder();

await fetch("https://www.reddit.com/r/memes/random/.json").then(async (res) => {
let meme = await res.json();

console.log(meme);

let title = meme[0].data.children[0].data.title;
let url = meme[0].data.children[0].data.url;
let author = meme[0].data.children[0].data.author;

await interaction.editReply({
embeds: [embed.setTitle(title).setImage(url).setURL(url).setColor("Blurple").setFooter({ text: author })],
});
});
},
};
36 changes: 36 additions & 0 deletions Commands/Fun/pixelate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const { ChatInputCommandInteraction } = require("discord.js");

module.exports = {
name: "pixelate",
description: "Get a pixelated form of a user's avatar",
category: "Fun",
options: [
{
name: "user",
description: "select a user",
type: 6,
required: true,
},
],

/**
*
* @param {ChatInputCommandInteraction} interaction
*/

async execute(interaction) {
const { options } = interaction;
const user = options.getUser("user");

if (!user) {
user = interaction.user;
}

let avatarUrl = user.avatarURL({ size: 512, extension: "jpg" });
let canvas = `https://some-random-api.ml/canvas/pixelate?avatar=${avatarUrl}`;

await interaction.reply({
content: canvas,
});
},
};
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
- [Contributing](#contributing)
- [License](#license)
- [Authors](#authors)
- [Acknowledgements](#acknowledgements)

## Built With

Expand Down

0 comments on commit 28bf36c

Please sign in to comment.