├── .github └── FUNDING.yml ├── LICENSE ├── README.md ├── photos ├── pic1.png ├── pic2.png ├── pic3.png ├── pic4.png └── readme.md └── src ├── commands ├── help.js ├── redeem.js ├── rlogs.js ├── ruser.js └── setseller.js ├── index.js └── package.json /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [mazkdevf, keyauth] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: ['https://keyauth.win', 'https://keyauth.cc'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Elastic License 2.0 2 | 3 | URL: https://www.elastic.co/licensing/elastic-license 4 | 5 | ## Acceptance 6 | 7 | By using the software, you agree to all of the terms and conditions below. 8 | 9 | ## Copyright License 10 | 11 | The licensor grants you a non-exclusive, royalty-free, worldwide, 12 | non-sublicensable, non-transferable license to use, copy, distribute, make 13 | available, and prepare derivative works of the software, in each case subject to 14 | the limitations and conditions below. 15 | 16 | ## Limitations 17 | 18 | You may not provide the software to third parties as a hosted or managed 19 | service, where the service provides users with access to any substantial set of 20 | the features or functionality of the software. 21 | 22 | You may not move, change, disable, or circumvent the license key functionality 23 | in the software, and you may not remove or obscure any functionality in the 24 | software that is protected by the license key. 25 | 26 | You may not alter, remove, or obscure any licensing, copyright, or other notices 27 | of the licensor in the software. Any use of the licensor’s trademarks is subject 28 | to applicable law. 29 | 30 | ## Patents 31 | 32 | The licensor grants you a license, under any patent claims the licensor can 33 | license, or becomes able to license, to make, have made, use, sell, offer for 34 | sale, import and have imported the software, in each case subject to the 35 | limitations and conditions in this license. This license does not cover any 36 | patent claims that you cause to be infringed by modifications or additions to 37 | the software. If you or your company make any written claim that the software 38 | infringes or contributes to infringement of any patent, your patent license for 39 | the software granted under these terms ends immediately. If your company makes 40 | such a claim, your patent license ends immediately for work on behalf of your 41 | company. 42 | 43 | ## Notices 44 | 45 | You must ensure that anyone who gets a copy of any part of the software from you 46 | also gets a copy of these terms. 47 | 48 | If you modify the software, you must include in any modified copies of the 49 | software prominent notices stating that you have modified the software. 50 | 51 | ## No Other Rights 52 | 53 | These terms do not imply any licenses other than those expressly granted in 54 | these terms. 55 | 56 | ## Termination 57 | 58 | If you use the software in violation of these terms, such use is not licensed, 59 | and your licenses will automatically terminate. If the licensor provides you 60 | with a notice of your violation, and you cease all violation of this license no 61 | later than 30 days after you receive that notice, your licenses will be 62 | reinstated retroactively. However, if you violate these terms after such 63 | reinstatement, any additional violation of these terms will cause your licenses 64 | to terminate automatically and permanently. 65 | 66 | ## No Liability 67 | 68 | *As far as the law allows, the software comes as is, without any warranty or 69 | condition, and the licensor will not be liable to you for any damages arising 70 | out of these terms or the use or nature of the software, under any kind of 71 | legal claim.* 72 | 73 | ## Definitions 74 | 75 | The **licensor** is the entity offering these terms, and the **software** is the 76 | software the licensor makes available under these terms, including any portion 77 | of it. 78 | 79 | **you** refers to the individual or entity agreeing to these terms. 80 | 81 | **your company** is any legal entity, sole proprietorship, or other kind of 82 | organization that you work for, plus all organizations that have control over, 83 | are under the control of, or are under common control with that 84 | organization. **control** means ownership of substantially all the assets of an 85 | entity, or the power to direct its management and policies by vote, contract, or 86 | otherwise. Control can be direct or indirect. 87 | 88 | **your licenses** are all the licenses granted to you for the software under 89 | these terms. 90 | 91 | **use** means anything you do with the software requiring one of your licenses. 92 | 93 | **trademark** means trademarks, service marks, and similar rights. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## KeyAuth Redeem Bot - V14 2 | 3 | Created for application resellers/sellers so users can redeem licenses to get role or user and password from the key. 4 | 5 |
6 | Showcase Pictures 7 | 8 | ![](photos/pic4.png "Logs") 9 | ![](photos/pic1.png "When user redeemed") 10 | ![](photos/pic2.png "License redeemed") 11 | ![](photos/pic3.png "Logging enabled") 12 |
13 | 14 | ###### Bot Commands 15 | `/redeem ` will give user role with that key. 16 | 17 | `/ruser [OPTIONAL ]` If optionals not used it will create random ones, otherwise will create account with ur choices 18 | 19 | `/rlogs` Create logging channel for KeyAuth Redeem Bot 20 | 21 | `/help` Shows basic help things 22 | 23 | `/setseller` Set up KeyAuth Seller Plan Sellerkey. 24 | 25 | ###### Requirements 26 | 27 | ```md 28 | Latest NodeJS 29 | Discord Bot 30 | KeyAuth Seller Plan / Subscription 31 | ``` 32 | 33 | ###### Setup 34 | 35 | ###### Discord Developer Portal 36 | `https://discord.com/api/oauth2/authorize?client_id=&permissions=8&scope=bot%20applications.commands` 37 | ```js 38 | #1: When inviting bot use this but replace ^^^^ with your bot ID 39 | #2: When you have done inviting do this step on discord oauth bot tab: https://i.imgur.com/lZvyONH.png 40 | #3: And bot should now have permission to put commands on that server. 41 | ``` 42 | 43 | ###### Discord Bot Source 44 | ```md 45 | #1: Install the Latest Version of the Main Branch 46 | #2: Open folder/src folder 47 | #3: Drag files inside that to any folder 48 | #4: Open Index.js with the code editor of your choice 49 | #5: Change 20 and 28-29 lines. 50 | #6: open cmd to that folder and run this npm install 51 | #7: then you can run the bot with node . or node filename.js 52 | ``` 53 | 54 | ## Copyright License 55 | 56 | KeyAuth is licensed under **Elastic License 2.0** 57 | 58 | * You may not provide the software to third parties as a hosted or managed 59 | service, where the service provides users with access to any substantial set of 60 | the features or functionality of the software. 61 | 62 | * You may not move, change, disable, or circumvent the license key functionality 63 | in the software, and you may not remove or obscure any functionality in the 64 | software that is protected by the license key. 65 | 66 | * You may not alter, remove, or obscure any licensing, copyright, or other notices 67 | of the licensor in the software. Any use of the licensor’s trademarks is subject 68 | to applicable law. 69 | 70 | Thank you for your compliance, we work hard on the development of KeyAuth and do not appreciate our copyright being infringed. -------------------------------------------------------------------------------- /photos/pic1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazkdevf/Keyauth-Redeem-Bot/3ca2df8561069f225867eb04716f50746c73cf4c/photos/pic1.png -------------------------------------------------------------------------------- /photos/pic2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazkdevf/Keyauth-Redeem-Bot/3ca2df8561069f225867eb04716f50746c73cf4c/photos/pic2.png -------------------------------------------------------------------------------- /photos/pic3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazkdevf/Keyauth-Redeem-Bot/3ca2df8561069f225867eb04716f50746c73cf4c/photos/pic3.png -------------------------------------------------------------------------------- /photos/pic4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazkdevf/Keyauth-Redeem-Bot/3ca2df8561069f225867eb04716f50746c73cf4c/photos/pic4.png -------------------------------------------------------------------------------- /photos/readme.md: -------------------------------------------------------------------------------- 1 | hello there 2 | -------------------------------------------------------------------------------- /src/commands/help.js: -------------------------------------------------------------------------------- 1 | const { SlashCommandBuilder, EmbedBuilder, Colors } = require("discord.js"); 2 | 3 | module.exports = { 4 | data: new SlashCommandBuilder() 5 | .setName("help") 6 | .setDescription("The help command, what do you expect?"), 7 | 8 | async execute(interaction) { 9 | 10 | let prefix = "/"; // Slash Prefix 11 | 12 | await interaction.deferReply({ ephemeral: true }); 13 | 14 | const embed = new EmbedBuilder() 15 | .setTitle('Redeem Help') 16 | .addFields( 17 | { name: '`redeem`', value: `Redeem a License. \nArgs: **${prefix}redeem**`, inline: true }, 18 | { name: '`ruser`', value: `Redeem a Username + password from license \nArgs: **${prefix}ruser**`, inline: true }, 19 | { name: '`rlogs`', value: `Enable Logging for redeems, / ye \nArgs: **${prefix}rlogs**`, inline: false }, 20 | ) 21 | .setFooter({ text: "KeyAuth Redeem Bot v5.2.2" }) 22 | .setTimestamp() 23 | 24 | interaction.editReply({ 25 | embeds: [embed], 26 | ephemeral: true, 27 | }); 28 | }, 29 | }; -------------------------------------------------------------------------------- /src/commands/redeem.js: -------------------------------------------------------------------------------- 1 | const { SlashCommandBuilder, EmbedBuilder, Colors } = require("discord.js"); 2 | const fetch = require('node-fetch') 3 | const db = require('quick.db'); 4 | 5 | module.exports = { 6 | data: new SlashCommandBuilder() 7 | .setName("redeem") 8 | .setDescription("Redeem a license key to get role.") 9 | .addStringOption((option) => 10 | option 11 | .setName("license") 12 | .setDescription("Your license key that you wan't to redeem.") 13 | .setRequired(true) 14 | ), 15 | 16 | async execute(interaction, client) { 17 | let sellerkey = await db.get(`token_${interaction.guild.id}`) 18 | if (sellerkey === null) return interaction.reply({ embeds: [new EmbedBuilder().setDescription(`Seller key haven't been set up yet!`).setColor(Colors.Red)], ephemeral: true, }); 19 | 20 | let key = await interaction.options.getString("license") 21 | 22 | if(client.use_once) { 23 | if(db.fetch(`${key}`)) { 24 | //Logs 25 | const channel = interaction.guild.channels.cache.find(channel => channel.name === 'prebeta-logs'); 26 | 27 | if (channel) { 28 | channel.send({ 29 | embeds: [new EmbedBuilder().setAuthor({ name: "License already redeemed!" }) 30 | .addFields( 31 | { name: 'License:', value: "```" + `${key}` + "```", inline: false }, 32 | { name: 'Discord:', value: "```" + interaction.member.user.username + "#" + interaction.member.user.discriminator + "```", inline: true }, 33 | { name: 'DiscordID:', value: "```" + interaction.member.user.id + "```", inline: true }, 34 | ) 35 | 36 | 37 | .setColor(Colors.Red).setFooter({ text: "KeyAuth Redeem Bot v5.2.2" })] 38 | }); 39 | } 40 | 41 | return interaction.reply({ embeds: [new EmbedBuilder().setDescription(`This key has already been redeemed!`).setColor(Colors.Red)], ephemeral: true, }); 42 | } 43 | } 44 | 45 | await interaction.deferReply({ ephemeral: true }); 46 | 47 | interaction.editReply({ 48 | embeds: [new EmbedBuilder().setTitle('Redeeming...').setColor(Colors.Red)], 49 | ephemeral: true, 50 | }); 51 | 52 | async function checkResponseStatus(res) { 53 | if (res.ok) { 54 | giveroletouser(); 55 | } else { 56 | 57 | const channel = interaction.guild.channels.cache.find(channel => channel.name === 'prebeta-logs'); 58 | 59 | interaction.editReply({ 60 | embeds: [new EmbedBuilder().setTitle('License Key Not Found').setColor(Colors.Red)], 61 | ephemeral: true, 62 | }); 63 | 64 | if (channel) { 65 | channel.send({ 66 | embeds: [new EmbedBuilder().setAuthor({ name: "Wrong Key ALERT" }) 67 | .addFields( 68 | { name: 'License:', value: "```" + `${key}` + "```", inline: false }, 69 | { name: 'Discord:', value: "```" + interaction.member.user.username + "#" + interaction.member.user.discriminator + "```", inline: true }, 70 | { name: 'DiscordID:', value: "```" + interaction.member.user.id + "```", inline: true }, 71 | ) 72 | 73 | 74 | .setColor(Colors.Red).setFooter({ text: "KeyAuth Redeem Bot v5.2.2" })] 75 | }); 76 | } 77 | } 78 | } 79 | 80 | async function giveroletouser() { 81 | let role = interaction.member.guild.roles.cache.find(r => r.id === client.customer_id); 82 | 83 | /* Another Role? 84 | let role2 = interaction.member.guild.roles.cache.find(r => r.id === "ROLEID"); If you want to add other role 85 | await interaction.guild.members.cache.get(interaction.member.id).roles.add(role2); 86 | */ 87 | 88 | if (role) { 89 | //GIVE ROLE 90 | try { 91 | await interaction.guild.members.cache.get(interaction.member.id).roles.add(role); 92 | } catch (err) { 93 | console.log(err); 94 | } 95 | 96 | if(client.use_once) { 97 | db.fetch(`${key}`) 98 | db.set(`${key}`, '1') 99 | } 100 | 101 | //REPLY 102 | interaction.editReply({ 103 | embeds: [new EmbedBuilder().setTitle("License Successfully Redeemed!").setColor(Colors.Red)], 104 | ephemeral: true, 105 | }) 106 | 107 | //Logs 108 | const channel = interaction.guild.channels.cache.find(channel => channel.name === 'prebeta-logs'); 109 | 110 | if (channel) { 111 | channel.send({ 112 | embeds: [new EmbedBuilder().setAuthor({ name: "License Redeemed!" }) 113 | .addFields( 114 | { name: 'License:', value: "```" + `${key}` + "```", inline: false }, 115 | { name: 'Discord:', value: "```" + interaction.member.user.username + "#" + interaction.member.user.discriminator + "```", inline: true }, 116 | { name: 'DiscordID:', value: "```" + interaction.member.user.id + "```", inline: true }, 117 | ) 118 | 119 | 120 | .setColor(Colors.Green).setFooter({ text: "KeyAuth Redeem Bot v1.6.2" })], 121 | ephemeral: true, 122 | }); 123 | } 124 | } 125 | 126 | return false; 127 | } 128 | 129 | fetch(`https://keyauth.` + client.domain + `/api/seller/?sellerkey=${sellerkey}&type=verify&key=${key}`) 130 | .then(checkResponseStatus); 131 | }, 132 | }; -------------------------------------------------------------------------------- /src/commands/rlogs.js: -------------------------------------------------------------------------------- 1 | const { SlashCommandBuilder, EmbedBuilder, Colors, PermissionsBitField, ChannelType } = require("discord.js"); 2 | 3 | module.exports = { 4 | data: new SlashCommandBuilder() 5 | .setName("rlogs") 6 | .setDescription("Enable logging for KeyAuth Redeem Bot"), 7 | 8 | async execute(interaction, client) { 9 | 10 | await interaction.deferReply({ ephemeral: true }); 11 | 12 | const channel = await interaction.guild.channels.cache.find(channel => channel.name === 'prebeta-logs'); 13 | if (channel) { 14 | console.log(`[RLOGS] ${interaction.member.user.id} tryed to create Logging channel, but it already exists.`); 15 | 16 | const embed = new EmbedBuilder() 17 | .setDescription(`<@${interaction.member.user.id}>, ${channel} **Already Exists.** \n\n**If you don't want to log anymore just delete: ** ${channel}.`); 18 | 19 | interaction.editReply({ 20 | embeds: [embed], 21 | ephemeral: true, 22 | }) 23 | 24 | return false; 25 | } else { 26 | if (isEmpty(client.admin_role_id)) { 27 | interaction.editReply({ 28 | embeds: [new EmbedBuilder().setDescription(`**Admin role haven't been set up yet, Go to** **index.js** **and Set it up.**`).setColor(Colors.Red).setFooter({ text: "KeyAuth Redeem Bot v5.2.2" })], 29 | ephemeral: true, 30 | }) 31 | return false; 32 | } 33 | console.log("[RLOGS] Creating Logging Channel..."); 34 | 35 | 36 | await interaction.guild.channels.create({ 37 | name: 'PreBeta-Logs', 38 | type: ChannelType.GuildText, 39 | permissionOverwrites: [ 40 | { 41 | id: client.admin_role_id, 42 | allow: [PermissionsBitField.Flags.ViewChannel], 43 | }, 44 | { 45 | id: interaction.user.id, 46 | deny: [PermissionsBitField.Flags.ViewChannel], 47 | }, 48 | ], 49 | }); 50 | 51 | interaction.editReply({ 52 | embeds: [new EmbedBuilder().setDescription(`**Okay, now the channel is created :) for <@&${client.admin_role_id}>**`).setColor(Colors.Red).setFooter({ text: "KeyAuth Redeem Bot v5.2.2" })], 53 | ephemeral: true, 54 | }); 55 | } 56 | }, 57 | }; 58 | 59 | function isEmpty(str) { 60 | return (!str || str.length === 0); 61 | } -------------------------------------------------------------------------------- /src/commands/ruser.js: -------------------------------------------------------------------------------- 1 | const { SlashCommandBuilder, EmbedBuilder, Colors } = require("discord.js"); 2 | const fetch = require('node-fetch') 3 | const db = require('quick.db'); 4 | 5 | var sendOnDMS = false; // Change this to true, if you want that the redeemed account details will be send on DMS 6 | 7 | module.exports = { 8 | data: new SlashCommandBuilder() 9 | .setName("ruser") 10 | .setDescription("Redeem User + Pass from license") 11 | .addStringOption((option) => 12 | option 13 | .setName("license") 14 | .setDescription("Your license key that you wan't to redeem.") 15 | .setRequired(true) 16 | ) 17 | .addStringOption((option) => 18 | option 19 | .setName("username") 20 | .setDescription("Choose your own username if you don't want random one") 21 | .setRequired(false) 22 | ) 23 | .addStringOption((option) => 24 | option 25 | .setName("password") 26 | .setDescription("Choose your own password if you don't want random one") 27 | .setRequired(false) 28 | ), 29 | 30 | async execute(interaction, client) { 31 | let sellerkey = await db.get(`token_${interaction.guild.id}`) 32 | if (sellerkey === null) return interaction.reply({ embeds: [new EmbedBuilder().setDescription(`Seller key haven't been setupped!`).setColor(Colors.Red).setTimestamp()], ephemeral: true, }); 33 | 34 | let key = await interaction.options.getString("license") 35 | let username = await interaction.options.getString('username'); 36 | let password = await interaction.options.getString('password'); 37 | 38 | if (isEmpty(username)) { 39 | username = await generaterandomname(10); 40 | }; 41 | 42 | if (isEmpty(password)) { 43 | password = await generate(); 44 | }; 45 | 46 | let un = username; 47 | let pw = password; 48 | 49 | await interaction.deferReply({ ephemeral: true }); 50 | 51 | interaction.editReply({ 52 | embeds: [new EmbedBuilder().setAuthor({ name: `Redeeming your account...` }).setColor(Colors.Gold)], 53 | ephemeral: true, 54 | }); 55 | 56 | function checkResponseStatus(res) { 57 | if (res.ok) { 58 | genaccforlicense(interaction); 59 | } else { 60 | const channel = interaction.guild.channels.cache.find(channel => channel.name === 'prebeta-logs'); 61 | 62 | interaction.editReply({ 63 | embeds: [new EmbedBuilder().setTitle('License Key Not Found').setColor(Colors.Red)], 64 | ephemeral: true, 65 | }); 66 | 67 | if (channel) { 68 | channel.send({ 69 | embeds: [new EmbedBuilder().setAuthor({ name: "Wrong Key ALERT" }) 70 | .addFields( 71 | { name: 'License:', value: "```" + `${key}` + "```", inline: false }, 72 | { name: 'Discord:', value: "```" + interaction.member.user.username + "```", inline: true }, 73 | { name: 'DiscordID:', value: "```" + interaction.member.user.id + "```", inline: true } 74 | ) 75 | .setColor(Colors.Red).setFooter({ text: "KeyAuth Redeem Bot v5.2.2" }).setTimestamp()] 76 | }); 77 | } 78 | } 79 | } 80 | 81 | async function genaccforlicense(interaction) { 82 | fetch(`https://keyauth.` + client.domain + `/api/seller/?sellerkey=${sellerkey}&type=activate&user=${un}&key=${key}&pass=${pw}&format=json`) 83 | .then(res => res.json()) 84 | .then(json => { 85 | if (json.success) { 86 | 87 | const FirstSub = json.info.subscriptions.subscriptions[0]; 88 | const DaysFromLicense = prettySeconds(FirstSub.timeleft); 89 | const SubName = FirstSub.subscription; 90 | 91 | fetch(`https://keyauth.` + client.domain + `/api/seller/?sellerkey=${sellerkey}&type=deluser&user=${un}`).then(res => res.json()) 92 | .then(json => { 93 | if (json.success) { 94 | fetch(`https://keyauth.` + client.domain + `/api/seller/?sellerkey=${sellerkey}&type=adduser&user=${un}&sub=${SubName}&expiry=${DaysFromLicense}&pass=${pw}`) 95 | .then(res => res.json()).then(json => { 96 | if (json.success) { 97 | 98 | 99 | //* Logging 100 | const channel = interaction.guild.channels.cache.find(channel => channel.name === 'prebeta-logs'); 101 | if (channel) { 102 | channel.send({ 103 | embeds: [new EmbedBuilder() 104 | .setAuthor({ name: "License Redeemed" }) 105 | .addFields( 106 | { 107 | name: 'License', 108 | value: "```" + `${key}` + "```", 109 | inline: false 110 | }, 111 | { 112 | name: 'Username', 113 | value: "```" + un + "```", 114 | inline: false 115 | }, 116 | { 117 | name: 'Password', 118 | value: "```" + pw + "```", 119 | inline: false 120 | }, 121 | { 122 | name: 'Discord', 123 | value: "```" + interaction.member.user.username + "```", 124 | inline: true 125 | }, 126 | { 127 | name: 'DiscordID', 128 | value: "```" + interaction.member.user.id + "```", 129 | inline: true 130 | } 131 | ) 132 | .setColor(Colors.Green).setFooter({ text: "KeyAuth Redeem Bot v5.2.2" }).setTimestamp()] 133 | }); 134 | } 135 | 136 | if (sendOnDMS) { 137 | interaction.editReply({ 138 | embeds: [new EmbedBuilder().setTitle('License Have been redeemed, please check your dms').setColor(Colors.Red)], 139 | }); 140 | 141 | interaction.member.send({ 142 | embeds: [new EmbedBuilder().setTitle('License Successfully Activated!').setFooter({ text: "KeyAuth Redeem Bot v5.2.2" }) 143 | .addFields( 144 | { 145 | name: 'License', 146 | value: "```" + `${key}` + "```", 147 | inline: false 148 | }, 149 | { 150 | name: 'Username', 151 | value: "```" + un + "```", 152 | inline: false 153 | }, 154 | { 155 | name: 'Expiry', 156 | value: "```" + DaysFromLicense + " Days```", 157 | inline: false 158 | }, 159 | { 160 | name: 'Password', 161 | value: "```" + pw + "```", 162 | inline: false 163 | } 164 | ) 165 | 166 | .setColor(Colors.Green).setTimestamp()], 167 | ephemeral: true, 168 | }).catch(error => { 169 | if (error.code === 50007) { 170 | interaction.editReply({ 171 | embeds: [new EmbedBuilder().setAuthor({ name: "DMS Closed so i will give here. " }).setTitle('License Successfully Activated!') 172 | .setFooter({ text: "KeyAuth Redeem Bot v5.2.2" }) 173 | .addFields( 174 | { 175 | name: 'License', 176 | value: "```" + `${key}` + "```", 177 | inline: false 178 | }, 179 | { 180 | name: 'Username', 181 | value: "```" + un + "```", 182 | inline: false 183 | }, 184 | { 185 | name: 'License', 186 | value: "```" + `${key}` + "```", 187 | inline: false 188 | }, 189 | { 190 | name: 'Password', 191 | value: "```" + pw + "```", 192 | inline: false 193 | } 194 | 195 | ) 196 | 197 | 198 | 199 | .setColor(Colors.Green).setTimestamp()], 200 | ephemeral: true, 201 | }); 202 | } 203 | }); 204 | } else { 205 | interaction.editReply({ 206 | embeds: [new EmbedBuilder().setTitle('License Successfully Activated!').setFooter({ text: "KeyAuth Redeem Bot v5.2.2" }) 207 | .addFields( 208 | { name: 'Username', value: "```" + un + "```", inline: false }, 209 | { name: 'Password', value: "```" + pw + "```", inline: false }, 210 | { name: 'License', value: "```" + `${key}` + "```", inline: false }, 211 | { name: 'Expiry', value: "```" + DaysFromLicense + " Days```", inline: false } 212 | ) 213 | 214 | 215 | 216 | .setColor(Colors.Green).setTimestamp()], 217 | ephemeral: true, 218 | }); 219 | } 220 | 221 | disableoldlicense(); 222 | } else { 223 | interaction.editReply({ 224 | embeds: [new EmbedBuilder().setTitle(json.message).setColor(Colors.Red)], 225 | ephemeral: true, 226 | }); 227 | } 228 | }); 229 | } else { 230 | interaction.editReply({ 231 | embeds: [new EmbedBuilder().setTitle('Something went wrong').setColor(Colors.Red)], 232 | ephemeral: true, 233 | }); 234 | } 235 | }); 236 | } else { 237 | interaction.editReply({ 238 | embeds: [new EmbedBuilder().setTitle(json.message).setColor(Colors.Red)], 239 | ephemeral: true 240 | }); 241 | return false; 242 | } 243 | }) 244 | } 245 | 246 | function disableoldlicense() { 247 | fetch(`https://keyauth.` + client.domain + `/api/seller/?sellerkey=${sellerkey}&type=del&key=${key}`); 248 | } 249 | 250 | fetch(`https://keyauth.` + client.domain + `/api/seller/?sellerkey=${sellerkey}&type=verify&key=${key}`) 251 | .then(checkResponseStatus); 252 | }, 253 | }; 254 | 255 | //* Check if string / variable is empty or null 256 | function isEmpty(str) { 257 | return (!str || str.length === 0); 258 | } 259 | 260 | //* Seconds to Days - original: https://www.npmjs.com/package/pretty-seconds 261 | function prettySeconds(seconds) { 262 | let prettyString = '' 263 | let data = [] 264 | 265 | if (typeof seconds === 'number') { 266 | data = quantify(data, 'day', parseInt(fix10(seconds / 86400))) 267 | 268 | prettyString = data; 269 | } 270 | 271 | return prettyString; 272 | } 273 | 274 | function fix10(number) { 275 | return number.toFixed(10) 276 | } 277 | 278 | function quantify(data, unit, value, allowZero) { 279 | if (value || (allowZero && !value)) { 280 | if (value > 1 || value < -1 || value === 0) { 281 | unit += 's' 282 | } 283 | 284 | data.push(value) 285 | } 286 | 287 | return data 288 | } 289 | 290 | 291 | //* Username + Password Generators 292 | async function generate(count = 8) { 293 | let password = '' 294 | while (password.length < count) { 295 | password += Math.random().toString(36).substr(2) 296 | } 297 | return password.substr(0, count) 298 | } 299 | 300 | async function generaterandomname(length) { 301 | var randomChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; 302 | var result = ''; 303 | for (var i = 0; i < length; i++) { 304 | result += randomChars.charAt(Math.floor(Math.random() * randomChars.length)); 305 | } 306 | return result; 307 | } 308 | 309 | async function sleep(ms) { 310 | return new Promise((resolve) => { 311 | setTimeout(resolve, ms); 312 | }); 313 | } -------------------------------------------------------------------------------- /src/commands/setseller.js: -------------------------------------------------------------------------------- 1 | const { SlashCommandBuilder, EmbedBuilder, Colors } = require("discord.js"); 2 | const db = require('quick.db') 3 | const fetch = require('node-fetch') 4 | 5 | module.exports = { 6 | data: new SlashCommandBuilder() 7 | .setName("setseller") 8 | .setDescription("Set up the sellerkey for bot.") 9 | .addStringOption((option) => 10 | option 11 | .setName("sellerkey") 12 | .setDescription("Specify application seller key") 13 | .setRequired(true) 14 | ), 15 | async execute(interaction, client) { 16 | 17 | let sellerkey = await interaction.options.getString("sellerkey") 18 | 19 | await interaction.deferReply({ ephemeral: true }); 20 | 21 | fetch(`https://keyauth.` + client.domain + `/api/seller/?sellerkey=${sellerkey}&type=setseller&format=text`) 22 | .then(res => res.text()) 23 | .then(text => { 24 | if (text == "Seller Key Successfully Found") { 25 | db.fetch(`token_${interaction.guild.id}`) 26 | db.set(`token_${interaction.guild.id}`, sellerkey) 27 | interaction.editReply({ embeds: [new EmbedBuilder().setTitle('Seller Key Successfully Set!').setColor(Colors.Green)], ephemeral: true }) 28 | } 29 | else { 30 | interaction.editReply({ embeds: [new EmbedBuilder().setTitle('Seller Key Not Found!') 31 | .addFields( 32 | { name: 'Where do I find seller key?', value: "In [Seller Settings](https://keyauth.win/dashboard/seller/settings/)", inline: false } 33 | ) 34 | .setColor(Colors.Red)], ephemeral: true }) 35 | } 36 | }) 37 | }, 38 | }; -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | const { REST, Client, GatewayIntentBits, ActivityType, Collection, EmbedBuilder, Routes, Partials, Colors, Events } = require("discord.js"); 3 | 4 | /// Discord Client Configuration /// 5 | const client = new Client({ 6 | intents: [ 7 | GatewayIntentBits.Guilds 8 | ], 9 | partials: [Partials.Channel] 10 | }) 11 | 12 | 13 | /// Discord Token and Server - Guild ID /// 14 | let conf = { 15 | token: "", // Discord Bot Token (https://discord.com/developers/applications/) 16 | GuildID: "", // GuildID Where Bot will put commands. 17 | } 18 | 19 | 20 | /// Client Setup /// 21 | client.domain = "win"; // KeyAuth Domain [win Currently] 22 | client.customer_id = ""; // What user get when /redeem have been used visit redeem.js if you want to add more roles. 23 | client.admin_role_id = ""; // Admin Role id to /rlogs + to access logs channel. 24 | client.use_once = true; // only allow members to use a license key once. set to false if you'd like people to be able to use multiple times 25 | 26 | 27 | const commandFiles = fs.readdirSync("./commands").filter(file => file.endsWith(".js")) 28 | const commands = []; 29 | 30 | client.commands = new Collection(); 31 | 32 | for (const file of commandFiles) { 33 | const command = require(`./commands/${file}`); 34 | commands.push(command.data.toJSON()); 35 | client.commands.set(command.data.name, command) 36 | } 37 | 38 | client.on("error", console.error); 39 | 40 | client.once('ready', async () => { 41 | console.clear(); 42 | await protyperxdd(logo(), 0); 43 | sysTitle("KeyAuth Redeem Bot - Started | https://github.com/mazkdevf"); 44 | console.log(`\x1b[33m[discord.js] \x1b[0mBot Started - ${client.user.tag}`) 45 | 46 | const CLIENT_ID = client.user.id; 47 | 48 | const rest = new REST({}).setToken(conf.token); 49 | 50 | (async () => { 51 | try { 52 | await rest.put(Routes.applicationGuildCommands(CLIENT_ID, conf.GuildID), { 53 | body: commands 54 | }) 55 | console.log(`\x1b[32m[CMDS] \x1b[0mCommands have been setup for GuildID: ${conf.GuildID}`) 56 | } catch (err) { 57 | console.error(err); 58 | } 59 | })(); 60 | 61 | client.user.setPresence({ 62 | activities: [ 63 | { 64 | name: "KeyAuth Redeem Bot - github.com/mazkdevf", 65 | type: ActivityType.COMPETING, 66 | } 67 | ], 68 | }) 69 | 70 | }); 71 | 72 | client.on(Events.InteractionCreate, async interaction => { 73 | if (!interaction.type === 2) return; 74 | 75 | const command = client.commands.get(interaction.commandName); 76 | 77 | if (!command) return; 78 | 79 | const ErrorEmbed = new EmbedBuilder() 80 | .setAuthor({ name: "Interaction Failed" }) 81 | .setColor(Colors.Red) 82 | .setFooter({ text: "KeyAuth Redeem Bot v5.2.2" }) 83 | 84 | client.user.setPresence({ 85 | activities: [ 86 | { 87 | name: "KeyAuth Redeem Bot - github.com/mazkdevf", 88 | type: ActivityType.COMPETING, 89 | } 90 | ], 91 | }) 92 | 93 | try { 94 | await command.execute(interaction, client); 95 | } catch (err) { 96 | if (err) console.error(err); 97 | 98 | await interaction.editReply({ 99 | embeds: [ErrorEmbed], 100 | ephemeral: true 101 | }) 102 | } 103 | }); 104 | 105 | function logo() { 106 | var lol = ` 107 | \x1b[37m::: === :::===== \x1b[34m::: === \x1b[37m:::==== ::: === :::==== ::: === :::==== :::==== 108 | \x1b[37m::: === ::: \x1b[34m::: === \x1b[37m::: === ::: === :::==== ::: === ::: === ::: === 109 | \x1b[34m====== ====== ===== ======== === === === ======== ======= ======= 110 | \x1b[37m=== === === \x1b[34m === \x1b[37m=== === === === === === === === === === === 111 | \x1b[37m=== === ======== \x1b[34m === \x1b[37m=== === ====== === === === === === ======= 112 | \n\n`; 113 | return lol; 114 | } 115 | 116 | 117 | // Change Console Title 118 | function sysTitle(title) { 119 | process.stdout.write( 120 | String.fromCharCode(27) + "]0;" + title + String.fromCharCode(7) 121 | ); 122 | } 123 | 124 | // Sleep 125 | async function sleep(ms) { 126 | return new Promise((resolve) => { 127 | setTimeout(resolve, ms); 128 | }); 129 | } 130 | 131 | // Typerwriter 132 | async function protyperxdd(text, ms = 20) { 133 | for (const c of text) { 134 | process.stdout.write(c); 135 | await sleep(ms); 136 | } 137 | } 138 | 139 | client.login(conf.token); 140 | 141 | 142 | -------------------------------------------------------------------------------- /src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "keyauth-redeem-bot", 3 | "version": "5.2.2", 4 | "description": "KeyAuth Redeem Bot v5.2.2", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "/help" 8 | }, 9 | "author": "KeyAuth - mazkdevf ", 10 | "license": "ISC", 11 | "keywords": [ 12 | "discordjs", 13 | "v14", 14 | "keyauth" 15 | ], 16 | "dependencies": { 17 | "discord.js": "^14.9.0", 18 | "fs": "^0.0.1-security", 19 | "node-fetch": "^2.6.7", 20 | "quick.db": "^7.1.3" 21 | } 22 | } 23 | --------------------------------------------------------------------------------