1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-18 00:31:00 -05:00

Compare commits

..

No commits in common. "c88c252d991e0dc79ea383534afe7a4c508c05cd" and "d434507b9b42857635961903f307415f9d0bc4dd" have entirely different histories.

8 changed files with 33 additions and 23 deletions

1
.gitignore vendored
View File

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

View File

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

View File

@ -6,7 +6,7 @@ const RedisClient = createClient({
url: (await TSClient()).redis_uri, url: (await TSClient()).redis_uri,
database: 0, database: 0,
name: 'Daggerbot', name: 'Daggerbot',
socket: { keepAlive: 15000, timeout: 30000, reconnectStrategy(retries:number = 5) {return Math.min(retries * 76, 1000)} } socket: { keepAlive: 15000, timeout: 30000 }
}); });
export default class CacheServer { export default class CacheServer {
@ -14,7 +14,16 @@ export default class CacheServer {
protected static eventManager() { protected static eventManager() {
RedisClient RedisClient
.on('connect', ()=>Logger.console('log', this.prefix, 'Connection to Redis has been established')) .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}`)) .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)
})
} }
public static async get(key:any, jsonMode:boolean):Promise<any> { public static async get(key:any, jsonMode:boolean):Promise<any> {
let cachedResult:any; let cachedResult:any;

View File

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