feat(permissions): Adds server permissions
This commit is contained in:
parent
d46bbd84c5
commit
cf9c88a2d6
24 changed files with 415 additions and 69 deletions
|
|
@ -1,8 +1,10 @@
|
|||
import {ConfigurationHandler} from "./ConfigurationHandler";
|
||||
import {ConfigurationHandler, PathConfigurationFrom} from "./ConfigurationHandler";
|
||||
import {
|
||||
AnyMenuItem,
|
||||
CollectionMenuItem,
|
||||
FieldMenuItem, FieldMenuItemContext, FieldMenuItemSaveValue,
|
||||
FieldMenuItem,
|
||||
FieldMenuItemContext,
|
||||
FieldMenuItemSaveValue,
|
||||
MenuItem,
|
||||
MenuItemType,
|
||||
PromptMenuItem
|
||||
|
|
@ -12,11 +14,11 @@ import {
|
|||
channelMention,
|
||||
ChannelSelectMenuBuilder,
|
||||
ChannelType,
|
||||
inlineCode,
|
||||
italic,
|
||||
StringSelectMenuBuilder, TextInputBuilder, TextInputStyle
|
||||
StringSelectMenuBuilder,
|
||||
TextInputBuilder,
|
||||
TextInputStyle
|
||||
} from "discord.js";
|
||||
import {ChannelId} from "../types/DiscordTypes";
|
||||
import {MessageActionRowComponentBuilder} from "@discordjs/builders";
|
||||
import {TransformerType} from "./ConfigurationTransformer";
|
||||
|
||||
|
|
@ -101,14 +103,14 @@ export class MenuHandler {
|
|||
|
||||
private getChannelValue(context: FieldMenuItemContext): string {
|
||||
const value = this.config.getConfigurationByPath(context.path.join('.'));
|
||||
if (value === undefined) {
|
||||
return italic("None");
|
||||
|
||||
const isDefault = value.from === PathConfigurationFrom.Default;
|
||||
const display = !value ? "None" : channelMention(<string>value.value);
|
||||
|
||||
if (isDefault) {
|
||||
return italic(`Default (${display})`)
|
||||
}
|
||||
|
||||
if (!value) {
|
||||
return inlineCode("None");
|
||||
}
|
||||
return channelMention(<ChannelId>value);
|
||||
return display;
|
||||
}
|
||||
|
||||
private getChannelMenuBuilder(): MessageActionRowComponentBuilder {
|
||||
|
|
@ -119,11 +121,14 @@ export class MenuHandler {
|
|||
|
||||
private getPermissionBooleanValue(context: FieldMenuItemContext) {
|
||||
const value = this.config.getConfigurationByPath(context.path.join('.'));
|
||||
if (value === undefined) {
|
||||
return italic("None");
|
||||
}
|
||||
|
||||
return value ? 'Allowed' : "Disallowed";
|
||||
const isDefault = value.from === PathConfigurationFrom.Default;
|
||||
const display = value.value === null ? "None" : value.value == true ? "Allowed" : "Disallowed";
|
||||
|
||||
if (isDefault) {
|
||||
return italic(`Default (${display})`)
|
||||
}
|
||||
return display;
|
||||
}
|
||||
|
||||
private getPermissionBooleanBuilder() {
|
||||
|
|
@ -144,15 +149,8 @@ export class MenuHandler {
|
|||
|
||||
private getStringValue(context: FieldMenuItemContext): string {
|
||||
const value = this.config.getConfigurationByPath(context.path.join('.'));
|
||||
if (!value) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
throw new TypeError(`Value of type ${typeof value} can't be used for a string value!`)
|
||||
}
|
||||
|
||||
return value;
|
||||
return value.value === null ? "" : <string>value.value;
|
||||
}
|
||||
|
||||
private getStringBuilder(): TextInputBuilder {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue