diff --git a/@types/Client.ts b/@types/Client.ts new file mode 100644 index 0000000..cbf3e41 --- /dev/null +++ b/@types/Client.ts @@ -0,0 +1,454 @@ +import { LoggerClientOptions } from '@navy.gif/logger'; +import { + Partials, + GatewayIntentBits, + Snowflake, + User, + ApplicationCommandType, + GuildMember, + Role, + BaseChannel, + TextChannel, + PermissionsString, + Channel, + APIEmbed, + OverwriteType, + Awaitable, + Message, + If, + GuildBan, + ThreadChannel, + APIEmbedField, + VoiceState, + Invite +} from 'discord.js'; +import { InvokerWrapper, MemberWrapper, UserWrapper } from '../src/client/components/wrappers/index.js'; +import GuildWrapper from '../src/client/components/wrappers/GuildWrapper.js'; +import DiscordClient from '../src/client/DiscordClient.js'; +import { CommandOption, Inhibitor } from '../src/client/interfaces/index.js'; +import { MuteType } from './Settings.js'; +import { ClientEvents } from './Events.js'; +import { FilterResult } from './Utils.js'; +import { GuildSettingTypes } from './Guild.js'; +import { StorageManagerOptions } from './Storage.js'; + +export type ManagerEvalOptions = { + context?: object, + debug?: boolean +} + +export type DiscordStruct = { + id: string +} + +export type FormatParams = { + [key: string]: string | number | boolean | undefined +} + +export type FormatOpts = { + code?: boolean, + language?: string +} + +export type ClientOptions = { + rootDir: string, + prefix?: string, + developers?: string[], + developmentMode?: boolean, + invite: string, + slashCommands?: { + developerGuilds: string[] + }, + libraryOptions: { + partials?: Partials[], + intents: GatewayIntentBits[], + invalidRequestWarningInterval?: number + }, + storage: StorageManagerOptions, + logger: LoggerClientOptions +} + +export type ComponentType = 'command' | 'module' | 'observer' | 'inhibitor' | 'setting' +export type ComponentOptions = { + id: string, + type: ComponentType, + module?: string, + guarded?: boolean, + disabled?: boolean +} + +export type ModuleOptions = { + name: string +} + +// type ComponentUpdate = (opts: { component: Component, type: 'ENABLE' | 'DISABLE' }) => void; +// export type EventHook = (...args: ClientEvents[keyof ClientEvents]) => Promise | void // ((...args: unknown[]) => void) | ComponentUpdate; +export type EventHook = (...args: ClientEvents[K]) => Awaitable; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export type GenericEventHook = (...args: any[]) => Awaitable; + +export type Hooks = [keyof ClientEvents, GenericEventHook][]; +export type ObserverOptions = { + name?: string, + priority?: number, + hooks?: Hooks, +} & Partial + +export type InhibitorOptions = { + name?: string, + guild?: boolean + priority?: number, + silent?: boolean +} & Partial + +export type InhibitorResponse = { + error: T, + inhibitor: Inhibitor, + params: If, +} + +export type InfractionType = + | 'ADDROLE' + | 'BAN' + | 'KICK' + | 'LOCKDOWN' + | 'MUTE' + | 'NICKNAME' + | 'NOTE' + | 'PRUNE' + | 'REMOVEROLE' + | 'SLOWMODE' + | 'SOFTBAN' + | 'UNBAN' + | 'UNLOCKDOWN' + | 'UNMUTE' + | 'VCKICK' + | 'VCMUTE' + | 'VCUNMUTE' + | 'VCBAN' + | 'VCUNBAN' + | 'WARN' + | 'DELETE'; + +export enum CommandOptionType { + SUB_COMMAND = 1, + SUB_COMMAND_GROUP = 2, + ROLES = 3, // Note plurality, strings can parse users, roles, and channels. + MEMBERS = 3, + USERS = 3, + CHANNELS = 3, + TEXT_CHANNELS = 3, + VOICE_CHANNELS = 3, + TIME = 3, // timestring + DATE = 3, + COMPONENT = 3, + COMPONENTS = 3, + COMMAND = 3, + COMMANDS = 3, + MODULE = 3, + STRING = 3, + INTEGER = 4, + BOOLEAN = 5, + MEMBER = 6, + USER = 6, + TEXT_CHANNEL = 7, + VOICE_CHANNEL = 7, + CHANNEL = 7, + ROLE = 8, + MENTIONABLE = 9, + NUMBER = 10, + FLOAT = 10, + POINTS = 4 +} + +export enum ChannelTypes { + TEXT_CHANNEL = 0, + VOICE_CHANNEL = 3 +} + +type CommandOptionChoice = { + name: string, + value: unknown +} +export type CommandOptionChoices = CommandOptionChoice[] +export type DependsOnMode = 'OR' | 'AND' + +export type RawCommandOption = { + name: string, + type: CommandOptionType, + options: RawCommandOption[] +} + +export type CommandOptionShape = { + name: string, + description: string, + type: number, + required: boolean, + choices: CommandOptionChoice[], + options: CommandOptionShape[], + min_value?: number, + max_value?: number, + channel_types: number[] | null, + autocomplete: boolean +} + +export type CommandOptionParams = { + client?: DiscordClient, + guild?: GuildWrapper | null, + + name: string | string[], + description?: string | string[] + type?: CommandOptionType | CommandOptionType[], + + required?: boolean, + autocomplete?: boolean, + strict?: boolean, + showUsage?: boolean + + choices?: CommandOptionChoices, + options?: CommandOptionParams[], + + dependsOn?: string[], + dependsOnMode?: DependsOnMode, + + minimum?: number, + maximum?: number, + // min?: number, + // max?: number, + + slashOption?: boolean, + flag?: boolean, + valueOptional?: boolean, + valueAsAlias?: boolean, + + value?: unknown, + defaultValue?: unknown, + rawValue?: string | string[] | null, +} + +export type CommandOptions = { + name?: string, + description?: string, + tags?: string[], + aliases?: string[], + restricted?: boolean, + showUsage?: boolean, + guildOnly?: boolean, + archivable?: boolean + slash?: boolean, + clientPermissions?: PermissionsString[], + memberPermissions?: PermissionsString[], + options?: CommandOptionParams[], + module?: string +} & Partial + +export type CommandParams = { [key: string]: CommandOption | undefined } + +export type SettingActionType = InfractionType | '' +export type SettingAction = { + [key: string]: unknown + type: SettingActionType, + duration: number | null, + points: number | null, + expiration: number | null, + force: boolean, + prune: boolean, + trigger: string | string[] | number +} +export type SettingMethod = 'add' | 'remove' | 'edit' | 'list' | 'reset' +export type SettingTypeResolve = 'USER' | 'GUILD'; +export type SettingEmojiOption = { + // +} +export type SettingApiDefinitions = { + // +} +export type BaseSetting = object +export type SettingOptions = { + name?: string, + resolve?: SettingTypeResolve, + description?: string, + display?: string, + emoji?: SettingEmojiOption, + default?: GuildSettingTypes + definitions?: SettingApiDefinitions, + commandOptions?: CommandOptionParams[], + commandType?: CommandOptionType, + clientPermissions?: PermissionsString[], + memberPermissions?: PermissionsString[], + premium?: number +} & Partial + +export type FilterSettingHelperResponse = { + error: true, + index?: string, + content?: string, + embeds?: APIEmbed[], + params?: FormatParams +} | { content: string, error?: false }; + +export type SlashCommandOptions = { + commandType?: ApplicationCommandType +} & CommandOptions; + +export type InfractionTargetType = 'USER' | 'CHANNEL'; + +export type InfractionArguments = { + [key: string]: CommandOption | undefined +} + +export type AdditionalInfractionData = { + muteType?: MuteType, + roles?: Role[] + roleIds?: Snowflake[], + roleNames?: string[], + oldPermissions?: { + [key: string]: { + type: OverwriteType, + permissions: { + SendMessages: boolean | null, + AddReactions: boolean | null + } + } + }, + dehoist?: boolean, + oldName?: string, + name?: string, + removedRoles?: Snowflake[] | null, + muteRole?: Snowflake | null, + amount?: number, + message?: Snowflake, + seconds?: number, +} + +export type InfractionFlags = { + // +} + +export type InfractionChangeType = + | 'UNRESOLVE' + | 'RESOLVE' + | 'DURATION' + | 'EXPIRATION' + | 'POINTS' + | 'REASON' + +export type InfractionChange = { + type: InfractionChangeType, + staff: string, + timestamp: number, + duration?: number | null, + reason?: string, + expiration?: number | null, + points?: number | null +} + +export type BaseInfractionData = { + _id?: string, + type?: InfractionType, + case?: number, + arguments?: InfractionArguments, + targetType?: InfractionTargetType, + guild: GuildWrapper, + channel?: TextChannel, + invoker?: InvokerWrapper | null, + target?: MemberWrapper | UserWrapper | TextChannel, + executor?: MemberWrapper | UserWrapper + duration?: number | null, + reason?: string, + silent?: boolean, + points?: number, + expiration?: number, + data?: AdditionalInfractionData, + hyperlink?: string | null, + _callbacked?: boolean, + fetched?: boolean +} + +export type InfractionJSON = { + id: string, + type: InfractionType, + case: number, + targetType: InfractionTargetType, + guild: Snowflake, + channel: Snowflake, + channelName: string, + target: Snowflake, + targetTag: string, + executor: Snowflake, + executorTag: string, + duration: number, + reason: string, + points: number, + expiration: number, + data: AdditionalInfractionData, + callback: number | null, + _callbacked?: boolean | null, + timestamp: number, + resolved: boolean, + changes: InfractionChange[], + flags: InfractionFlags, + modLogMessage: Snowflake, + modLogChannel: Snowflake + dmLogMessage: Snowflake, + message: Snowflake, +} + +export type ModerationCallback = { + infraction: InfractionJSON, + timeout: NodeJS.Timeout +} + +export type InfractionData = { +// +} & BaseInfractionData + +export type MemberResolveable = Snowflake | GuildMember | MemberWrapper | User | UserWrapper | string; +export type UserResolveable = Snowflake | User | UserWrapper | MemberWrapper | GuildMember | string; +export type RoleResolveable = Snowflake | Role | string; +export type ChannelResolveable = Snowflake | BaseChannel | string; +// type Resolveable = MemberResolveable | UserResolveable | RoleResolveable | ChannelResolveable + +export type MemberResolverFunction = (r: MemberResolveable, s: boolean, g: GuildWrapper | null) => Promise +export type UserResolverFunction = (r: UserResolveable, s: boolean, g: GuildWrapper | null) => Promise +export type RoleResolverFunction = (r: RoleResolveable, s: boolean, g: GuildWrapper | null) => Promise +export type ChannelResolverFunction = (r: ChannelResolveable, s: boolean, g: GuildWrapper | null) => Promise +export type ResolverFunction = + | MemberResolverFunction + | UserResolverFunction + | RoleResolverFunction + | ChannelResolverFunction + +export declare interface ExtendedMessage extends Message { + guildWrapper: If; + filtered?: FilterResult +} + +export declare interface ExtendedGuildBan extends GuildBan { + guildWrapper: GuildWrapper +} + +export declare interface ExtendedGuildMember extends GuildMember { + guildWrapper: GuildWrapper +} + +export declare interface ExtendedThreadChannel extends ThreadChannel { + guildWrapper: GuildWrapper +} + +export declare interface ExtendedAPIEmbedField extends APIEmbedField +{ + _attachment?: boolean; +} + +export declare interface ExtendedAPIEmbed extends APIEmbed { + fields: ExtendedAPIEmbedField[]; +} + +export declare interface ExtendedVoiceState extends VoiceState { + guildWrapper: GuildWrapper +} + +export declare interface ExtendedInvite extends Invite { + guildWrapper?: GuildWrapper +} \ No newline at end of file diff --git a/@types/Commands/Moderation.d.ts b/@types/Commands/Moderation.d.ts new file mode 100644 index 0000000..1d3299b --- /dev/null +++ b/@types/Commands/Moderation.d.ts @@ -0,0 +1,7 @@ +import { SlashCommandOptions } from '../Client.js'; + +export type ModerationCommandOptions = { + skipOptions?: string[], + overrideOptions?: boolean, + +} & SlashCommandOptions \ No newline at end of file diff --git a/@types/Commands/Settings.ts b/@types/Commands/Settings.ts new file mode 100644 index 0000000..dfe1c4b --- /dev/null +++ b/@types/Commands/Settings.ts @@ -0,0 +1,16 @@ +import { SlashCommandOptions } from '../Client.js'; +import { ReplyOptions } from '../Wrappers.js'; + +export type SettingsCommandOptions = { + // +} & SlashCommandOptions + +export type SettingResult = { + error?: boolean, +} & ReplyOptions + +export type SettingModifyResult = { + list: T[], + modified: T[], + skipped?: T[], +} \ No newline at end of file diff --git a/@types/Controller.d.ts b/@types/Controller.d.ts new file mode 100644 index 0000000..dd43300 --- /dev/null +++ b/@types/Controller.d.ts @@ -0,0 +1,48 @@ +import { LoggerMasterOptions, LoggerClientOptions } from '@navy.gif/logger'; +import { ClientOptions } from './Client.ts'; +import { StorageManagerOptions } from './Storage.js'; + +// export type ClientOptions = { +// prefix: string, +// developers: string[], +// developmentMode: boolean, +// invite: string, + +// slashCommands: { +// developerGuilds: string[] +// }, +// libraryOptions: { +// partials: string[], +// intents: string[], +// invalidRequestWarningInterval: number +// } +// } + +export type ControllerOptions = { + rootDir: string, + logger: LoggerMasterOptions, + shardOptions: { + totalShards: 'auto' | number, + shardList?: 'auto' | number[] + respawn?: boolean, + }, + discord: ClientOptions, + storage: StorageManagerOptions, + api: { + load: boolean, + domain: string, + authCallback: string, + dashboardUrl: string, + logger: LoggerClientOptions, + debug: boolean, + shardCount: number, + + discord: { + scope: string[], + token: string + } + http: { + port: number + } + } +}; \ No newline at end of file diff --git a/@types/Events.d.ts b/@types/Events.d.ts new file mode 100644 index 0000000..c90b3ad --- /dev/null +++ b/@types/Events.d.ts @@ -0,0 +1,23 @@ +import { Component } from '../src/client/interfaces/index.ts'; +import { ClientEvents as CE, InvalidRequestWarningData, RateLimitData, ResponseLike } from 'discord.js'; +import { ExtendedGuildBan, ExtendedMessage } from './Client.ts'; +import { APIRequest } from '@discordjs/rest'; +import { AutomodErrorProps, LinkFilterWarnProps, LogErrorProps, MissingPermsProps, UtilityErrorProps, WordWatcherErrorProps } from './Moderation.js'; + +type ComponentUpdate = { component: Component, type: 'ENABLE' | 'DISABLE' | 'LOAD' | 'UNLOAD' | 'RELOAD' } +export interface ClientEvents extends CE { + componentUpdate: [data: ComponentUpdate], + rateLimit: [rateLimitInfo: RateLimitData]; + invalidRequestWarning: [invalidRequestInfo: InvalidRequestWarningData]; + built: []; + messageCreate: [message: ExtendedMessage]; + apiResponse: [APIRequest, ResponseLike]; + guildBanAdd: [ExtendedGuildBan]; + guildBanRemove: [ExtendedGuildBan]; + automodError: [AutomodErrorProps]; + wordWatcherError: [WordWatcherErrorProps]; + logError: [LogErrorProps]; + utilityError: [UtilityErrorProps]; + linkFilterWarn: [LinkFilterWarnProps]; + filterMissingPermissions: [MissingPermsProps]; +} \ No newline at end of file diff --git a/@types/Guild.d.ts b/@types/Guild.d.ts new file mode 100644 index 0000000..26d8d41 --- /dev/null +++ b/@types/Guild.d.ts @@ -0,0 +1,206 @@ +import { ChannelType, Snowflake } from 'discord.js'; +import { + AutomodSettings, + AutoroleSettings, + CommandSettings, + DMInfractionSettings, + ErrorLogSettings, + GrantableSettings, + IgnoreSettings, + IndexingSettings, + InviteFilterSettings, + LinkfilterSettings, + LocaleSettings, + MemberLogSettings, + MentionFilterSettings, + MessagesSettings, + ModerationPointsSettings, + ModerationSettings, + MuteSettings, + NicknameLogSettings, + PermissionSettings, + ProtectionSettings, + RaidprotectionSettings, + SelfroleSettings, + SilenceSettings, + StaffSettings, + StickyRoleSettings, + TextCommandsSettings, + VoiceSettings, + WelcomerSettings, + WordFilterSettings, + WordWatcherSettings +} from './Settings.js'; +import { ObjectId } from 'mongodb'; + +export type GuildSettingTypes = + | AutomodSettings + | AutoroleSettings + | CommandSettings + | DMInfractionSettings + | ErrorLogSettings + | GrantableSettings + | IgnoreSettings + | IndexingSettings + | InviteFilterSettings + | LinkfilterSettings + | MemberLogSettings + | MentionFilterSettings + | MessagesSettings + | ModerationPointsSettings + | ModerationSettings + | MuteSettings + | NicknameLogSettings + | PermissionSettings + | ProtectionSettings + | SelfroleSettings + | SilenceSettings + | StaffSettings + | StickyRoleSettings + | TextCommandsSettings + | VoiceSettings + | WelcomerSettings + | WordFilterSettings + | WordWatcherSettings + | LocaleSettings + +export type PartialGuildSettings = Partial +// { +// [key: string]: unknown +// } + +export type GuildSettings = { + [key: string]: GuildSettingTypes, + locale: LocaleSettings, + textcommands: TextCommandsSettings, + wordfilter: WordFilterSettings + moderation: ModerationSettings, + dminfraction: DMInfractionSettings, + protection: ProtectionSettings, + modpoints: ModerationPointsSettings, + automod: AutomodSettings, + permissions: PermissionSettings, + grantable: GrantableSettings, + mute: MuteSettings, + silent: SilenceSettings, + ignore: IgnoreSettings, + commands: CommandSettings, + indexing: IndexingSettings, + errors: ErrorLogSettings, + messages: MessagesSettings, + staff: StaffSettings, + voice: VoiceSettings, + selfrole: SelfroleSettings, + members: MemberLogSettings, + nicknames: NicknameLogSettings, + stickyrole: StickyRoleSettings, + autorole: AutoroleSettings, + welcomer: WelcomerSettings, + wordwatcher: WordWatcherSettings, + linkfilter: LinkfilterSettings, + invitefilter: InviteFilterSettings, + mentionfilter: MentionFilterSettings, + raidprotection: RaidprotectionSettings, +} + +export type PermissionSet = { + global: string[], + channels: { + [id: Snowflake]: string[] + } +} + +export type GuildPermissions = { + guildId: Snowflake, + [roleId: Snowflake]: PermissionSet | Snowflake +} + +export type GuildData = { + [key: string]: unknown + caseId?: number, + settings?: GuildSettings, + premium?: number, + _version?: string, + _imported?: { + [key: string]: boolean | undefined, + modlogs?: boolean, + settings?: boolean + } +} + +export type CallbackData = { + type: string, + created: number, + time: number, + id: string +} + +export type PollData = { + user: string, + duration: number, + message: string, + channel: string, + startedIn: string, + questions: string[], + multiChoice?: boolean +} + +export type ReminderData = { + user: string, + channel: string, + reminder: string, + time: number +} + +export type ChannelJSON = { + id: Snowflake, + type: ChannelType, + name: string, + parent: Snowflake | null +} + +export type RoleJSON = { + id: Snowflake, + name: string, + position: number, +} + +export type GuildJSON = { + channels: ChannelJSON[], + roles: RoleJSON[] +} + +export type AttachmentData = { + size: number, + attachmentId: string, + name: string, + index: ObjectId, + id: string, + extension: string, + buffer: { buffer: Buffer } +} + +export type MessageLogEntry = { + attachments: AttachmentData[] +} + +export type RoleCacheEntry = { + member: string, + guild: string, + roles: string[], + timestamp: number +} + +export type WordWatcherEntry = { + message: string, + target: string, + channel: string, + timestamp: number +} + +export type WebhookEntry = { + feature: string, + guild: string, + hookId: string, + token: string +} \ No newline at end of file diff --git a/@types/Infractions.d.ts b/@types/Infractions.d.ts new file mode 100644 index 0000000..9a09610 --- /dev/null +++ b/@types/Infractions.d.ts @@ -0,0 +1,100 @@ +import { GuildTextBasedChannel } from 'discord.js'; +import { MemberWrapper } from '../src/client/components/wrappers/index.ts'; +import { BaseInfractionData } from './Client.ts'; +import { Infraction } from '../src/client/interfaces/index.ts'; + +export type ResolveResult = { + result?: void, + message?: string | null, + error?: boolean +} + +export type InfractionFail = { + error: true, + infraction: Infraction, + reason: string, + fatal: boolean, + formatted: boolean +} + +export type InfractionSuccess = { + error: false, + infraction: Infraction +} + +export type AddRoleData = { + target: MemberWrapper, + executor: MemberWrapper +} & BaseInfractionData + +export type BanData = { + executor: MemberWrapper +} & BaseInfractionData + +export type KickData = { + target: MemberWrapper, + executor: MemberWrapper +} & BaseInfractionData + +export type LockdownData = { + executor: MemberWrapper, + target: GuildTextBasedChannel +} & BaseInfractionData + +export type MuteData = { + executor: MemberWrapper, + target: MemberWrapper +} & BaseInfractionData + +export type NicknameData = { + executor: MemberWrapper, + target: MemberWrapper +} & BaseInfractionData + +export type NoteData = { + executor: MemberWrapper, +} & BaseInfractionData + +export type PruneData = { + executor: MemberWrapper, + target: GuildTextBasedChannel +} & BaseInfractionData + +export type RemoveRoleData = { + executor: MemberWrapper, + target: MemberWrapper +} & BaseInfractionData + +export type SlowmodeData = { + executor: MemberWrapper, + target: GuildTextBasedChannel +} & BaseInfractionData + +export type UnbanData = { + executor: MemberWrapper, +} & BaseInfractionData + +export type SoftbanData = { + executor: MemberWrapper, + target: MemberWrapper +} & BaseInfractionData + +export type UnlockdownData = { + executor: MemberWrapper, + target: GuildTextBasedChannel +} & BaseInfractionData + +export type UnmuteData = { + executor: MemberWrapper, + target: MemberWrapper +} & BaseInfractionData + +export type VcKickData = { + executor: MemberWrapper, + target: MemberWrapper +} & BaseInfractionData + +export type WarnData = { + executor: MemberWrapper, + target: MemberWrapper +} & BaseInfractionData \ No newline at end of file diff --git a/@types/Moderation.d.ts b/@types/Moderation.d.ts new file mode 100644 index 0000000..75f8f09 --- /dev/null +++ b/@types/Moderation.d.ts @@ -0,0 +1,91 @@ +import { GuildBasedChannel, Message, TextChannel } from 'discord.js'; +import { GuildWrapper, InvokerWrapper, MemberWrapper, UserWrapper } from '../src/client/components/wrappers/index.ts'; +import { CommandOption, Infraction } from '../src/client/interfaces/index.ts'; +import { FormatParams, InfractionType } from './Client.ts'; + +export type ModerationTarget = UserWrapper | MemberWrapper | TextChannel +export type ModerationTargets = ModerationTarget[] + +export type InfractionHandlerOptions = { + targets: ModerationTargets, + args: { [key: string]: CommandOption | undefined }, + data?: object +} + +export type HandleAutomodOptions = { + prune: boolean, + channel: TextChannel +} + +export type HandleTargetData = { + reason?: string, + force: boolean, + guild: GuildWrapper, + points?: number | null, + expiration?: number | null, + invoker?: InvokerWrapper, + arguments?: { [key: string]: CommandOption | undefined }, + channel: TextChannel, + executor: MemberWrapper, + duration?: number | null, + data: object, + silent: boolean, +} + +export type EscalationResult = { + threshold: number, + type: InfractionType, + length: number +} + +// export type AutomodAction = { +// points: number | undefined; +// expiration: number | undefined; +// prune: boolean; +// type: string, +// trigger: string | number, +// duration: number | null +// } + +export type AutomodErrorProps = { + fatal: boolean, + reason: string, + infraction: Infraction +} + +export type WordWatcherErrorProps = { + message: Message, + guild: GuildWrapper, + warning: boolean +} + +export type LogErrorProps = { + guild: GuildWrapper, + reason: string, + params: FormatParams, + logger: string +} + +export type UtilityErrorProps = { + guild: GuildWrapper, + reason: string, + params: FormatParams, + utility: string +} + +export type LinkFilterWarnProps = { + guild: GuildWrapper, + message: string +} + +export type MissingPermsProps = { + guild: GuildWrapper, + filter: string, + permissions: string[], + channel: GuildBasedChannel +} + +export type InfractionEditResult = { + error: true, + index: string +} | undefined; \ No newline at end of file diff --git a/@types/Settings.ts b/@types/Settings.ts new file mode 100644 index 0000000..1ec98d0 --- /dev/null +++ b/@types/Settings.ts @@ -0,0 +1,195 @@ +import { Snowflake } from 'discord.js'; +import { InfractionType, SettingAction } from './Client.js'; + +export type UserSettings = { + prefix?: string, + locale?: string +} + +export type Setting = { + [key: string]: any + enabled: boolean +} + +export type TextCommandsSettings = { + prefix: string, +} & Setting + +export type FilterSetting = { + bypass: string[], + whitelist: string[], + ignore: string[], + silent: boolean, + actions: SettingAction[] +} & Setting + +export type WordFilterSettings = { + explicit: string[], + fuzzy: string[], + regex: string[], +} & FilterSetting + +export type ModerationSettings = { + channel: Snowflake | null, + infractions: InfractionType[], + anonymous: boolean, + enabled: boolean +} + +export type DMInfractionSettings = { + anonymous: boolean, + infractions: InfractionType[], + messages: { + [key: string]: string + } +} & Setting + +export type ProtectionType = 'position' | 'role' +export type ProtectionSettings = { + type: ProtectionType, + roles: Snowflake[] +} & Setting + +export type ModerationPointsSettings = { + points: { [key in InfractionType]: number }, + expirations: { [key in InfractionType]: number }, + associations: { [key: string]: number }, + multiplier: boolean +} & Setting + +export type AutomodSettings = { + usePrevious: boolean; + thresholds: { + [key: number]: { + type?: InfractionType, + length?: number + } + }, +} & Setting + +export type PermissionType = 'discord' | 'grant' | 'both'; +export type PermissionSettings = { + type: PermissionType +} + +export type GrantableSettings = { + roles: Snowflake[] +} & Setting + +// export type MuteType = 1 | 2 | 3; +export enum MuteType { + Add = 0, + Replace = 1, + Remove = 2, + Timeout = 3 +} +export type MuteSettings = { + [key: string]: any// MuteType | Snowflake | number | boolean | null + type: MuteType, + role: Snowflake | null, + permanent: boolean, + default: number, +} + +export type SilenceSettings = { + // +} & Setting + +export type IgnoreSettings = { + [key: string]: Snowflake[] + channels: Snowflake[], + bypass: Snowflake[] +} + +export type CommandSettings = { + disabled: string[], + custom: object +} + +export type IndexingSettings = { + description: string | null +} & Setting + +export type ErrorLogSettings = { + types: string[] + channel: string | null +} + +export type MessagesSettings = { + channel: string | null, + bypass: string[], + ignore: string[], + attachments: boolean, + webhook: string | null, +} & Setting + +export type StaffSettings = { + role: string | null, + rule: string | null +} & Setting + +export type VoiceSettings = { + channel: string | null +} & Setting + +export type SelfroleSettings = { + text: string | null, + roles: string[], + message: string | null, + channel: string | null, +} + +export type MemberLogSettings = { + channel: string | null, + join: string | null, + leave: string | null +} & Setting + +export type NicknameLogSettings = { + channel: string | null +} & Setting + +export type StickyRoleSettings = { + roles: string[] +} & Setting + +export type AutoroleSettings = { + roles: string[] +} & Setting + +export type WelcomerSettings = { + message: string | null +} & Setting + +export type WordWatcherSettings = { + [key: string]: any// SettingAction[] | string[] | string | null + words: string[], + regex: string[], + bypass: string[], + ignore: string[], + channel: string | null, + actions: SettingAction[] +} + +export type LinkfilterSettings = { + blacklist: string[], + greylist: string[] + whitelistMode: boolean, +} & FilterSetting + +export type InviteFilterSettings = { + // +} & FilterSetting + +export type MentionFilterSettings = { + unique: boolean, + limit: number +} & FilterSetting + +export type LocaleSettings = { + language: string +} + +export type RaidprotectionSettings = { + // +} & Setting \ No newline at end of file diff --git a/@types/Shard.d.ts b/@types/Shard.d.ts new file mode 100644 index 0000000..7197d01 --- /dev/null +++ b/@types/Shard.d.ts @@ -0,0 +1,30 @@ +import { ClientOptions } from './Client.ts'; + +export type ShardingOptions = { + shardList?: 'auto' | number[], + totalShards?: 'auto' | number, + mode?: 'worker' | 'process', + respawn?: boolean, + shardArgs?: string[], + execArgv?: string[], + token?: string, + path?: string, + clientOptions?: ClientOptions +} + +export type ShardOptions = { + file: string, + token?: string, + execArgv?: string[], + args?: string[]; + respawn?: boolean, + clientOptions: ClientOptions + totalShards: number +} + +export type BroadcastEvalOptions = { + shard?: number, + context?: object +} + +export type ShardMethod = 'eval' | 'fetchClientValue' \ No newline at end of file diff --git a/@types/Shared.d.ts b/@types/Shared.d.ts new file mode 100644 index 0000000..81eff58 --- /dev/null +++ b/@types/Shared.d.ts @@ -0,0 +1,76 @@ +import { WriteOptions, LoggerClient } from '@navy.gif/logger'; +import { ClientOptions } from './Client.ts'; + +export type CommandOption = { + [key: string]: unknown +} + +export type Command = { + name: string, + options: { + [key: string]: CommandOption + } +} + +export type CommandsDef = { + type: 'global' | 'guild', + commands: Command[], + guilds: string[], + clientId: string +} + +export type IPCMessage = { + id?: string, + _start?: ClientOptions, + _ready?: boolean, + _disconnect?: boolean, + _reconnecting?: boolean, + _fetchProp?: string, + _sFetchProp?: string, + _sFetchPropShard?: number, + _sEval?: string, + _sEvalShard?: number, + _eval?: string, + _result?: unknown, + _error?: Error, + _sRespawnAll?: { + shardDelay: number, + respawnDelay: number, + timeout: number + }, + _mEval?: string, + _mEvalResult?: boolean + _logger?: boolean, + _api?: boolean, + _commands?: CommandsDef, + _shutdown?: boolean, + _fatal?: boolean, + success?: boolean + script?: string, + debug?: boolean, + type?: string, + data?: unknown, + shards?: number[] +} + +export type PlainError = { + name: string; + message: string; + stack?: string; +} + +export type EnvObject = { + [key: string]: unknown, + SHARDING_MANAGER: boolean + SHARD_ID: number + SHARD_COUNT: number + DISCORD_TOKEN: string | null +} + +export type Loggable = { + createLogger: (comp: object, options?: WriteOptions) => LoggerClient +} & T; + +export type Hookable = { + ready: boolean +} & T \ No newline at end of file diff --git a/@types/Storage.d.ts b/@types/Storage.d.ts new file mode 100644 index 0000000..2eff834 --- /dev/null +++ b/@types/Storage.d.ts @@ -0,0 +1,63 @@ +import { MongoClientOptions } from 'mongodb'; +import { PoolClusterConfig, PoolConfig } from 'mysql'; + +export type MariaError = { + code: string, + errno: number, + fatal: boolean, + sql: string, + sqlState: string, + sqlMessage:string +} & Error + +export type Credentials = { + user: string, + password: string, + host: string, + port: number, + database: string +} + +type DBOptions = { + load?: boolean, + tables: string[] +} + +export type MongoDBOptions = { + client?: MongoClientOptions, +} & DBOptions + +export type MariaDBOptions = { + cluster?: PoolClusterConfig, + client?: PoolConfig, +} & DBOptions + +export type StorageManagerOptions = { + [key: string]: MariaDBOptions | MongoDBOptions + mongodb: MongoDBOptions, + mariadb: MariaDBOptions +} + +export type MongoDBClientOptions = { + // +} + +export type MariaDBClientOptions = { + // +} + +export type ProviderOptions = { + tables: string[], +} + +export type TableOptions = { + name: string +} + +export type MongoDBTableOptions = { + // +} & TableOptions + +export type MariaDBTableOptions = { + // +} & TableOptions \ No newline at end of file diff --git a/@types/Utils.d.ts b/@types/Utils.d.ts new file mode 100644 index 0000000..e27b5f3 --- /dev/null +++ b/@types/Utils.d.ts @@ -0,0 +1,19 @@ +export type FilterType = 'explicit' | 'regex' | 'fuzzy' + +export type FilterResult = { + filter?: string, + match?: string, + matcher?: string, + matched?: boolean, + _matcher?: string, + type?: FilterType + word?: string, + raw?: string, + sim?: number, + threshold?: number, + sanctioned?: boolean +} + +export type Nullable = { + [K in keyof T]: T[K] | null +} \ No newline at end of file diff --git a/@types/Wrappers.d.ts b/@types/Wrappers.d.ts new file mode 100644 index 0000000..03f287b --- /dev/null +++ b/@types/Wrappers.d.ts @@ -0,0 +1,44 @@ +import { APIEmbed, ActionRowData, Attachment, AttachmentBuilder, AttachmentPayload, ChannelSelectMenuInteraction, EmbedBuilder, MentionableSelectMenuInteraction, MessageActionRowComponentBuilder, MessageActionRowComponentData, MessageComponent, MessageComponentType, RoleSelectMenuInteraction, StringSelectMenuInteraction, UserSelectMenuInteraction } from 'discord.js'; +import { FormatOpts, FormatParams } from './Client.ts'; + +export type MessageOptions = { + index?: string, + content?: string, + params?: FormatParams, + formatOpts?: FormatOpts, + emoji?: string, + embed?: APIEmbed | EmbedBuilder | null, + embeds?: (APIEmbed | EmbedBuilder)[], + files?: (Attachment | AttachmentBuilder | AttachmentPayload)[] +} + +export type PromptMessageOptions = { + files?: Buffer[], + editReply?: boolean, + delete?: boolean, + time?: number, + // disableMentions?: Mention +} & MessageOptions + +export type PromptInteractionOptions = { + components: ActionRowData[] + componentType?: MessageComponentType +} & ReplyOptions + +export type ReplyOptions = { + edit?: boolean, + dm?: boolean, + ephemeral?: boolean, + // _edit?: boolean, +} & MessageOptions + +export type EditReplyOptions = { + components?: ActionRowData[] +} & ReplyOptions + +export type SelectMenuInteraction = +| StringSelectMenuInteraction +| UserSelectMenuInteraction +| RoleSelectMenuInteraction +| MentionableSelectMenuInteraction +| ChannelSelectMenuInteraction \ No newline at end of file