Change help command so exclusive commands can only be seen for the server they're assigned to
This commit is contained in:
parent
2dc5d0397b
commit
6af20fa6c8
1 changed files with 18 additions and 10 deletions
|
@ -29,8 +29,9 @@ export default class Help extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SendAll(context: ICommandContext) {
|
public SendAll(context: ICommandContext) {
|
||||||
const allCommands = CoreClient.commandItems;
|
const allCommands = CoreClient.commandItems
|
||||||
const cateogries = [...new Set(allCommands.map(x => x.Command.Category))];;
|
.filter(x => !x.ServerId || x.ServerId == context.message.guild?.id);
|
||||||
|
const cateogries = [...new Set(allCommands.map(x => x.Command.Category))];
|
||||||
|
|
||||||
const embed = new PublicEmbed(context, "Commands", "");
|
const embed = new PublicEmbed(context, "Commands", "");
|
||||||
|
|
||||||
|
@ -44,19 +45,26 @@ export default class Help extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SendSingle(context: ICommandContext) {
|
public SendSingle(context: ICommandContext) {
|
||||||
const command = CoreClient.commandItems.find(x => x.Name == context.args[0]);
|
const command = CoreClient.commandItems.find(x => x.Name == context.args[0] && !x.ServerId);
|
||||||
|
const exclusiveCommand = CoreClient.commandItems.find(x => x.Name == context.args[0] && x.ServerId == context.message.guild?.id);
|
||||||
|
|
||||||
if (!command) {
|
if (exclusiveCommand) {
|
||||||
const errorEmbed = new ErrorEmbed(context, "Command does not exist");
|
const embed = new PublicEmbed(context, StringTools.Capitalise(exclusiveCommand.Name), "");
|
||||||
errorEmbed.SendToCurrentChannel();
|
embed.addField("Category", StringTools.Capitalise(exclusiveCommand.Command.Category || "Uncategorised"));
|
||||||
|
embed.addField("Required Roles", StringTools.Capitalise(exclusiveCommand.Command.Roles.join(", ")) || "Everyone");
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
embed.SendToCurrentChannel();
|
||||||
|
} else if (command) {
|
||||||
const embed = new PublicEmbed(context, StringTools.Capitalise(command.Name), "");
|
const embed = new PublicEmbed(context, StringTools.Capitalise(command.Name), "");
|
||||||
embed.addField("Category", StringTools.Capitalise(command.Command.Category || "Uncategorised"));
|
embed.addField("Category", StringTools.Capitalise(command.Command.Category || "Uncategorised"));
|
||||||
embed.addField("Required Roles", StringTools.Capitalise(command.Command.Roles.join(", ")) || "Everyone");
|
embed.addField("Required Roles", StringTools.Capitalise(command.Command.Roles.join(", ")) || "Everyone");
|
||||||
|
|
||||||
embed.SendToCurrentChannel();
|
embed.SendToCurrentChannel();
|
||||||
|
} else {
|
||||||
|
const errorEmbed = new ErrorEmbed(context, "Command does not exist");
|
||||||
|
errorEmbed.SendToCurrentChannel();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue