const {Command, Random} = require('../../lib.js'); const {EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle} = require('discord.js'); const guildsM = require('../../models/guilds.js'); module.exports = class leave extends Command { constructor(client) { super(client, { name: 'activateMusic', group:'admin', aliases: ['music','amusic'], description: 'Activates music for the guild. Can be called again to disable.', needsAdmin:true, hidden:true }) } async run(message, args) { const Author = message.author const guild = message.guild.id guildsM.findOne({gID:guild}).then(g=> { g.music =!g.music; guildsM.updateOne({gID:guild}, g,{upsert:true}).then(updatedG=> { sendMessage(g.music); }) }) async function sendMessage(active){ console.log(active?'Activate Music: -':'Disable Music: -', Author.username, 'on guild:', guild); const randomID = Random() const embed = new EmbedBuilder() .setColor(0xd31f1f) .setTitle(active?'Music activated!':'Music disabled!') .setAuthor( {name:"Rem-chan", iconURL:"https://i.imgur.com/g6FSNhL.png"}) .setFooter({text:'Rem-chan on ', iconURL:"https://i.imgur.com/g6FSNhL.png"}) .setTimestamp() const row = new ActionRowBuilder() .addComponents( new ButtonBuilder() .setCustomId(randomID) .setLabel('Remove this.') .setStyle(ButtonStyle.Primary), ); const Message = await message.channel.send({ephemeral: true, embeds: [embed], components: [row] }); const filter = i => i.customId === randomID; const collector = message.channel.createMessageComponentCollector({ filter, time: 60000 }); collector.on('collect', async m => { collector.stop(); message.delete(); m.message.delete(); }); collector.on('end', async ()=> { Message.edit({ components: [] }); }) } } }