-
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.
feat(Fun): /pixelate feat(Fun): /meme fix(Fun): fetch now doesn't spam console
- Loading branch information
Showing
5 changed files
with
72 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,3 +102,5 @@ dist | |
|
||
# TernJS port file | ||
.tern-port | ||
# Configuration | ||
config.json |
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,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 })], | ||
}); | ||
}); | ||
}, | ||
}; |
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,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, | ||
}); | ||
}, | ||
}; |
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