import { Client , Collection , Intents , Snowflake } from "discord.js" ; import { DBGuild , guildInterface } from "../models/Guild" ; import * as fs from "fs" ; import { Command } from "./Command" ; import { Player } from "discord-player" ; import { Downloader as youtubeDownloader } from "@discord-player/downloader" ; import { DBEvent , eventInterface } from "../models/Event" ; import { DBRoleMenu , roleMenuInterface } from "../models/RoleMenu" ; import { DBSoundEffect , soundEffectInterface } from "../models/SoundEffect" ; import Deps from "../utils/deps" ; import { DBMember } from "../models/Member" ; import { DBMessage } from "../models/Message" ; import { DBPoll } from "../models/Poll" ; import { DBReminder } from "../models/Reminder" ; import { DBUser } from "../models/User" ; import { MemberSoundEffects } from "../helpers/loadMemberSoundEffects" ; import { DiscordTogether } from "discord-together" ; import { CachedInvite } from "../events/inviteCreate" ; export class TundraBot extends Client { /** <command name, command module> */ commands : Collection < string , Command > ; /** <command alias, command name> */ aliases : Collection < string , string > ; categories : string [ ] ; /** <command name, command module> */ interactiveCommands : Collection < string , Command > ; player : Player ; /** <`${message.guild.id}${message.member.id}`, TODO> */ gameMembers : Map < string , any > ; activeEmojiStealing : Set < string > ; /** <userID> */ waitingResponse : Set < Snowflake > ; /** <guildID, <invite code, invite>> */ guildInvites : Map < string , Map < Snowflake , CachedInvite > > ; discordTogether : DiscordTogether < { "TundraBot" ; } > ; databaseCache : { /** <guildID, guildInterface> */ settings : Collection < Snowflake , guildInterface > ; /** <messageID, eventInterface> */ events : Collection < Snowflake , eventInterface > ; /** <messageID, roleMenuInterface> */ roleMenus : Collection < Snowflake , roleMenuInterface > ; /** <`${message.guild.id}${soundEffect.name}`, soundEffectInterface> */ soundEffects : Collection < string , soundEffectInterface > ; /** <`${message.member.guild.id}${message.author.id}`, MemberSoundEffects> */ memberSoundEffects : Collection < string , MemberSoundEffects > ; } ; constructor ( ) { const intents = new Intents ( [ Intents . FLAGS . DIRECT_MESSAGES , Intents . FLAGS . DIRECT_MESSAGE_REACTIONS , Intents . FLAGS . GUILDS , Intents . FLAGS . GUILD_EMOJIS_AND_STICKERS , Intents . FLAGS . GUILD_INVITES , Intents . FLAGS . GUILD_MEMBERS , Intents . FLAGS . GUILD_MESSAGES , Intents . FLAGS . GUILD_MESSAGE_REACTIONS , Intents . FLAGS . GUILD_VOICE_STATES , ] ) ; super ( { intents : intents , partials : [ "CHANNEL" ] } ) ; this . commands = new Collection ( ) ; this . aliases = new Collection ( ) ; this . categories = fs . readdirSync ( __dirname + "/../commands" ) ; this . interactiveCommands = new Collection ( ) ; Deps . buildDB ( this , DBEvent , DBGuild , DBMember , DBMessage , DBPoll , DBReminder , DBRoleMenu , DBSoundEffect , DBUser ) ; this . player = new Player ( this , { ytdlOptions : { filter : "audioonly" , highWaterMark : 1 << 25 , } , } ) ; this . player . unuse ( "Attachment" ) ; this . player . unuse ( "Facebook" ) ; this . player . unuse ( "Reverbnation" ) ; this . player . unuse ( "Vimeo" ) ; this . player . use ( "YOUTUBE_DL" , youtubeDownloader ) ; this . gameMembers = new Map ( ) ; this . activeEmojiStealing = new Set ( ) ; this . waitingResponse = new Set ( ) ; this . guildInvites = new Map ( ) ; this . discordTogether = new DiscordTogether ( this ) ; import ( "../utils/mongoose" ) . then ( ( module ) => { module . init ( ) ; } ) ; this . databaseCache = { settings : new Collection ( ) , events : new Collection ( ) , roleMenus : new Collection ( ) , soundEffects : new Collection ( ) , memberSoundEffects : new Collection ( ) , } ; import ( "../handlers/commands" ) . then ( async ( module ) => { await module . default ( this ) ; import ( "../handlers/events" ) . then ( async ( module ) => { await module . default ( this ) ; } ) ; } ) ; } }