This commit is contained in:
+7
-7
@@ -4,7 +4,7 @@ export interface DiscordSettings {
|
||||
enabled: boolean;
|
||||
guildId: string;
|
||||
channels: Record<DiscordGame, string>;
|
||||
publishedServers: string[];
|
||||
excludedServers: string[];
|
||||
showPlayers: boolean;
|
||||
showAddresses: boolean;
|
||||
leaderboardEnabled: boolean;
|
||||
@@ -14,7 +14,7 @@ export const defaultDiscordSettings: DiscordSettings = {
|
||||
enabled: false,
|
||||
guildId: '',
|
||||
channels: { t5: '', t6: '' },
|
||||
publishedServers: [],
|
||||
excludedServers: [],
|
||||
showPlayers: false,
|
||||
showAddresses: false,
|
||||
leaderboardEnabled: false
|
||||
@@ -43,20 +43,20 @@ export function validateDiscordSettings(value: unknown): DiscordSettings {
|
||||
throw new Error('Channel IDs must be valid Discord IDs or empty.');
|
||||
}
|
||||
if (
|
||||
!Array.isArray(input.publishedServers) ||
|
||||
input.publishedServers.length > 100 ||
|
||||
input.publishedServers.some(
|
||||
!Array.isArray(input.excludedServers) ||
|
||||
input.excludedServers.length > 100 ||
|
||||
input.excludedServers.some(
|
||||
(name) => typeof name !== 'string' || !/^[A-Za-z0-9_.-]{1,128}$/.test(name)
|
||||
)
|
||||
)
|
||||
throw new Error('Choose up to 100 published servers.');
|
||||
throw new Error('Choose up to 100 servers to exclude from Discord.');
|
||||
if (input.enabled && (!input.guildId || (!channels.t5 && !channels.t6)))
|
||||
throw new Error('Choose a Discord server and at least one board channel before enabling.');
|
||||
return {
|
||||
enabled: input.enabled as boolean,
|
||||
guildId: input.guildId,
|
||||
channels: { t5: channels.t5 as string, t6: channels.t6 as string },
|
||||
publishedServers: [...new Set(input.publishedServers as string[])].sort(),
|
||||
excludedServers: [...new Set(input.excludedServers as string[])].sort(),
|
||||
showPlayers: input.showPlayers as boolean,
|
||||
showAddresses: input.showAddresses as boolean,
|
||||
leaderboardEnabled: input.leaderboardEnabled as boolean
|
||||
|
||||
Reference in New Issue
Block a user