You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
2.2 KiB

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:'music',
aliases: ['music','amusic'],
description: 'Activates music for the guild. Can be called again to disable.',
needsAdmin: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),
);
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 =>
{
message.delete();
m.message.delete();
});
}
}
}