Skip to content

Commit

Permalink
feat: added help command
Browse files Browse the repository at this point in the history
  • Loading branch information
parnavh committed Nov 30, 2024
1 parent 6921f87 commit 3c3ad99
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/two-buttons-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"koala": minor
---

added help command
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ PERMISSIONS_INTEGER="35597246614592"

# Custom Invite Link - Optional
CUSTOM_INVITE_LINK=""

# Invite link for support server - Optional
SUPPORT_SERVER_LINK=""
40 changes: 36 additions & 4 deletions src/commands/misc.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,50 @@
import { env } from "@/env";
import { type CommandInteraction } from "discord.js";
import { EmbedBuilder, type CommandInteraction } from "discord.js";
import { Discord, Slash } from "discordx";

function getInviteLink(botId: string) {
return (
env.CUSTOM_INVITE_LINK ||
`https://discord.com/oauth2/authorize?client_id=${botId}&permissions=${env.PERMISSIONS_INTEGER}&integration_type=0&scope=applications.commands+bot`
);
}

@Discord()
export class MiscCommands {
@Slash({ description: "Get an invite link to the bot" })
invite(interaction: CommandInteraction, client: KoalaClient): void {
const url =
env.CUSTOM_INVITE_LINK ||
`https://discord.com/oauth2/authorize?client_id=${client.user?.id}&permissions=${env.PERMISSIONS_INTEGER}&integration_type=0&scope=applications.commands+bot`;
const url = getInviteLink(client.user!.id);

interaction.reply({
content: `[Invite link](${url})`,
ephemeral: true,
});
}

@Slash({ description: "Feeling lost? Get to know the basics!" })
help(interaction: CommandInteraction, client: KoalaClient): void {
const links = [`[Invite me](${getInviteLink(client.user!.id)})`];

if (env.SUPPORT_SERVER_LINK) {
links.push(`[Support Server](${env.SUPPORT_SERVER_LINK})`);
}

const helpEmbed = new EmbedBuilder()
.setColor(0xb46547)
.setTitle("Help")
.setDescription(
`Koala is a voice utility-focused bot that enhances your discord experience by announcing users as they join the channel and much more
\nUse the \`/settings announce\` command and its subcommands to customize which channels Koala announces in
\nBy default, announcements are enabled for every channel, so you're ready to go right out of the box!\n`,
)
.addFields({
name: "Links",
value: links.join(" • "),
});

interaction.reply({
embeds: [helpEmbed],
ephemeral: true,
});
}
}
1 change: 1 addition & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const env = createEnv({
}),
CUSTOM_INVITE_LINK: z.string().url().optional(),
PERMISSIONS_INTEGER: z.coerce.number(),
SUPPORT_SERVER_LINK: z.string().url().optional(),
},
runtimeEnv: process.env,
emptyStringAsUndefined: true,
Expand Down

0 comments on commit 3c3ad99

Please sign in to comment.