Simplification of button time out code.

master
masterhc 1 year ago
parent 5486c91aca
commit 98f806d280

@ -54,7 +54,7 @@ module.exports = class leave extends Command
}); });
collector.on('end', async ()=> collector.on('end', async ()=>
{ {
this.client.guilds.cache.get(Message.guildId).channels.cache.get(Message.channelId).messages.cache.get(Message.id).edit({ components: [] }); Message.edit({ components: [] });
}) })
} }
} }

@ -62,7 +62,7 @@ const {EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelType,
collector.on('end', async ()=> collector.on('end', async ()=>
{ {
this.client.guilds.cache.get(Message.guildId).channels.cache.get(Message.channelId).messages.cache.get(Message.id).edit({ components: [] }); Message.edit({ components: [] });
}) })
} }
} }

@ -79,7 +79,7 @@ const {EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelType,
}); });
collector.on('end', async ()=> collector.on('end', async ()=>
{ {
this.client.guilds.cache.get(Message.guildId).channels.cache.get(Message.channelId).messages.cache.get(Message.id).edit({ components: [] }); Message.edit({ components: [] });
}) })
} }
} }

@ -54,7 +54,7 @@ class Guilds extends Command
}); });
collector.on('end', async ()=> collector.on('end', async ()=>
{ {
this.client.guilds.cache.get(Message.guildId).channels.cache.get(Message.channelId).messages.cache.get(Message.id).edit({ components: [] }); Message.edit({ components: [] });
}) })
} }

@ -78,7 +78,7 @@ const {Command} = require('../../lib.js')
}); });
collector.on('end', async ()=> collector.on('end', async ()=>
{ {
this.client.guilds.cache.get(Message.guildId).channels.cache.get(Message.channelId).messages.cache.get(Message.id).edit({ components: [] }); Message.edit({ components: [] });
}) })
} }
}module.exports = purge; }module.exports = purge;

@ -69,7 +69,7 @@ const {Command, } = require('../../lib.js');
}); });
collector.on('end', async ()=> collector.on('end', async ()=>
{ {
this.client.guilds.cache.get(Message.guildId).channels.cache.get(Message.channelId).messages.cache.get(Message.id).edit({ components: [] }); Message.edit({ components: [] });
}) })
} }

@ -73,7 +73,7 @@ class setfreegameschannel extends Command{
}); });
collector.on('end', async ()=> collector.on('end', async ()=>
{ {
this.client.guilds.cache.get(Message.guildId).channels.cache.get(Message.channelId).messages.cache.get(Message.id).edit({ components: [] }); Message.edit({ components: [] });
}) })
} }
function addChannel(id, name) function addChannel(id, name)

@ -39,7 +39,7 @@ class setrustcommitschannel extends Command{
); );
const filter = i => i.customId === 'RemoveRustCommitsNewChannelMessage'; const filter = i => i.customId === 'RemoveRustCommitsNewChannelMessage';
const Mesage = await message.channel.send({ephemeral: true, embeds: [embed], components: [row] }); const Message = await message.channel.send({ephemeral: true, embeds: [embed], components: [row] });
const collector = message.channel.createMessageComponentCollector({ filter, time: 60000 }); const collector = message.channel.createMessageComponentCollector({ filter, time: 60000 });
collector.on('collect', async m => collector.on('collect', async m =>
{ {
@ -48,7 +48,7 @@ class setrustcommitschannel extends Command{
}); });
collector.on('end', async ()=> collector.on('end', async ()=>
{ {
this.client.guilds.cache.get(Message.guildId).channels.cache.get(Message.channelId).messages.cache.get(Message.id).edit({ components: [] }); Message.edit({ components: [] });
}) })
} }
function addChannel(id, name) function addChannel(id, name)

@ -71,7 +71,7 @@ const strikeM = require('../../models/strikes');
}); });
collector.on('end', async ()=> collector.on('end', async ()=>
{ {
this.client.guilds.cache.get(Message.guildId).channels.cache.get(Message.channelId).messages.cache.get(Message.id).edit({ components: [] }); Message.edit({ components: [] });
}) })
} }
async confirmArgs(message,args) async confirmArgs(message,args)

@ -55,7 +55,7 @@ module.exports = class leave extends Command
}); });
collector.on('end', async ()=> collector.on('end', async ()=>
{ {
this.client.guilds.cache.get(Message.guildId).channels.cache.get(Message.channelId).messages.cache.get(Message.id).edit({ components: [] }); Message.edit({ components: [] });
}) })
} }
} }

@ -129,7 +129,7 @@ module.exports = class play extends Command
}); });
collector.on('end', async ()=> collector.on('end', async ()=>
{ {
this.client.guilds.cache.get(Message.guildId).channels.cache.get(Message.channelId).messages.cache.get(Message.id).edit({ components: [] }); Message.edit({ components: [] });
}) })
} }
} }

