MCPcopy Index your code
hub / github.com/Linen-dev/linen.dev / initializeBot

Function initializeBot

packages/integration-discord/src/bot.ts:24–73  ·  view source on GitHub ↗
(botId: number, callback: () => void)

Source from the content-addressed store, hash-verified

22import { Logger } from './utils/logger';
23
24function initializeBot(botId: number, callback: () => void) {
25 const logger = new Logger(botId, 'initializeBot', 'initialization');
26
27 const bot = new Client({
28 intents: [
29 GatewayIntentBits.Guilds,
30 GatewayIntentBits.GuildMessages,
31 GatewayIntentBits.GuildMembers,
32 GatewayIntentBits.GuildMessageReactions,
33 GatewayIntentBits.MessageContent,
34 ],
35 });
36
37 bot.on(Events.ClientReady, () => {
38 logger.info({ bot: 'Ready!' });
39 });
40
41 bot.on(Events.ShardDisconnect, () => {
42 callback();
43 process.exit(1);
44 });
45
46 bot.on(Events.Error, (error) => {
47 logger.error({ error });
48 });
49
50 bot.on(Events.MessageCreate, onMessageCreate(botId));
51 bot.on(Events.MessageDelete, onMessageDelete(botId));
52 bot.on(Events.MessageUpdate, onMessageUpdate(botId));
53
54 // bot.on(Events.MessageReactionAdd, onMessageReactionAdd);
55 // bot.on(Events.MessageReactionRemove, onMessageReactionRemove);
56 // bot.on(Events.MessageReactionRemoveAll, onMessageReactionRemoveAll);
57 // bot.on(Events.MessageReactionRemoveEmoji, onMessageReactionRemoveEmoji);
58
59 // bot.on(Events.ChannelCreate, onChannelCreate(botId));
60 // bot.on(Events.ChannelUpdate, onChannelUpdate(botId));
61
62 bot.on(Events.ThreadCreate, onThreadCreate(botId));
63 bot.on(Events.ThreadUpdate, onThreadUpdate(botId));
64 // bot.on(Events.ThreadDelete, onThreadDelete(botId));
65
66 // bot.on(Events.UserUpdate, onUserUpdate(botId));
67
68 // bot.on(Events.GuildMemberAdd, onGuildMemberAdd(botId));
69 // bot.on(Events.GuildMemberRemove, onGuildMemberRemove(botId));
70 // bot.on(Events.GuildMemberUpdate, onGuildMemberUpdate(botId));
71
72 bot.login(getToken(botId));
73}
74
75export { initializeBot };

Callers 1

discord-bot.tsFile · 0.90

Calls 9

infoMethod · 0.95
errorMethod · 0.95
onMessageCreateFunction · 0.90
onMessageDeleteFunction · 0.90
onMessageUpdateFunction · 0.90
onThreadCreateFunction · 0.90
onThreadUpdateFunction · 0.90
getTokenFunction · 0.90
callbackFunction · 0.50

Tested by

no test coverage detected