Skip to content

Commit

Permalink
fix(env): env parse errors
Browse files Browse the repository at this point in the history
  • Loading branch information
fieztazica committed May 12, 2024
1 parent ee5d2c4 commit c10d14a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/example.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
NODE_ENV=
# Your Discord Application Bot Token
DISCORD_TOKEN=abcAbc123
# Discord User ID(s) of owner(s) (separate by a comma)
OWNERS=0000000000000,111111111111111
# Your Discord Development Guild Id for development purpose
DEV_GUILD_ID=8888888888888888888
# Discord User ID(s) of owner(s) (separate by a whitespace)
OWNERS=0000000000000 111111111111111
# Your Discord Development Guild Id for development purpose (separate by a whitespace)
DEV_GUILD_IDS=8888888888888888888 9999999999999999999
# Support Discord Server ID
SUPPORT_SERVER_ID=
# Support Discord Server Invite Link
Expand Down
13 changes: 8 additions & 5 deletions src/lib/HootClient.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { ApplicationCommandRegistries, SapphireClient, container } from '@sapphire/framework';
import { envParseArray, envParseString } from '@skyra/env-utilities';
import { ClientOptions } from 'discord.js';
import { DisTube, DisTubeOptions } from 'distube';

const dev = process.env.NODE_ENV !== 'production';
const dev = envParseString('NODE_ENV') !== 'production';
const devGuildIds = dev ? envParseArray('DEV_GUILD_IDS') : null;
console.log(devGuildIds);

export class HootClient extends SapphireClient {
distube: DisTube;
Expand All @@ -19,11 +22,11 @@ export class HootClient extends SapphireClient {
this.distube = distube;
container.distube = distube;

dev && ApplicationCommandRegistries.setDefaultGuildIds([process.env.DEV_GUILD_ID]);
dev && ApplicationCommandRegistries.setDefaultGuildIds(devGuildIds);

for (const command of container.stores.get('commands').values()) {
command.applicationCommandRegistry.registerChatInputCommand((b) => b.setDMPermission(false));
}
for (const command of container.stores.get('commands').values()) {
command.applicationCommandRegistry.registerChatInputCommand((b) => b.setDMPermission(false));
}

ApplicationCommandRegistries.registries.forEach((r) => r.registerChatInputCommand((b) => b.setDMPermission(false)));
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ colorette.createColors({ useColor: true });
declare module '@skyra/env-utilities' {
interface Env {
OWNERS: ArrayString;
DEV_GUILD_ID: string;
DEV_GUILD_IDS: ArrayString;
SUPPORT_SERVER_ID: string;
SUPPORT_SERVER_INVITE_LINK: string;
SUPPORT_URL: string;
Expand Down
4 changes: 2 additions & 2 deletions src/preconditions/GuildOnly.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Precondition } from '@sapphire/framework';
import { AllFlowsPrecondition } from '@sapphire/framework';
import type { ChatInputCommandInteraction, ContextMenuCommandInteraction, Message } from 'discord.js';

export class UserPrecondition extends Precondition {
export class UserPrecondition extends AllFlowsPrecondition {
#message: string = 'This command can only be used in guilds!';

public override messageRun(message: Message) {
Expand Down

0 comments on commit c10d14a

Please sign in to comment.