Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 44 additions & 81 deletions src/commands/slash/Main/setup.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import BaseCommand from '#main/core/BaseCommand.js';
import { RegisterInteractionHandler } from '#main/decorators/RegisterInteractionHandler.js';
import { Pagination } from '#main/modules/Pagination.js';
import { HubJoinService } from '#main/services/HubJoinService.js';
import Constants from '#main/utils/Constants.js';
import Constants, { emojis } from '#main/utils/Constants.js';
import { CustomID } from '#main/utils/CustomID.js';
import { InfoEmbed } from '#main/utils/EmbedUtils.js';
import { stripIndents } from 'common-tags';
Expand All @@ -14,64 +13,40 @@ import {
ButtonStyle,
ChannelType,
ChatInputCommandInteraction,
InteractionContextType,
RESTPostAPIChatInputApplicationCommandsJSONBody,
} from 'discord.js';

export default class SetupCommand extends BaseCommand {
readonly data: RESTPostAPIChatInputApplicationCommandsJSONBody = {
name: 'setup',
description: 'Setup the bot for the server',
contexts: [InteractionContextType.Guild],
options: [
{
name: 'interchat',
name: 'channel',
description: 'The channel to setup the bot in',
type: ApplicationCommandOptionType.Subcommand,
options: [
{
name: 'channel',
description: 'The channel to setup the bot in',
type: ApplicationCommandOptionType.Channel,
channel_types: [
ChannelType.GuildText,
ChannelType.PublicThread,
ChannelType.PrivateThread,
],
required: true,
},
],
},
{
name: 'lobby',
description: 'Learn how to use our userphone-like lobby chat system.',
type: ApplicationCommandOptionType.Subcommand,
type: ApplicationCommandOptionType.Channel,
channel_types: [ChannelType.GuildText, ChannelType.PublicThread, ChannelType.PrivateThread],
required: true,
},
],
};

public async execute(interaction: ChatInputCommandInteraction) {
const subcommand = interaction.options.getSubcommand(true);
if (subcommand === 'lobby') await this.setupLobby(interaction);
else if (subcommand === 'interchat') await this.setupHub(interaction);
}

private async setupLobby(interaction: ChatInputCommandInteraction): Promise<void> {
const embed = new InfoEmbed().setTitle('Lobby Setup').setDescription(stripIndents`
The lobby is a userphone-like chat system where you can chat with random people. What makes it different from other userphone bots is that you can have upto 3 servers in a lobby at once.
### How to setup:
1. Type \`c!connect\` or \`c!call\`.
2. Wait for someone to to join.
3. Have fun! 🎉
### Want something more?
Try out our multi-server hub chatting using </setup interchat:1305504885315207259>

-# Note: You are expected to follow our [guidelines](${Constants.Links.Website}/guidelines). If you are found breaking the guidelines, you will be banned from using the bot.
`);

await interaction.reply({ embeds: [embed] });
}

private async setupHub(interaction: ChatInputCommandInteraction): Promise<void> {
if (!interaction.inCachedGuild()) return;
const embed = new InfoEmbed().setDescription(
stripIndents`
## ${emojis.guide_icon} Interchat Setup - Let\'s get started!
Let's get started with setting up a connection to a hub from a channel in this server.
### Hub?
A **hub** is a **group**—where servers connect to, to chat together. Once you setup the bot in a channel, messages to and from that channel will go to other servers in that hub.
## Choose a Hub
1. Click **Official Hub** to join the official InterChat hub. (Recommended)
2. Or click **Random Hub** to join to a random community hub!

You and this server are expected to follow the [guidelines](${Constants.Links.Website}/guidelines) when chatting. We hope you enjoy your time on InterChat. 🎉
`,
);

const channel = interaction.options.getChannel('channel', true, [
ChannelType.GuildText,
Expand All @@ -95,40 +70,7 @@ export default class SetupCommand extends BaseCommand {
),
];

const embed1 = new InfoEmbed().setTitle('Interchat Setup - Let\'s get started!').setDescription(
stripIndents`
A **hub** is a group of servers that you can chat with. It can contain unlimited servers and lets you chat without disconnecting.

After this setup, you will be able to talk with people that are part of your chosen hub from ${channel}.
`,
);
const setupEmbed = new InfoEmbed().setDescription(stripIndents`
### Setup:
1. Click **Official Hub** to connect to a hub moderated by InterChat staff.
2. Or click **Random Hub** to connect to a random community owned hub.

You are expected to follow the [guidelines](${Constants.Links.Website}/guidelines) when chatting. If you are found breaking the guidelines, you will be banned from using the bot. Have fun! 🎉
`);

const finalEmbed = new InfoEmbed().setDescription(stripIndents`
### Finally:
- Search for community hubs by category here: ${Constants.Links.Website}/hubs
- Create your own hub using \`/hub create\`.
- Join a hub by name or invite by using \`/hub join\`.
- Leave a hub using \`/hub leave\`.
- Use our userphone-like lobby chat using \`/setup lobby\`.

Thats it! We hope you enjoy your time on InterChat.
-# Need help? Join our [support server](${Constants.Links.SupportInvite}).
`);

await new Pagination({ hideButtons: { search: true, exit: true, select: true } })
.addPages([
{ embeds: [embed1] },
{ embeds: [setupEmbed], components },
{ embeds: [finalEmbed], components: [] },
])
.run(interaction);
await interaction.reply({ embeds: [embed], components });
}

@RegisterInteractionHandler('setupHub')
Expand Down Expand Up @@ -159,12 +101,33 @@ export default class SetupCommand extends BaseCommand {
return;
}

let joinSuccess = false;

if (customId.suffix === 'official') {
// NOTE: if hub name ever changes, this will need to be updated
await hubJoinService.joinHub(channel, 'InterChat Central');
joinSuccess = await hubJoinService.joinHub(channel, 'InterChat Central');
}
else if (customId.suffix === 'random') {
await hubJoinService.joinRandomHub(channel);
joinSuccess = await hubJoinService.joinRandomHub(channel);
}

if (!joinSuccess) return;

const embed1 = new InfoEmbed().setDescription(stripIndents`
## ${emojis.yes} Setup Complete!
The bot has been setup in ${channel.toString()}. You can now chat with other servers from this channel. 🎉
`);

const embed2 = new InfoEmbed().setDescription(stripIndents`
You can also setup the bot in other channels with a different hub using \`/hub join\`. Pick a hub of your own choosing from a wide list of [public hubs](${Constants.Links.Website}/hubs) made by the community.
`);

const finalEmbed = new InfoEmbed().setDescription(stripIndents`
If you have any questions or need help, feel free to ask in the [support server](${Constants.Links.SupportInvite}). We also have a [Documentation](${Constants.Links.Website}/docs) page for more information.

Enjoy your time on InterChat! 🎉
`);

await interaction.followUp({ embeds: [embed1, embed2, finalEmbed], ephemeral: true });
}
}
2 changes: 1 addition & 1 deletion src/utils/CustomID.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class CustomID {
* @param suffix - The suffix for the custom ID (optional).
* @returns CustomID - The CustomID instance for method chaining.
*/
setIdentifier(prefix: string, suffix?: string): CustomID {
setIdentifier(prefix: string, suffix?: string): this {
this.customId = `${prefix}${suffix ? `:${suffix}` : ''}`;
return this;
}
Expand Down
Loading