Skip to content

Commit

Permalink
fix(hubs): disable starter hubs for now
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-737 committed May 15, 2023
1 parent af8c45e commit ad3093f
Showing 1 changed file with 64 additions and 64 deletions.
128 changes: 64 additions & 64 deletions src/Scripts/network/displayStarterHubs.ts
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, ComponentType, EmbedBuilder } from 'discord.js';
import { getDb } from '../../Utils/functions/utils';
import { stripIndents } from 'common-tags';
import logger from '../../Utils/logger';

export = {
async execute(interaction: ChatInputCommandInteraction) {
const db = getDb();
try {
const allHubs = await db.hubs.findMany({ where: { official: true } });

const embed = new EmbedBuilder()
.setTitle('Pick your Starter Hub')
.setDescription(stripIndents`
A hub is a public network that servers can join. Messages will only be recieved by other members of the hub.
Below are some **starter hubs**. Please select one you wish to be a part of:
`)
.setFooter({ text: 'Tip: You can join other community hubs using /hub browse!' })
.setColor('#0099ff');

const rows: ActionRowBuilder<ButtonBuilder>[] = [];

for (let i = 0; i < allHubs.length; i++) {
const hub = allHubs[i];
if (!hub.official) continue;

rows.push(new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
.setCustomId(hub.id)
.setLabel(hub.name)
.setStyle(ButtonStyle.Primary),
));

embed.addFields({
name: hub.name,
value: hub.description,
inline: i % 3 === 0 ? false : true,
});
}

const reply = await interaction.editReply({
embeds: [embed],
components: rows,
});

const selection = await reply.awaitMessageComponent({
componentType: ComponentType.Button,
filter: (i) => i.user.id === interaction.user.id,
time: 30_000,
}).catch(() => null);

if (selection) {
await selection.deferUpdate();
return { id: selection.customId };
}
}
catch (err) {
logger.error(err);
interaction.editReply('An error occurred while retrieving the hubs. Please try again later.');
}
return false;
},
};
// import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, ComponentType, EmbedBuilder } from 'discord.js';
// import { getDb } from '../../Utils/functions/utils';
// import { stripIndents } from 'common-tags';
// import logger from '../../Utils/logger';
//
// export = {
// async execute(interaction: ChatInputCommandInteraction) {
// const db = getDb();
// try {
// const allHubs = await db.hubs.findMany({ where: { official: true } });
//
// const embed = new EmbedBuilder()
// .setTitle('Pick your Starter Hub')
// .setDescription(stripIndents`
// A hub is a public network that servers can join. Messages will only be recieved by other members of the hub.
//
// Below are some **starter hubs**. Please select one you wish to be a part of:
// `)
// .setFooter({ text: 'Tip: You can join other community hubs using /hub browse!' })
// .setColor('#0099ff');
//
// const rows: ActionRowBuilder<ButtonBuilder>[] = [];
//
// for (let i = 0; i < allHubs.length; i++) {
// const hub = allHubs[i];
// if (!hub.official) continue;
//
// rows.push(new ActionRowBuilder<ButtonBuilder>().addComponents(
// new ButtonBuilder()
// .setCustomId(hub.id)
// .setLabel(hub.name)
// .setStyle(ButtonStyle.Primary),
// ));
//
// embed.addFields({
// name: hub.name,
// value: hub.description,
// inline: i % 3 === 0 ? false : true,
// });
// }
//
// const reply = await interaction.editReply({
// embeds: [embed],
// components: rows,
// });
//
// const selection = await reply.awaitMessageComponent({
// componentType: ComponentType.Button,
// filter: (i) => i.user.id === interaction.user.id,
// time: 30_000,
// }).catch(() => null);
//
// if (selection) {
// await selection.deferUpdate();
// return { id: selection.customId };
// }
// }
// catch (err) {
// logger.error(err);
// interaction.editReply('An error occurred while retrieving the hubs. Please try again later.');
// }
// return false;
// },
// };

0 comments on commit ad3093f

Please sign in to comment.