Bläddra i källkod

Add config

Config is for setting up bot on first start.
master
TheoryOfNekomata 1 månad sedan
förälder
incheckning
d6b1e0eba6
3 ändrade filer med 11 tillägg och 4 borttagningar
  1. +5
    -0
      packages/discord-bot/.env.example
  2. +1
    -0
      packages/discord-bot/src/config.ts
  3. +5
    -4
      packages/discord-bot/src/index.ts

+ 5
- 0
packages/discord-bot/.env.example Visa fil

@@ -0,0 +1,5 @@
# Discord bot token. The bot must be added to the server first.
DISCORD_BOT_TOKEN=

# Channel ID of the forum to proxy comments.
DISCORD_FORUM_CHANNEL_ID=

+ 1
- 0
packages/discord-bot/src/config.ts Visa fil

@@ -6,4 +6,5 @@ export namespace meta {
GatewayIntentBits.Guilds | GatewayIntentBits.GuildMessages | GatewayIntentBits.MessageContent
);
export const token = process.env.DISCORD_BOT_TOKEN as string;
export const channelId = process.env.DISCORD_FORUM_CHANNEL_ID as string;
}

+ 5
- 4
packages/discord-bot/src/index.ts Visa fil

@@ -5,7 +5,7 @@ import {ForumChannel} from 'discord.js';
import {setupThreads} from './modules/thread';
import {BotContext} from './common';

const main = async (channelId: string) => {
const main = async () => {
const client = createClient({
intents: config.meta.intentsInteger,
});
@@ -28,9 +28,9 @@ const main = async (channelId: string) => {
}
console.log(`Logged in as ${client.user.tag}`);

const channel = await client.channels.fetch(channelId);
const channel = await client.channels.fetch(config.meta.channelId);
if (!(channel instanceof ForumChannel)) {
console.error(`Channel ${channelId} is not a forum!`);
console.error(`Channel ${config.meta.channelId} is not a forum!`);
return;
}

@@ -43,4 +43,5 @@ const main = async (channelId: string) => {
}

// TODO load channelId from config
void main('1244285168580300904');
// TODO add discord wizard for chatting with bot for setup (e.g. selecting forum channel ID)
void main();

Laddar…
Avbryt
Spara