From 7412cdba75ce313907dfbae3a90a751c7177e199 Mon Sep 17 00:00:00 2001 From: Maseshi Date: Wed, 26 Apr 2023 15:07:20 +0700 Subject: [PATCH] =?UTF-8?q?=E2=9E=95=20ADD:=20New=20`qrcode`=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/commands/tools/qrcode.js | 58 +++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 source/commands/tools/qrcode.js diff --git a/source/commands/tools/qrcode.js b/source/commands/tools/qrcode.js new file mode 100644 index 00000000..03fafca9 --- /dev/null +++ b/source/commands/tools/qrcode.js @@ -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 ", + "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] }); + } +}; \ No newline at end of file