aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-08-29 19:53:53 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-08-29 19:53:53 -0400
commit800668f3e0fec80f3ba08f115d9563324bc54045 (patch)
tree6a210bcfafbdd82382dab1dc18a7e2aca93e42de
parentd941214503812267415db570f646cc69bc22664d (diff)
downloadtanzanite-800668f3e0fec80f3ba08f115d9563324bc54045.tar.gz
tanzanite-800668f3e0fec80f3ba08f115d9563324bc54045.tar.bz2
tanzanite-800668f3e0fec80f3ba08f115d9563324bc54045.zip
deploy stuff
-rw-r--r--config/Config.ts13
-rw-r--r--config/example-options.ts1
-rw-r--r--ecosystem.config.cjs10
-rw-r--r--lib/extensions/discord-akairo/TanzaniteClient.ts7
-rw-r--r--lib/utils/BotClientUtils.ts5
-rw-r--r--lib/utils/UpdateCache.ts2
6 files changed, 26 insertions, 12 deletions
diff --git a/config/Config.ts b/config/Config.ts
index 4aae10a..90d4428 100644
--- a/config/Config.ts
+++ b/config/Config.ts
@@ -51,7 +51,7 @@ export class Config implements ConfigOptions {
this.credentials = options.credentials;
this.environment = options.environment;
this.owners = options.owners;
- this.prefix = options.prefix;
+ this.prefix = typeof options.prefix === 'string' ? options.prefix : options.prefix[this.environment];
this.channels = options.channels;
this.db = options.db;
this.logging = options.logging;
@@ -118,7 +118,7 @@ export interface ConfigOptions {
/**
* A string that needs to come before text commands.
*/
- prefix: string;
+ prefix: EnvironmentMap<string>;
/**
* Various discord channels that logs will be sent in.
@@ -210,7 +210,7 @@ export type Channels = {
* The id of a channel to send logging messages in,
* use an empty string for no channel to be used.
*/
- [Key in ConfigChannelKey]: Snowflake | '';
+ [Key in ConfigChannelKey]: EnvironmentMap<Snowflake | ''>;
};
/**
@@ -223,6 +223,11 @@ export type ConfigChannelKey = 'log' | 'error' | 'dm' | 'servers';
*/
export interface DataBase {
/**
+ * Ex. "tanzanite" would use the databases "tanzanite", "tanzanite-beta", "tanzanite-dev", and "tanzanite-shared".
+ */
+ databasePrefix: string;
+
+ /**
* The host of the database.
*/
host: string;
@@ -272,3 +277,5 @@ export interface SupportGuild {
*/
invite: string | null;
}
+
+export type EnvironmentMap<T> = T | { [Key in Environment]: T };
diff --git a/config/example-options.ts b/config/example-options.ts
index 43b805e..903928d 100644
--- a/config/example-options.ts
+++ b/config/example-options.ts
@@ -26,6 +26,7 @@ export default new Config({
servers: '1000000000000000'
},
db: {
+ databasePrefix: 'tanzanite',
host: 'localhost',
port: 5432,
username: '[USER_NAME]',
diff --git a/ecosystem.config.cjs b/ecosystem.config.cjs
index 32971cf..ce407cb 100644
--- a/ecosystem.config.cjs
+++ b/ecosystem.config.cjs
@@ -4,8 +4,8 @@ module.exports = {
name: `tanzanite${e}`,
script: 'yarn',
args: 'start:raw',
- out_file: `../bushbot${e}.log`,
- error_file: `../bushbot${e}.log`,
+ out_file: `../tanzanite${e}.log`,
+ error_file: `../tanzanite${e}.log`,
max_memory_restart: '1G',
node_args: ['--max_old_space_size=2048'],
env: { FORCE_COLOR: '3' },
@@ -19,11 +19,11 @@ module.exports = {
['production', 'beta'].map((e) => [
e,
{
- 'user': 'pi',
- 'host': '192.168.1.210',
+ 'user': 'ironmoon',
+ 'host': '192.168.1.11',
'ref': `origin/${e === 'production' ? 'master' : 'beta'}`,
'repo': 'https://github.com/TanzaniteBot/tanzanite.git',
- 'path': `/code/bush-bot${e === 'beta' ? '-beta' : ''}`,
+ 'path': `/code/tanzanite${e === 'beta' ? '-beta' : ''}`,
'post-deploy': `yarn install && yarn build && pm2 start ecosystem.config.cjs --only tanzanite${
e === 'beta' ? '-beta' : ''
}`
diff --git a/lib/extensions/discord-akairo/TanzaniteClient.ts b/lib/extensions/discord-akairo/TanzaniteClient.ts
index 24ce962..fe34b58 100644
--- a/lib/extensions/discord-akairo/TanzaniteClient.ts
+++ b/lib/extensions/discord-akairo/TanzaniteClient.ts
@@ -347,13 +347,16 @@ export class TanzaniteClient<Ready extends boolean = boolean> extends AkairoClie
logging: this.config.logging.db ? (sql) => this.logger.debug(sql) : false,
timezone: 'America/New_York'
};
+
+ const prefix = this.config.db.databasePrefix;
+
this.instanceDB = new Sequelize({
...sharedDBOptions,
- database: this.config.isDevelopment ? 'bushbot-dev' : this.config.isBeta ? 'bushbot-beta' : 'bushbot'
+ database: this.config.isDevelopment ? `${prefix}-dev` : this.config.isBeta ? `${prefix}-beta` : prefix
});
this.sharedDB = new Sequelize({
...sharedDBOptions,
- database: 'bushbot-shared'
+ database: `${prefix}-shared`
});
this.sentry = Sentry;
diff --git a/lib/utils/BotClientUtils.ts b/lib/utils/BotClientUtils.ts
index a251bdf..1dd46bf 100644
--- a/lib/utils/BotClientUtils.ts
+++ b/lib/utils/BotClientUtils.ts
@@ -469,7 +469,10 @@ export class BotClientUtils {
if (!(channel in channels))
throw new TypeError(`Invalid channel provided (${channel}), must be one of ${Object.keys(channels).join(' ')}`);
- const channelId = channels[channel];
+ const channelConfig = channels[channel];
+ const environment = this.client.config.environment;
+
+ const channelId = typeof channelConfig === 'string' ? channelConfig : channelConfig[environment];
if (channelId === '') return null;
const res = await this.client.channels.fetch(channelId);
diff --git a/lib/utils/UpdateCache.ts b/lib/utils/UpdateCache.ts
index 2f96d9d..0e39344 100644
--- a/lib/utils/UpdateCache.ts
+++ b/lib/utils/UpdateCache.ts
@@ -14,7 +14,7 @@ export async function updateGlobalCache(client: Client) {
}
export async function updateSharedCache(client: Client) {
- const row: { [x: string]: any } = ((await Shared.findByPk(0)) ?? (await Shared.create())).toJSON();
+ const row: { [x: string]: any } = ((await Shared.findByPk(0)) ?? (await Shared.create({ primaryKey: 0 }))).toJSON();
for (const option in row) {
if (Object.keys(client.cache.shared).includes(option)) {