Skip to content

Commit

Permalink
➕ ADD: New qrcode command
Browse files Browse the repository at this point in the history
  • Loading branch information
Maseshi committed Apr 26, 2023
1 parent 1f74982 commit 7412cdb
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions source/commands/tools/qrcode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const { EmbedBuilder, PermissionsBitField } = require("discord.js");

module.exports = {
"enable": true,
"name": "qrcode",
"description": "Generate your QR code.",
"category": "tools",
"permissions": {
"client": [PermissionsBitField.Flags.SendMessages]
},
"usage": "qrcode <text(String)>",
"function": {
"command": {}
}
};

module.exports.function.command = {
"data": {
"name": module.exports.name,
"name_localizations": {
"th": "คิวอาร์โค้ด"
},
"description": module.exports.description,
"description_localizations": {
"th": "สร้างคิวอาร์โค้ดของคุณ"
},
"options": [
{
"type": 3,
"name": "text",
"name_localizations": {
"th": "ข้อความ"
},
"description": "Message to be encrypted.",
"description_localizations": {
"th": "ข้อความหรือลิงค์ที่ต้องการจะสร้างคิวอาร์โค้ด"
},
"required": true
}
]
},
async execute(interaction) {
const inputText = interaction.options.getString("text");

const apiURL = "https://api.qrserver.com/v1";
const createQRCode = "/create-qr-code/?size=1024x1024&data=";
const data = apiURL + createQRCode + inputText.replace(new RegExp(" ", "g"), "%20")

const qrcodeEmbed = new EmbedBuilder()
.setColor("White")
.setTitle(interaction.client.translate.commands.qrcode.qrcode_title)
.setDescription(interaction.client.translate.commands.qrcode.qrcode_success)
.setImage(data)
.setTimestamp();

await interaction.reply({ "embeds": [qrcodeEmbed] });
}
};

0 comments on commit 7412cdb

Please sign in to comment.