import { Message as DiscordMessage, Guild as DiscordGuild, GuildMember as DiscordGuildMember, Collection, Snowflake, } from 'discord.js'; import { Client as PgClient } from 'pg'; export interface DiscordBotConfig { botId: string; botToken: string; cordeBotId: string; cordeBotToken: string; commandPrefix: string; allowedGuilds: string; allowedChannels: string; messageVerificationDelayMs: number; } import { MockChannel } from './utils/mocks'; import { SUUID } from 'short-uuid'; export { SUUID } from 'short-uuid'; export { MockChannel, Snowflake }; export type Message = DiscordMessage | MockMessage; export type GuildMember = DiscordGuildMember | MockGuildMember; export type Guild = DiscordGuild | MockGuild; export interface MockMessage { id: string; content: string; author: MockUser; member?: MockGuildMember; channel: MockChannel; guild?: MockGuild; // I'm being really loose with what a message item is, if we want to nail it // down there is a large pile of stuff this could be, but I didn't want to // make the mock too heavyweight reply: (msg: any) => Promise; } export interface MockUser { id: string; bot: boolean; username: string; } export interface MockGuild { id: string; roles: { cache: Collection; }; } export interface MockRole { id: string; name: string; } export interface MockGuildMember { id: string; user: MockUser; createDM: () => Promise; roles: { cache: Collection; }; } export type NotificationCallback = (msg: any) => void; export interface DiscordBotsDbGateway { getDatabaseClient(): Promise; getCurrentListenerId(type: string): Promise; getLastMessageIdProcessed(type: string): Promise; becomeListener(botInstanceId: SUUID, type: string, previousListenerId?: SUUID | null): Promise; updateStatus(status: DiscordBotStatus, botType: string, botInstanceId: SUUID): Promise; updateLastMessageProcessed(messageId: Snowflake, botInstanceId: SUUID): Promise; subscribe(channel: string, botType: string, callback: NotificationCallback): Promise; unsubscribe(channel: string, botType: string): Promise; } export interface DmChannelsDbGateway { conversationCommand(channelId: string): Promise; activateDMConversation(channelId: string, userId: string, commandName: string): Promise; deactivateDMConversation(channelId: string, userId: string): Promise; } export type DiscordBotStatus = 'connecting' | 'connected' | 'listening' | 'disconnected' | 'unresponsive'; export interface MessageVerificationScheduler { destroy(): void; cancelScheduledVerification(messageId: Snowflake): Message | undefined; scheduledVerificationsCount: number; scheduleVerification(message: Message): Promise; }