TEXT   31
Untitled
Guest on 15th March 2023 04:47:38 AM


  1.  
  2.               const { Client, CommandInteraction } = require("discord.js");
  3. const { MessageEmbed } = require("discord.js");
  4. const { QuickDB } = require ('quick.db');
  5. const db = new QuickDB({ filePath:
  6. './allowedrank.sqlite' });
  7. const noblox = require('noblox.js');
  8. module.exports = {
  9.     name: "promote",
  10.     description: "promote a user",
  11.     userPermissions: "",
  12.             options: [{
  13.                 name: "username",
  14.                 type: 3,
  15.                 required: true,
  16.                 description: "Roblox Username"
  17.             },{
  18.                 name: "groupid",
  19.                 type: 4,
  20.                 required: true,
  21.                 description: "Roblox group id"
  22.             }],
  23.     /**
  24.      *
  25.      * @param {Client} client
  26.      * @param {CommandInteraction} interaction
  27.      * @param {String[]} args
  28.      */
  29.     run: async (client, interaction, args) => {
  30.      
  31. //const allowedRank = db.get("allowedRank", role.id)
  32. // if (!allowedRank) {
  33.      //interaction.reply({content: "You don't have access to use this command", ephemeral: true})
  34. // }
  35.  
  36.     const robloxUsername = interaction.options.getString('username');
  37.     const robloxGroupId = interaction.options.getInteger('groupid'); // Does this need to be a prompt, or can it just be a fixed environment variable?
  38.     try {
  39.       // Convert the username to a Roblox ID
  40.       const robloxUserId = await noblox.getIdFromUsername(robloxUsername)
  41.       // Promote the user to the next-ranked role
  42.       const { _, newRole } = await noblox.promote(robloxGroupId, robloxUserId)
  43.       // Send a comfirmation message
  44.       const Embed = new MessageEmbed()
  45.       .setTitle("Promotion Command")
  46.       .setDescription(`${robloxUsername} [${robloxUserId}] has been promoted to rank ${newRole.name}.`)
  47.       .setColor("GREEN");
  48.      
  49.         await interaction.reply({embeds: [Embed], ephemeral: false})
  50.            
  51.     } catch (err) {
  52.       console.error(err)
  53.  
  54.         const Embed2 = new MessageEmbed()
  55.       .setTitle("Promotion Command")
  56.       .setDescription("Unable to process the request at this time.")
  57.       .setColor("RED");
  58.        
  59.         await interaction.reply({embeds: [Embed2], ephemeral: true})
  60.  

Raw Paste

Login or Register to edit or fork this paste. It's free.