xernerx 4.15.1 → 4.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -20,6 +20,6 @@ export default class InteractionUtil extends Util {
|
|
|
20
20
|
mimic(user: XernerxUser | string, interaction: MessageCreateOptions, options: MimicOptions): Promise<void>;
|
|
21
21
|
paginator(embeds: Array<EmbedBuilder>, options?: PaginatorOptions): Promise<void | import("discord.js").Message<false> | import("discord.js").Message<true>>;
|
|
22
22
|
commands(): import("@discordjs/collection").Collection<string, import("../main.js").XernerxSlashCommand> | import("@discordjs/collection").Collection<string, import("../main.js").XernerxContextCommand>;
|
|
23
|
-
permissionCheck(type: 'user' | 'client', permissions: Array<PermissionNames
|
|
23
|
+
permissionCheck(type: 'user' | 'client', permissions: Array<PermissionNames>, emit?: boolean): boolean | string[];
|
|
24
24
|
}
|
|
25
25
|
export {};
|
|
@@ -125,7 +125,7 @@ export default class InteractionUtil extends Util {
|
|
|
125
125
|
else
|
|
126
126
|
return this.client.commands.context;
|
|
127
127
|
}
|
|
128
|
-
permissionCheck(type, permissions) {
|
|
128
|
+
permissionCheck(type, permissions, emit = true) {
|
|
129
129
|
console.log(type);
|
|
130
130
|
const missing = [];
|
|
131
131
|
for (const permission of permissions) {
|
|
@@ -137,8 +137,7 @@ export default class InteractionUtil extends Util {
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
const command = this.commands().toJSON().find((cmd) => cmd.name == this.parsed.alias?.split(/ +/)[0]);
|
|
140
|
-
|
|
141
|
-
if (missing.length) {
|
|
140
|
+
if (missing.length && emit) {
|
|
142
141
|
this.client.emit(`commandBlock`, this.interaction, {
|
|
143
142
|
reason: `missing${Style.pascalCase(type)}Permissions`,
|
|
144
143
|
message: `${type == 'user' ? 'You are' : 'I am'} missing the following permissions to run \`${command?.name}\`:\n${missing.map((permission) => `> - ${permission}`).join('\n')}`,
|
|
@@ -147,6 +146,8 @@ export default class InteractionUtil extends Util {
|
|
|
147
146
|
}, command || null);
|
|
148
147
|
return false;
|
|
149
148
|
}
|
|
149
|
+
else if (missing.length && !emit)
|
|
150
|
+
return missing;
|
|
150
151
|
else
|
|
151
152
|
return true;
|
|
152
153
|
}
|
|
@@ -21,6 +21,6 @@ export default class MessageUtil extends Util {
|
|
|
21
21
|
mimic(user: XernerxUser | string, message: MessageCreateOptions, options: MimicOptions): Promise<void>;
|
|
22
22
|
paginator(embeds: Array<EmbedBuilder>, options?: PaginatorOptions): Promise<void | import("discord.js").Message<boolean> | null>;
|
|
23
23
|
commands(): import("@discordjs/collection").Collection<string, import("../main.js").XernerxMessageCommand>;
|
|
24
|
-
permissionCheck(type: 'user' | 'client', permissions: Array<PermissionNames
|
|
24
|
+
permissionCheck(type: 'user' | 'client', permissions: Array<PermissionNames>, emit?: boolean): boolean | string[];
|
|
25
25
|
}
|
|
26
26
|
export {};
|
|
@@ -139,7 +139,7 @@ export default class MessageUtil extends Util {
|
|
|
139
139
|
commands() {
|
|
140
140
|
return this.client.commands.message;
|
|
141
141
|
}
|
|
142
|
-
permissionCheck(type, permissions) {
|
|
142
|
+
permissionCheck(type, permissions, emit = true) {
|
|
143
143
|
console.log(type);
|
|
144
144
|
const missing = [];
|
|
145
145
|
for (const permission of permissions) {
|
|
@@ -151,8 +151,7 @@ export default class MessageUtil extends Util {
|
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
const command = this.commands().find((cmd) => cmd.name == this.parsed.alias || cmd.aliases?.includes(this.parsed.alias));
|
|
154
|
-
|
|
155
|
-
if (missing.length) {
|
|
154
|
+
if (missing.length && emit) {
|
|
156
155
|
this.client.emit(`commandBlock`, this.message, {
|
|
157
156
|
reason: `missing${Style.pascalCase(type)}Permissions`,
|
|
158
157
|
message: `${type == 'user' ? 'You are' : 'I am'} missing the following permissions to run \`${command?.name}\`:\n${missing.map((permission) => `> - ${permission}`).join('\n')}`,
|
|
@@ -161,6 +160,8 @@ export default class MessageUtil extends Util {
|
|
|
161
160
|
}, command || null);
|
|
162
161
|
return false;
|
|
163
162
|
}
|
|
163
|
+
else if (missing.length && !emit)
|
|
164
|
+
return missing;
|
|
164
165
|
else
|
|
165
166
|
return true;
|
|
166
167
|
}
|