This repository has been archived by the owner on Oct 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eb63248
commit 11e5ab8
Showing
5 changed files
with
951 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
METEORIUM_POSTGRES_URL= | ||
METEORIUM_BOT_TOKEN= | ||
METEORIUM_APPLICATION_ID= | ||
METEORIUM_HOLODEX_TOKEN= | ||
METEORIUM_HOLODEX_APIKEY= | ||
METEORIUM_GENIUS_APIKEY= | ||
METEORIUM_APPDEPLOY_GUILDIDS= | ||
METEORIUM_RUNTIMELOG_CHANNELIDS= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Client } from "discord.js"; | ||
import { config } from "dotenv"; | ||
import { PrismaClient } from "@prisma/client"; | ||
import { HolodexApiClient } from "holodex.js"; | ||
|
||
import Logging from "./logging.js"; | ||
|
||
function parseDotEnvConfig() { | ||
if (!process.env.METEORIUM_BOT_TOKEN) config(); | ||
return { | ||
BotToken: String(process.env.METEORIUM_BOT_TOKEN), | ||
ApplicationId: String(process.env.METEORIUM_APPLICATION_ID), | ||
HolodexApiKey: String(process.env.METEORIUM_HOLODEX_APIKEY), | ||
GeniusApiKey: String(process.env.METEORIUM_GENIUS_APIKEY), | ||
ApplicationDeployGuildIds: String(process.env.METEORIUM_APPDEPLOY_GUILDIDS).split(","), | ||
RuntimeLogChannelIds: String(process.env.METEORIUM_RUNTIMELOG_CHANNELIDS).split(","), | ||
}; | ||
} | ||
|
||
export default class MeteoriumClient extends Client<true> { | ||
public logging = new Logging("Meteorium"); | ||
public config = parseDotEnvConfig(); | ||
public db = new PrismaClient(); | ||
public holodex = new HolodexApiClient({ apiKey: this.config.HolodexApiKey }); | ||
|
||
public async login() { | ||
const loginNS = this.logging.getNamespace("Login"); | ||
loginNS.info("Logging in to Discord"); | ||
return super.login(this.config.BotToken); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
import Logging from "./classes/logging.js"; | ||
import MeteoriumClient from "./classes/client.js"; | ||
import { IntentsBitField } from "discord.js"; | ||
|
||
const logging = new Logging("Meteorium"); | ||
const mainNS = logging.registerNamespace("Main"); | ||
mainNS.info("Hello, world!"); | ||
const client = new MeteoriumClient({ | ||
intents: [ | ||
IntentsBitField.Flags.Guilds, | ||
IntentsBitField.Flags.GuildMembers, | ||
IntentsBitField.Flags.GuildMessages, | ||
IntentsBitField.Flags.GuildModeration, | ||
IntentsBitField.Flags.GuildVoiceStates, | ||
], | ||
}); | ||
|
||
await client.login(); |
Oops, something went wrong.