/[sudobot]/branches/7.x/src/events/ReadyEvent.ts
ViewVC logotype

Annotation of /branches/7.x/src/events/ReadyEvent.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 577 - (hide annotations)
Mon Jul 29 18:52:37 2024 UTC (8 months ago) by rakinar2
File MIME type: application/typescript
File size: 2260 byte(s)
chore: add old version archive branches (2.x to 9.x-dev)
1 rakinar2 577 /**
2     * This file is part of SudoBot.
3     *
4     * Copyright (C) 2021-2023 OSN Developers.
5     *
6     * SudoBot is free software; you can redistribute it and/or modify it
7     * under the terms of the GNU Affero General Public License as published by
8     * the Free Software Foundation, either version 3 of the License, or
9     * (at your option) any later version.
10     *
11     * SudoBot is distributed in the hope that it will be useful, but
12     * WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU Affero General Public License for more details.
15     *
16     * You should have received a copy of the GNU Affero General Public License
17     * along with SudoBot. If not, see <https://www.gnu.org/licenses/>.
18     */
19    
20     import type Client from "../core/Client";
21     import EventListener from "../core/EventListener";
22     import { Events } from "../types/ClientEvents";
23     import { logError, logInfo, logWarn } from "../utils/logger";
24    
25     export default class ReadyEvent extends EventListener<Events.Ready> {
26     public readonly name = Events.Ready;
27    
28     async execute(client: Client<true>) {
29     logInfo("The bot has logged in.");
30    
31     await this.client.server.onReady();
32     this.client.server.start().catch(logError);
33     this.client.queueManager.onReady().catch(logError);
34     const homeGuild = await this.client.getHomeGuild();
35    
36     if (this.client.configManager.systemConfig.sync_emojis) {
37     try {
38     const emojis = await homeGuild.emojis.fetch();
39    
40     for (const [id, emoji] of emojis) {
41     if (!this.client.emojis.cache.has(id)) {
42     this.client.emojis.cache.set(id, emoji);
43     this.client.emojiMap.set(emoji.name ?? emoji.identifier, emoji);
44     }
45     }
46    
47     logInfo("Successfully synced the emojis of home guild.");
48     } catch (e) {
49     logError(e);
50     logWarn("Failed to fetch some of the emojis. The bot may not show some of the emojis in it's responses.");
51     }
52     }
53    
54     if (client.configManager.systemConfig.log_server?.auto_start) {
55     this.client.logServer.listen();
56     }
57    
58     super.execute(client);
59     }
60     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26