Skip to content
This repository was archived by the owner on Jul 7, 2024. It is now read-only.

Commit

Permalink
config: updated default
Browse files Browse the repository at this point in the history
  • Loading branch information
zleyyij committed Jul 21, 2023
1 parent be68f46 commit f9e11a7
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 131 deletions.
55 changes: 51 additions & 4 deletions config.default.jsonc
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
{
/**
* https://discord.com/developers/docs/topics/oauth2
* https://discord.com/developers
* create new application -> bot -> new bot user -> oath2 -> bot -> administrator -> copy link
* rememember to set your bot intents
*/
"authToken": "your-auth-token",
"applicationId": "",
// database configuration
"mongodb": {
// These are filled out using the settings from `k8s/dev.yaml`, but should probably
// be set to something different in prod
// login code *probably* needs to be changed if you're using atlas
"address": "mongodb.default.svc.cluster.local",
"username": "root",
"password": "root"
},
// Specifically event logging
"logging": {
/**
* Different levels of verbose logging.
Expand All @@ -14,16 +32,45 @@
* 4:
*/
"stdout": {
"verboseLevel": 2
"verboseLevel": 3
},
// It is an option to have the bot DM certain users for events, it's suggested to leave this disabled or on a very low level.
"directMessageLogging": {
"userIds": [],
"verboseLevel": 0
"userIds": [""],
"verboseLevel": 1
},

"loggingChannel": {
"loggingChannelId": "",
"verboseLevel": 2
"verboseLevel": 3
}
},

"testing": {
// The user ID for the bot test user
"userID": ""
},

// The key for each module should match the one specified in the root module initialization
// if the `enabled` key is missing, the extension will be disabled by default, and a warning issued
"modules": {
"logging": {
"enabled": true,
// each channel ID paired with a respecting logging channel, if it's not specified here
// messages from that channel will silently not be logged,
"loggingCategory": "",
// this can be filled automatically with `logging populate` if `loggingCategory` is set
// communication channel on the left, logging channel on the right
"channelMap": {
},
// this map contains a list of channels that will not be logged. also populated by `logging populate`
"channelBlacklist": [
]
},
"factoid": {
"enabled": true,
// a list of characters that can be used as a prefix to trigger a factoid
"prefixes": ["?"]
}
}
}
113 changes: 0 additions & 113 deletions k8s/dev.yaml

This file was deleted.

26 changes: 26 additions & 0 deletions k8s/dev/bot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: turingbot
labels:
name: turingbot
spec:
replicas: 1
# Selector and template are basically specifying "when i want to take an action, what do i want to target?"
# in this case, we only want to target *this* container
selector:
matchLabels:
name: turingbot
template:
metadata:
labels:
name: turingbot
spec:
containers:
- name: turingbot
image: turingbot
imagePullPolicy: Never
resources:
limits:
memory: '512Mi'
cpu: '500m'
35 changes: 35 additions & 0 deletions k8s/dev/mongo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: v1
kind: Service
metadata:
name: mongodb
spec:
type: ClusterIP
selector:
name: mongodb
ports:
- port: 27017
targetPort: 27017
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mongodb
spec:
serviceName: mongodb
replicas: 1
selector:
matchLabels:
name: mongodb
template:
metadata:
labels:
name: mongodb
spec:
containers:
- name: mongodb
image: mongo:6.0
env:
- name: MONGO_INITDB_ROOT_USERNAME
value: root
- name: MONGO_INITDB_ROOT_PASSWORD
value: root
12 changes: 11 additions & 1 deletion src/core/discord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import {
ButtonStyle,
ChatInputCommandInteraction,
Collection,
Client,
Message,
REST,
RESTPostAPIChatInputApplicationCommandsJSONBody,
Routes,
GatewayIntentBits,
SlashCommandAttachmentOption,
SlashCommandBooleanOption,
SlashCommandBuilder,
Expand All @@ -28,7 +30,7 @@ import {
SlashCommandUserOption,
} from 'discord.js';

import {client, guild, modules} from './main.js';
import {modules, guild} from './main.js';
import {ModuleInputOption, ModuleOptionType, RootModule} from './modules.js';
import {botConfig} from './config.js';
import {EventCategory, logEvent} from './logger.js';
Expand All @@ -53,6 +55,14 @@ type SlashCommandOption =
| SlashCommandStringOption
| SlashCommandUserOption;

export const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
});

/**
* Helper utilities used to speed up embed work
*/
Expand Down
2 changes: 1 addition & 1 deletion src/core/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import chalk from 'chalk';

import {botConfig} from './config.js';
import {client} from './main.js';
import {client} from './discord.js';
import {APIEmbed, TextChannel} from 'discord.js';

/**
Expand Down
12 changes: 1 addition & 11 deletions src/core/main.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import {readdirSync, Dirent} from 'fs';
import {
APIEmbedField,
Client,
Events,
GatewayIntentBits,
APIEmbed,
Guild,
ChatInputCommandInteraction,
Expand All @@ -14,6 +12,7 @@ import {botConfig} from './config.js';
import {EventCategory, logEvent} from './logger.js';
import {RootModule, SubModule} from './modules.js';
import {
client,
embed,
generateSlashCommandForModule,
registerSlashCommandSet,
Expand All @@ -23,15 +22,6 @@ import {fileURLToPath} from 'url';

// TODO: re-organize the core to take advantage of typescript namespaces (https://www.typescriptlang.org/docs/handbook/namespaces.html).

/** @see {@link https://discord.js.org/docs/packages/builders/stable/RoleSelectMenuBuilder:Class#/docs/discord.js/main/class/Client } */
export const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
});

/**
* `GuildMember` is the server specific object for a `User`, so that's fetched
* to get info like nickname, and perform administrative tasks on a user.
Expand Down
2 changes: 1 addition & 1 deletion src/modules/factoids/factoids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ factoid.registerSubModule(
// NOTE: THE BELOW IS TEMPORARY AS A TEST
const ping = new util.SubModule('ping', 'ping the ping');
const pong = new util.SubModule('pong', 'pong the pong', [], async () => {
console.log('hee heee');
console.log('hee hee');
});
factoid.registerSubModule(ping);
ping.registerSubmodule(pong);
Expand Down
3 changes: 3 additions & 0 deletions src/test/main.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {describe, it} from 'node:test';
// dynamic import statements are used to avoid side affects
// this is all broken

0 comments on commit f9e11a7

Please sign in to comment.