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 ; reply : ( msg : any ) => Promise < unknown > ; } export interface MockUser { id : string ; bot : boolean ; username : string ; } export interface MockGuild { id : string ; roles : { cache : Collection < string , MockRole > ; } ; } export interface MockRole { id : string ; name : string ; } export interface MockGuildMember { id : string ; user : MockUser ; createDM : ( ) => Promise < MockChannel > ; roles : { cache : Collection < string , MockRole > ; } ; } export type NotificationCallback = ( msg : any ) => void ; export interface DiscordBotsDbGateway { getDatabaseClient ( ) : Promise < PgClient > ; getCurrentListenerId ( type ) : Promise < SUUID | null > ; getLastMessageIdProcessed ( type ) : Promise < Snowflake | null > ; becomeListener ( botInstanceId , type , previousListenerId ? ) : Promise < boolean > ; updateStatus ( status , botType , botInstanceId ) : Promise < void > ; updateLastMessageProcessed ( messageId , botInstanceId ) : Promise < void > ; subscribe ( channel , botType , callback ) : Promise < void > ; unsubscribe ( channel , botType ) : Promise < void > ; } export interface DmChannelsDbGateway { conversationCommand ( channelId ) : Promise < string | undefined > ; activateDMConversation ( channelId , userId , commandName ) : Promise < void > ; deactivateDMConversation ( channelId , userId ) : Promise < void > ; } export type DiscordBotStatus = 'connecting' | 'connected' | 'listening' | 'disconnected' | 'unresponsive' ; export interface MessageVerificationScheduler { destroy ( ) : void ; cancelScheduledVerification ( messageId ) : Message | undefined ; scheduledVerificationsCount : number ; scheduleVerification ( message ) : Promise < void > ; }