Adding QR Generator
This commit is contained in:
parent
fe217b04f5
commit
c394af15d3
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
.env
|
.env
|
||||||
node_modules
|
node_modules
|
||||||
|
images
|
||||||
|
BIN
Terminal-icon.png
Normal file
BIN
Terminal-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 144 KiB |
@ -7,7 +7,6 @@ module.exports = {
|
|||||||
name: "joke",
|
name: "joke",
|
||||||
description: "Gets a funny joke",
|
description: "Gets a funny joke",
|
||||||
|
|
||||||
|
|
||||||
run: async (client, interaction) => {
|
run: async (client, interaction) => {
|
||||||
giveMeAJoke.getRandomDadJoke(function (joke) {
|
giveMeAJoke.getRandomDadJoke(function (joke) {
|
||||||
|
|
||||||
|
26
commands/untils/activity.js
Normal file
26
commands/untils/activity.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
const { EmbedBuilder } = require('discord.js');
|
||||||
|
var unirest = require('unirest');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "bored",
|
||||||
|
description: "Find an activity to do when you are bored.",
|
||||||
|
|
||||||
|
run: async (client, interaction) => {
|
||||||
|
|
||||||
|
unirest
|
||||||
|
.get('https://www.boredapi.com/api/activity')
|
||||||
|
.headers({
|
||||||
|
'Accept': 'application/json', 'Content-Type': 'application/json',
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
let data = response.body
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setColor("#FF0000")
|
||||||
|
.setTitle("🏓 Pong!")
|
||||||
|
.setDescription(data.activity)
|
||||||
|
.setTimestamp()
|
||||||
|
.setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` });
|
||||||
|
interaction.followUp({ embeds: [embed] });
|
||||||
|
})
|
||||||
|
},
|
||||||
|
};
|
52
commands/untils/qrgen.js
Normal file
52
commands/untils/qrgen.js
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
const { EmbedBuilder } = require('discord.js');
|
||||||
|
const { AttachmentBuilder } = require('discord.js');
|
||||||
|
const { AwesomeQR } = require("awesome-qr");
|
||||||
|
const fs = require("fs");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "qr",
|
||||||
|
description: "Returns websocket latency",
|
||||||
|
options: [{
|
||||||
|
"name": "text-data",
|
||||||
|
"description": "The data you would like inside of the QR",
|
||||||
|
"required": true,
|
||||||
|
"type": 3 // 6 is type USER
|
||||||
|
}],
|
||||||
|
|
||||||
|
run: async (client, interaction) => {
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
let rand = Math.floor(Math.random() * 99999).toString();
|
||||||
|
let text = interaction.options._hoistedOptions[0].value
|
||||||
|
|
||||||
|
const background = fs.readFileSync("Terminal-icon.png");
|
||||||
|
|
||||||
|
const buffer = await new AwesomeQR({
|
||||||
|
text: text,
|
||||||
|
size: 500,
|
||||||
|
backgroundImage: background,
|
||||||
|
|
||||||
|
}).draw();
|
||||||
|
|
||||||
|
fs.writeFileSync("./images/" + rand + ".png", buffer);
|
||||||
|
const file = new AttachmentBuilder('./images/' + rand + ".png");
|
||||||
|
const exampleEmbed = {
|
||||||
|
title: 'QR Code',
|
||||||
|
image: {
|
||||||
|
url: 'attachment://discordjs.png',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setColor("#FF0000")
|
||||||
|
.setTitle("Your Generated QR Code")
|
||||||
|
.setTimestamp()
|
||||||
|
.setImage('attachment://images/' + rand + ".png")
|
||||||
|
|
||||||
|
.setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` });
|
||||||
|
interaction.editReply({ embeds: [embed], files: [file] });
|
||||||
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
};
|
1057
package-lock.json
generated
1057
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -10,12 +10,14 @@
|
|||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"awesome-qr": "^2.1.5-rc.0",
|
||||||
"discord.js": "^14.0.3",
|
"discord.js": "^14.0.3",
|
||||||
"dotenv": "^16.0.0",
|
"dotenv": "^16.0.0",
|
||||||
"give-me-a-joke": "^0.5.1",
|
"give-me-a-joke": "^0.5.1",
|
||||||
"glob": "^7.2.0",
|
"glob": "^7.2.0",
|
||||||
"is-not-defined": "^1.0.1",
|
"is-not-defined": "^1.0.1",
|
||||||
"random-text-meme": "^1.1.9",
|
"random-text-meme": "^1.1.9",
|
||||||
|
"unirest": "^0.6.0",
|
||||||
"urban": "^0.3.4"
|
"urban": "^0.3.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user