parent
b02a6a46cb
commit
2c7e683636
@ -0,0 +1,66 @@
|
||||
const {Command, Random, ErrorMessage, ErrorType} = require('../../lib.js')
|
||||
const {EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle} = require('discord.js');
|
||||
const feedM = require('../../models/feeds');
|
||||
class setYTFeed extends Command{
|
||||
constructor(client){
|
||||
super(client, {
|
||||
name: 'resetFeed',
|
||||
aliases:['rsetFeed','rfeed'],
|
||||
description: 'Resets feed display on this channel. You can then set another feed or the same to use this channel.',
|
||||
needsAdmin:true,
|
||||
});
|
||||
this.client = client;
|
||||
}
|
||||
async run(message, args)
|
||||
{
|
||||
var channel;
|
||||
try {
|
||||
channel = await this.client.channels.fetch(args[0]);
|
||||
} catch (error) {
|
||||
return new ErrorMessage(this.client).send(ErrorType.Arguments, message, ['Channel does not exist.'])
|
||||
}
|
||||
var auxClient = this.client
|
||||
feedM.findOneAndDelete({ChannelId: args[0]}, function (err, feed)
|
||||
{
|
||||
if(err || !feed) return new ErrorMessage(auxClient).send(ErrorType.Arguments, message, ['There are no feeds displaying in this channel'])
|
||||
const embed = new EmbedBuilder()
|
||||
const randomID = Random();
|
||||
embed.setFooter({text:'Rem-chan on ', iconURL:"https://i.imgur.com/g6FSNhL.png"})
|
||||
embed.setAuthor({name:"Rem-chan", iconURL:"https://i.imgur.com/g6FSNhL.png",url:'https://rem.wordfights.com/addtodiscord'});
|
||||
embed.setColor(0x110809);
|
||||
embed.setTimestamp()
|
||||
embed.setTitle(`${channel.name} channel is now free to be used with a different feed.`)
|
||||
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId(randomID)
|
||||
.setLabel('Remove this.')
|
||||
.setStyle(ButtonStyle.Primary),
|
||||
);
|
||||
const filter = i => i.customId === randomID;
|
||||
message.channel.send({embeds: [embed], components: [row] });
|
||||
const collector = message.channel.createMessageComponentCollector({ filter, time: 60000 });
|
||||
collector.on('collect', async m =>
|
||||
{
|
||||
_delete(message, m);
|
||||
});
|
||||
collector.on('end', async m=>
|
||||
{
|
||||
_delete(message,m);
|
||||
})
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}module.exports = setYTFeed;
|
||||
|
||||
function _delete(message, m)
|
||||
{
|
||||
try {
|
||||
message.delete();
|
||||
m.message.delete();
|
||||
} catch (error) {
|
||||
console.log('SetYTID: Error deleting the message:',error)
|
||||
}
|
||||
}
|
Loading…
Reference in new issue