import {Events, GatewayIntentBits, Partials, ActivityType} from 'discord.js'; import {createServer} from 'http'; // Global config import {config} from './config'; // Classes import {ExtendedClient} from './classes/extendedclient' // Initialization functions import {setNickname} from './init/set-nickname'; import {loadCommands} from './init/load-commands'; import {registerCommands} from './init/register-commands'; import {sendReadyDM} from './init/ready-dm'; // Event-handling functions import {handleCommands} from './events/handle-commands'; import {handleGiveaway} from './events/handle-giveaway'; import {handleRoleAdd, handleRoleRemove} from './events/handle-auto-roles'; import {handleReactImage} from './events/handle-react-image'; // Sub-services import {logger} from './logger'; import {runMongo} from './mongo'; const client = new ExtendedClient({ intents:[ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildModeration, GatewayIntentBits.GuildEmojisAndStickers, GatewayIntentBits.GuildIntegrations, GatewayIntentBits.GuildWebhooks, GatewayIntentBits.GuildInvites, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildPresences, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildMessageReactions, GatewayIntentBits.GuildMessageTyping, GatewayIntentBits.DirectMessages, GatewayIntentBits.DirectMessageReactions, GatewayIntentBits.DirectMessageTyping, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildScheduledEvents, GatewayIntentBits.AutoModerationConfiguration, GatewayIntentBits.AutoModerationExecution, ], partials:[ Partials.User, Partials.Channel, Partials.GuildMember, Partials.Message, Partials.Reaction, Partials.GuildScheduledEvent, Partials.ThreadMember, ] }); client.login(config.token); // Event handling client.on(Events.InteractionCreate, handleCommands); client.on(Events.MessageReactionAdd, handleGiveaway); client.on(Events.MessageReactionAdd, handleRoleAdd); client.on(Events.MessageReactionRemove, handleRoleRemove); client.on(Events.MessageCreate, handleReactImage); // Initialization client.once(Events.ClientReady, async c => { logger.info(`Logged in as ${c.user.tag}`); if(client.user){ client.user.setPresence({ activities: [{ name: '天使☆騒々 RE-BOOT!', type: ActivityType.Playing, }], status: 'online' }); logger.info('Set status done'); } await setNickname(client); logger.info(`Set nickname as ${config.nickname}`); const commands = await loadCommands(client); logger.info(`${commands.length} commands loaded.`); const regCmdCnt = await registerCommands(commands); logger.info(`${regCmdCnt} commands registered.`); await runMongo(); logger.info(`Database ready`); logger.info(`Ready!`); await sendReadyDM(client, config.adminId); });