This commit is contained in:
Erik 2023-12-05 17:47:54 +02:00
parent 8142312546
commit 9960211eee
14 changed files with 1372 additions and 0 deletions

454
@types/Client.ts Normal file
View File

@ -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> | void // ((...args: unknown[]) => void) | ComponentUpdate;
export type EventHook<K extends keyof ClientEvents> = (...args: ClientEvents[K]) => Awaitable<unknown>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type GenericEventHook = (...args: any[]) => Awaitable<unknown>;
export type Hooks = [keyof ClientEvents, GenericEventHook][];
export type ObserverOptions = {
name?: string,
priority?: number,
hooks?: Hooks,
} & Partial<ComponentOptions>
export type InhibitorOptions = {
name?: string,
guild?: boolean
priority?: number,
silent?: boolean
} & Partial<ComponentOptions>
export type InhibitorResponse<T extends boolean = boolean> = {
error: T,
inhibitor: Inhibitor,
params: If<T, FormatParams>,
}
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<ComponentOptions>
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<ComponentOptions>
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<GuildMember | null>
export type UserResolverFunction = (r: UserResolveable, s: boolean, g: GuildWrapper | null) => Promise<User | null>
export type RoleResolverFunction = (r: RoleResolveable, s: boolean, g: GuildWrapper | null) => Promise<Role | null>
export type ChannelResolverFunction = (r: ChannelResolveable, s: boolean, g: GuildWrapper | null) => Promise<Channel | null>
export type ResolverFunction =
| MemberResolverFunction
| UserResolverFunction
| RoleResolverFunction
| ChannelResolverFunction
export declare interface ExtendedMessage<InGuild extends boolean = boolean> extends Message<InGuild> {
guildWrapper: If<InGuild, GuildWrapper>;
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
}

7
@types/Commands/Moderation.d.ts vendored Normal file
View File

@ -0,0 +1,7 @@
import { SlashCommandOptions } from '../Client.js';
export type ModerationCommandOptions = {
skipOptions?: string[],
overrideOptions?: boolean,
} & SlashCommandOptions

View File

@ -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<T> = {
list: T[],
modified: T[],
skipped?: T[],
}

48
@types/Controller.d.ts vendored Normal file
View File

@ -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
}
}
};

23
@types/Events.d.ts vendored Normal file
View File

@ -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];
}

206
@types/Guild.d.ts vendored Normal file
View File

@ -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<GuildSettings>
// {
// [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
}

100
@types/Infractions.d.ts vendored Normal file
View File

@ -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

91
@types/Moderation.d.ts vendored Normal file
View File

@ -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;

195
@types/Settings.ts Normal file
View File

@ -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

30
@types/Shard.d.ts vendored Normal file
View File

@ -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'

76
@types/Shared.d.ts vendored Normal file
View File

@ -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<T> = {
createLogger: (comp: object, options?: WriteOptions) => LoggerClient
} & T;
export type Hookable<T> = {
ready: boolean
} & T

63
@types/Storage.d.ts vendored Normal file
View File

@ -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

19
@types/Utils.d.ts vendored Normal file
View File

@ -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<T> = {
[K in keyof T]: T[K] | null
}

44
@types/Wrappers.d.ts vendored Normal file
View File

@ -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<MessageActionRowComponentData | MessageActionRowComponentBuilder>[]
componentType?: MessageComponentType
} & ReplyOptions
export type ReplyOptions = {
edit?: boolean,
dm?: boolean,
ephemeral?: boolean,
// _edit?: boolean,
} & MessageOptions
export type EditReplyOptions = {
components?: ActionRowData<MessageActionRowComponentData | MessageActionRowComponentBuilder>[]
} & ReplyOptions
export type SelectMenuInteraction =
| StringSelectMenuInteraction
| UserSelectMenuInteraction
| RoleSelectMenuInteraction
| MentionableSelectMenuInteraction
| ChannelSelectMenuInteraction