Skip to content

Commit ed0deff

Browse files
committed
♻️ redo scope
1 parent 70be37b commit ed0deff

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

src/classes/DiscordCommand.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import type {
1111
} from "discord.js";
1212

1313
export default class DiscordCommand extends BaseClass {
14-
scope: "GLOBAL" | "GUILD" | "UNKNOWN" = "UNKNOWN";
1514
guildId?: string;
1615
name: string;
1716
description: string;

src/classes/ModuleLoader.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import debug from "debug";
2-
import { ApplicationCommand, Collection } from "discord.js";
3-
import { existsSync, lstatSync } from "node:fs";
4-
import { readdir } from "node:fs/promises";
2+
import { Collection } from "discord.js";
3+
import { existsSync } from "node:fs";
4+
import { lstat, readdir } from "node:fs/promises";
55
import { basename, resolve } from "node:path";
66

77
import DiscordCommand from "./DiscordCommand";
@@ -14,7 +14,8 @@ import type {
1414
Interaction,
1515
CacheType,
1616
UserApplicationCommandData,
17-
ChatInputApplicationCommandData
17+
ChatInputApplicationCommandData,
18+
ApplicationCommand
1819
} from "discord.js";
1920

2021
export interface ModuleLoaderOptions {
@@ -56,7 +57,7 @@ export default class DiscordModuleLoader {
5657

5758
const returnGuilds: [string, DiscordGuild][] = [];
5859
for (const folder of guilds) {
59-
if (!lstatSync(resolve(dir, folder)).isDirectory())
60+
if (!(await lstat(resolve(dir, folder))).isDirectory())
6061
throw new Error(`${folder} is not a directory.`);
6162

6263
if (!existsSync(resolve(dir, folder, "index.js")))
@@ -109,7 +110,7 @@ export default class DiscordModuleLoader {
109110

110111
const returnModules: [string, DiscordModule][] = [];
111112
for (const folder of modules) {
112-
if (!lstatSync(resolve(dir, folder)).isDirectory())
113+
if (!(await lstat(resolve(dir, folder))).isDirectory())
113114
throw new Error(`${folder} is not a directory.`);
114115

115116
if (!existsSync(resolve(dir, folder, "index.js")))
@@ -194,9 +195,7 @@ export default class DiscordModuleLoader {
194195
if (this.commands.has(command.name.toLowerCase()))
195196
throw new Error(`Cannot add ${command.name} more than once.`);
196197

197-
if (globalCommands === true) command.scope = "GLOBAL";
198198
if (globalCommands !== true) {
199-
command.scope = "GUILD";
200199
command.guildId = globalCommands;
201200
}
202201

@@ -210,7 +209,7 @@ export default class DiscordModuleLoader {
210209
async updateSlashCommands() {
211210
if (!this.client.isReady()) throw new Error("Client is not ready.");
212211

213-
const localGlobalCommands = this.commands.filter(c => c.scope === "GLOBAL"),
212+
const localGlobalCommands = this.commands.filter(c => !c.guildId),
214213
log = this.log.extend("SlashCommands");
215214

216215
log("Setting %d global commands...", localGlobalCommands.size);

0 commit comments

Comments
 (0)