AtomicNyte

Buttons

May 8th, 2022
1,094
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //interactionCreate.js
  2. module.exports = (Discord, libitina) => {
  3.     libitina.on('interactionCreate', interaction => {
  4.         if (!interaction.isButton()) return;
  5.  
  6.         const approval = require('../../approval');
  7.         const approved = require('../../approved');
  8.         const denied = require('../../denied');
  9.  
  10.         const modsChat = interaction.member.guild.channels.cache.get('957493730598879372');
  11.         const role = interaction.member.guild.roles.cache.find(role => role.name === "✅Verified 18+");
  12.  
  13.         console.log(interaction);
  14.  
  15.         if (interaction.channelId === '957493729101488152') return  approval(interaction, modsChat, role);
  16.        
  17.         if (interaction.channelId === modsChat.id){
  18.             const newUserId = interaction.message.mentions.users.first().id
  19.             if(interaction.customId === "approved") return  approved(interaction, modsChat, role, newUserId);
  20.             if(interaction.customId === "deny") return  denied(interaction, modsChat, role, newUserId);
  21.         }
  22.     });    
  23. }
  24.  
  25.  
  26.  
  27.  
  28. //approval.js
  29. module.exports = async (interaction, modsChat, role) => {
  30.     const  { MessageActionRow, MessageButton } = require('discord.js');
  31.    
  32.     if(interaction.customId === "yes"){
  33.         const row = new MessageActionRow()
  34.             .addComponents(
  35.           new MessageButton()
  36.             .setCustomId('approved')
  37.             .setLabel('Approve')
  38.             .setStyle('SUCCESS'),
  39.           new MessageButton()
  40.             .setCustomId('deny')
  41.             .setLabel('Deny')
  42.             .setStyle('DANGER')
  43.             );        
  44.             modsChat.send({content: `<@${interaction.user.id}> wants the ${role} role!`, components: [row] });
  45.             await interaction.reply({ content: 'Your application has been sent to the server moderators. Please allow them 24 hours to review your application.', ephemeral: true,});
  46.         }
  47.         else if(interaction.customId === "no") {
  48.           modsChat.send(`<@${interaction.user.id}> selected "No!", they are not over the age of 18.`) ;
  49.           await interaction.reply({ content: 'Sorry, we require all members of the servr to be over the age of 18.', ephemeral: true,});
  50.         }
  51. }
  52.  
  53.  
  54.  
  55.  
  56. //approved.js
  57. module.exports = async (interaction, modsChat, role, newUserId) => {
  58.     interaction.member.roles.add(role);
  59.     modsChat.send(`<@${interaction.user.id}> granted <@${newUserId}> the ${role} role.`)
  60. }
  61.  
  62.  
  63.  
  64. //denied.js
  65. module.exports = async (interaction, modsChat, role, newUserId) => {
  66.     interaction.member.roles.remove(role)
  67.     modsChat.send(`<@${interaction.user.id}> denied <@${newUserId}> the ${role} role.`)
  68. }
  69.  
  70.  
  71.  
  72. //index.js
  73. ['command_handler', 'event_handler'].forEach(handler =>{
  74.     require(`./handlers/${handler}`)(libitina, Discord);
  75. });
Advertisement
Add Comment
Please, Sign In to add comment