Archived
restricted access to CommandManager's list
This commit is contained in:
1 parent
695f66843f
commit
00753477de
3 files changed
+17
-5
No files matched your search
+6
-3
@@ -132,7 +132,6 @@ export class Bot extends EventEmitter {
|
||||
const helpMsg: Command = new HelpMessage(this.commands, this.messages.help, this.name);
|
||||
this.commands.add(helpMsg);
|
||||
}
|
||||
Object.freeze(this.commands.list);
|
||||
process.stdout.write("Connecting to Discord... ");
|
||||
this.client.login(this.token);
|
||||
this.client.on("ready", async () => {
|
||||
@@ -248,11 +247,15 @@ export class Bot extends EventEmitter {
|
||||
process.stdout.write("Registering commands... ");
|
||||
await axios.put(
|
||||
`https://discord.com/api/v8/applications/${this.applicationId}/commands`,
|
||||
this.commands.list.filter((c) => !Array.isArray(c.guilds) && c.slash).map((c) => c.toCommandObject()),
|
||||
this.commands
|
||||
.getList()
|
||||
.filter((c) => !Array.isArray(c.guilds) && c.slash)
|
||||
.map((c) => c.toCommandObject()),
|
||||
{ headers: { Authorization: `Bot ${this.token}` } }
|
||||
);
|
||||
const guilds: any = {};
|
||||
await this.commands.list
|
||||
await this.commands
|
||||
.getList()
|
||||
.filter((c) => Array.isArray(c.guilds) && c.guilds.length > 0)
|
||||
.map((c) => {
|
||||
c.guilds?.map(async (g) => {
|
||||
|
||||
+10
-1
@@ -12,7 +12,7 @@ export class CommandManager {
|
||||
* List of commands registered in the manager
|
||||
* @type {Array} {@link Command}
|
||||
*/
|
||||
public readonly list: Command[];
|
||||
private readonly list: Command[];
|
||||
/**
|
||||
* Prefix used as a way to trigger the bot using messages
|
||||
* @type {string}
|
||||
@@ -56,6 +56,15 @@ export class CommandManager {
|
||||
return command;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all commands registered in a manager
|
||||
* @returns {Command[]} List of registered commands in a manager
|
||||
*/
|
||||
getList(): Command[] {
|
||||
const list = this.list;
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given {@link Command} to the instance manager with initial processing
|
||||
* @param {Command} command - {@link Command} instance object
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ export class HelpMessage extends Command {
|
||||
helpMsg.setTitle(params.title);
|
||||
helpMsg.setDescription(params.bottomText);
|
||||
|
||||
cmdManager.list.map((c) => {
|
||||
cmdManager.getList().map((c) => {
|
||||
if (
|
||||
c.visible &&
|
||||
((Array.isArray(c.guilds) && c.guilds.length > 0 && c.guilds.find((g) => i?.guild?.id === g)) || !Array.isArray(c.guilds) || c.guilds.length === 0)
|
||||
|
||||
Reference in new issue
Block a user