Skip to content

Commit

Permalink
fix: only use secondary buttons for messageinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-737 committed Sep 3, 2023
1 parent 88a46a1 commit 47f2fbc
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions src/Commands/Network/messageInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default {

if (!networkMessage) {
await interaction.reply({
content: 'This message has expired. If not, please wait a few seconds and try again.',
content: 'Information about this message is no longer available.',
ephemeral: true,
});
return;
Expand All @@ -45,7 +45,7 @@ export default {
**Sent In (Hub):**
__${networkMessage.hub?.name}__
**Sent At:**
**Message Created:**
<t:${Math.floor(target.createdTimestamp / 1000)}:R>
`)
.setColor('Random');
Expand All @@ -59,11 +59,11 @@ export default {
new ButtonBuilder()
.setCustomId('serverInfo')
.setLabel('Server Info')
.setStyle(ButtonStyle.Primary),
.setStyle(ButtonStyle.Secondary),
new ButtonBuilder()
.setCustomId('userInfo')
.setLabel('User Info')
.setStyle(ButtonStyle.Primary),
.setStyle(ButtonStyle.Secondary),
);

const replyMsg = await interaction.reply({
Expand All @@ -75,7 +75,7 @@ export default {
// create a variable to store the profile card buffer
let customCard: AttachmentBuilder | null = null;

const collector = replyMsg?.createMessageComponentCollector({ time: 30_000 });
const collector = replyMsg?.createMessageComponentCollector({ idle: 30_000 });
collector.on('collect', async i => {
if (i.customId === 'serverInfo') {
if (!server) {
Expand All @@ -96,7 +96,7 @@ export default {
${server.description || 'No Description.'}
**Name:**
${server?.name.substring(0, 256)}
${server?.name}
**Owner:**
__${owner.user.username}__${owner.user.discriminator !== '0' ? `#${owner.user.discriminator}` : ''} ${owner.user.bot ? '(Bot)' : ''}
Expand All @@ -111,19 +111,23 @@ export default {
__${guildSetup?.invite ? `[\`${guildSetup.invite}\`](https://discord.gg/${guildSetup.invite})` : 'Not Set.'}__`)
.setFooter({ text: `ID: ${server.id}` });

const components: ActionRowBuilder<ButtonBuilder>[] = [];
const newButtons = ActionRowBuilder.from<ButtonBuilder>(buttons);
newButtons.components[0].setDisabled(false).setStyle(ButtonStyle.Primary);
newButtons.components[1].setDisabled(true).setStyle(ButtonStyle.Secondary);
newButtons.components[0].setDisabled(false);
newButtons.components[1].setDisabled(true);
components.push(newButtons);

if (guildSetup?.invite) {
newButtons.addComponents(new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setURL(`https://discord.gg/${guildSetup?.invite}`)
.setEmoji(interaction.client.emotes.icons.join)
.setLabel('Join'));
components.push(
new ActionRowBuilder<ButtonBuilder>().addComponents(new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setURL(`https://discord.gg/${guildSetup?.invite}`)
.setEmoji(interaction.client.emotes.icons.join)
.setLabel('Join')),
);
}

await i.update({ embeds: [serverEmbed], components: [newButtons], files: [] });
await i.update({ embeds: [serverEmbed], components, files: [] });
}


Expand Down Expand Up @@ -159,8 +163,8 @@ export default {

// disable the user info button
const newButtons = ActionRowBuilder.from<ButtonBuilder>(buttons);
newButtons.components[0].setDisabled(false).setStyle(ButtonStyle.Primary);
newButtons.components[2].setDisabled(true).setStyle(ButtonStyle.Secondary);
newButtons.components[0].setDisabled(false);
newButtons.components[2].setDisabled(true);

// generate the profile card
if (!customCard) customCard = new AttachmentBuilder(await profileImage(author.id), { name: 'customCard.png' });
Expand Down

0 comments on commit 47f2fbc

Please sign in to comment.