@ -56,16 +56,16 @@ class anime extends Command{
{ {
message.delete(); message.delete();
m.message.delete(); m.message.delete();
if(m.customId[m.customId.length-1]!=4) sendMessage(data[m.customId[m.customId.length-1]].id, this.client); if(m.customId[m.customId.length-1]!=4) sendMessage(data[m.customId[m.customId.length-1]].id);
}); });
collector.on('end', async ()=> collector.on('end', async ()=>
{ {
this.client.guilds.cache.get(Message.guildId).channels.cache.get(Message.channelId).messages.cache.get(Message.id).edit({ components: [] }); Message.edit({components:[]})
}) })
/** /**
* @param {Number} id * @param {Number} id
*/ */
async function sendMessage(id, client) async function sendMessage(id)
{ {
const data = await new Anilist().getAnimeInfo(id); const data = await new Anilist().getAnimeInfo(id);
// console.log('Command: SearchChar: SendMessage: Data', data) // console.log('Command: SearchChar: SendMessage: Data', data)
@ -104,7 +104,7 @@ class anime extends Command{
.setStyle(ButtonStyle.Primary), .setStyle(ButtonStyle.Primary),
); );
const filter = i => i.customId === randomID; const filter = i => i.customId === randomID;
await message.channel.send({ephemeral: true, embeds: [embed], components: [row] }); const sentMessage = await message.channel.send({ephemeral: true, embeds: [embed], components: [row] });
const collector = message.channel.createMessageComponentCollector({ filter, time: 60000 }); const collector = message.channel.createMessageComponentCollector({ filter, time: 60000 });
collector.on('collect', async m => collector.on('collect', async m =>
{ {
@ -112,7 +112,7 @@ class anime extends Command{
}); });
collector.on('end', async ()=> collector.on('end', async ()=>
{ {
client.guilds.cache.get(sentMessage.guildId).channels.cache.get(sentMessage.channelId).messages.cache.get(sentMessage.id).edit({ components: [] }); sentMessage.edit({components:[]})
}) })
} }
} }

@ -51,22 +51,22 @@ class char extends Command{
// console.log(data.length, embeds.length, embeds) // console.log(data.length, embeds.length, embeds)
const filter = i => i.customId.slice(0,-1) === randomID; const filter = i => i.customId.slice(0,-1) === randomID;
const sentMessage = await message.channel.send({ephemeral: true, embeds, components: [row] }); const Message = await message.channel.send({ephemeral: true, embeds, components: [row] });
const collector = message.channel.createMessageComponentCollector({ filter, time: 60000 }); const collector = message.channel.createMessageComponentCollector({ filter, time: 60000 });
collector.on('collect', async m => collector.on('collect', async m =>
{ {
message.delete(); message.delete();
m.message.delete(); m.message.delete();
if(m.customId[m.customId.length-1]!=4) sendMessage(data[m.customId[m.customId.length-1]].id, this.client); if(m.customId[m.customId.length-1]!=4) sendMessage(data[m.customId[m.customId.length-1]].id);
}); });
collector.on('end', async ()=> collector.on('end', async ()=>
{ {
this.client.guilds.cache.get(sentMessage.guildId).channels.cache.get(sentMessage.channelId).messages.cache.get(sentMessage.id).edit({ components: [] }); Message.edit({components:[]})
}) })
/** /**
* @param {Number} id * @param {Number} id
*/ */
async function sendMessage(id, client) async function sendMessage(id)
{ {
const data = await new Anilist().getCharInfo(id); const data = await new Anilist().getCharInfo(id);
data.description = data.description.replaceAll('~!', '').replaceAll('!~', '').replaceAll(/<[^>]*>/g, ''); data.description = data.description.replaceAll('~!', '').replaceAll('!~', '').replaceAll(/<[^>]*>/g, '');
@ -96,15 +96,15 @@ class char extends Command{
.setStyle(ButtonStyle.Primary), .setStyle(ButtonStyle.Primary),
); );
const filter = i => i.customId === randomID; const filter = i => i.customId === randomID;
await message.channel.send({ephemeral: true, embeds: [embed], components: [row] }); const sentMessage = await message.channel.send({ephemeral: true, embeds: [embed], components: [row] });
const collector = message.channel.createMessageComponentCollector({ filter, time: 60000 }); const collector = message.channel.createMessageComponentCollector({ filter, time: 6})//0000 });
collector.on('collect', async m => collector.on('collect', async m =>
{ {
m.message.delete(); m.message.delete();
}); });
collector.on('end', async ()=> collector.on('end', async ()=>
{ {
client.guilds.cache.get(sentMessage.guildId).channels.cache.get(sentMessage.channelId).messages.cache.get(sentMessage.id).edit({ components: [] }); sentMessage.edit({components:[]})
}) })
} }
} }

@ -58,16 +58,16 @@ class manga extends Command{
{ {
message.delete(); message.delete();
m.message.delete(); m.message.delete();
if(m.customId[m.customId.length-1]!=4) sendMessage(data[m.customId[m.customId.length-1]].id, this.client); if(m.customId[m.customId.length-1]!=4) sendMessage(data[m.customId[m.customId.length-1]].id);
}); });
collector.on('end', async ()=> collector.on('end', async ()=>
{ {
this.client.guilds.cache.get(Message.guildId).channels.cache.get(Message.channelId).messages.cache.get(Message.id).edit({ components: [] }); Message.edit({components:[]})
}) })
/** /**
* @param {Number} id * @param {Number} id
*/ */
async function sendMessage(id, client) async function sendMessage(id)
{ {
const data = await new Anilist().getMangaInfo(id); const data = await new Anilist().getMangaInfo(id);
data.description = data.description.replaceAll('~!', '').replaceAll('!~', '').replaceAll(/<[^>]*>/g, ''); data.description = data.description.replaceAll('~!', '').replaceAll('!~', '').replaceAll(/<[^>]*>/g, '');
@ -100,7 +100,7 @@ class manga extends Command{
}); });
collector.on('end', async ()=> collector.on('end', async ()=>
{ {
client.guilds.cache.get(sentMessage.guildId).channels.cache.get(sentMessage.channelId).messages.cache.get(sentMessage.id).edit({ components: [] }); sentMessage.edit({components:[]})
}) })
} }
} }

@ -528,7 +528,7 @@ class ErrorMessage
}); });
collector.on('end', async ()=> collector.on('end', async ()=>
{ {
this.client.guilds.cache.get(Message.guildId).channels.cache.get(Message.channelId).messages.cache.get(Message.id).edit({ components: [] }); Message.edit({ components: [] });
}) })
} }

Loading…
Cancel
Save