1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-17 20:30:58 -05:00

Compare commits

..

4 Commits

Author SHA1 Message Date
AnxietyisReal
c88c252d99 Trim the trailing whitespaces 2024-01-06 20:49:35 +11:00
AnxietyisReal
b151f04c48 Refactor CmdModule.ts 2024-01-06 20:49:12 +11:00
AnxietyisReal
1c3c14a159 Hide Postgres credentials 2024-01-06 18:09:29 +11:00
AnxietyisReal
543a84a433 Replace janky reconnect method with a reliable one from the package. 2024-01-06 18:03:26 +11:00
8 changed files with 23 additions and 33 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.env
# Yarn stuff
.yarn
# TypeScript stuff

View File

@ -14,6 +14,6 @@ services:
volumes:
- /var/lib/docker/volumes/daggerbot-db:/var/lib/postgresql/data:rw
environment:
POSTGRES_USER: daggerbot
POSTGRES_PASSWORD: dagbot
POSTGRES_DB: daggerbot
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}

View File

@ -6,7 +6,7 @@ const RedisClient = createClient({
url: (await TSClient()).redis_uri,
database: 0,
name: 'Daggerbot',
socket: { keepAlive: 15000, timeout: 30000 }
socket: { keepAlive: 15000, timeout: 30000, reconnectStrategy(retries:number = 5) {return Math.min(retries * 76, 1000)} }
});
export default class CacheServer {
@ -14,16 +14,7 @@ export default class CacheServer {
protected static eventManager() {
RedisClient
.on('connect', ()=>Logger.console('log', this.prefix, 'Connection to Redis has been established'))
.on('error', (err:ErrorReply)=>{
Logger.console('error', this.prefix, `Encountered an error in Redis: ${err.message}`)
setTimeout(async()=>{
if (!RedisClient.isReady) {
Logger.console('log', this.prefix, 'Client is zombified, starting a fresh connection...');
RedisClient.quit();
await RedisClient.connect();
}
}, 1500)
})
.on('error', (err:ErrorReply)=>Logger.console('error', this.prefix, `Encountered an error in Redis: ${err.message}`))
}
public static async get(key:any, jsonMode:boolean):Promise<any> {
let cachedResult:any;

View File

@ -7,14 +7,13 @@ export default class CmdTrigger {
return message.content.toLowerCase().startsWith(this.prefix+trigger)
}
static registerCmds(client:TClient, message:Message, trigger:string) {
if (this.SenseTrigger(message, trigger) && client.config.whitelist.includes(message.author.id)) {
if (!this.SenseTrigger(message, trigger) ?? !client.config.whitelist.includes(message.author.id)) return;
(client.guilds.cache.get(message.guildId) as Guild).commands.set(client.registry)
.then(()=>message.reply('Deployed the slash commands successfully!'))
.catch(e=>message.reply(`Failed to deploy slash commands:\n\`\`\`${e.message}\`\`\``));
}
}
static MFPwTrigger(message:Message, trigger:string) {
if (this.SenseTrigger(message, trigger)) {
if (!this.SenseTrigger(message, trigger)) return;
let passwordText = 'The farm password is ';
const mapping = {
'1149138133514981386': 'koops',
@ -25,4 +24,3 @@ export default class CmdTrigger {
}
}
}
}