1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-17 16: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

View File

@ -116,7 +116,7 @@ jobs:
core.setFailed('Failed to create combined branch - maybe a branch by that name already exists?');
return;
}
let combinedPRs = [];
let mergeFailedPRs = [];
for(const { branch, prString } of branchesAndPRStrings) {
@ -134,7 +134,7 @@ jobs:
mergeFailedPRs.push(prString);
}
}
console.log('Creating combined PR');
const combinedPRsString = combinedPRs.join('\n');
let body = '✅ This PR was created by the Combine Dependabot PRs action by combining the following PRs:\n' + combinedPRsString;

1
.gitignore vendored
View File

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

View File

@ -7,7 +7,7 @@ This is a repository for V3 revision that has been transitioned and rewritten fr
This revision took **4 months** (Late September to Mid December) working on and off to do literally everything that needed a rewrite so badly that it cannot be done in V2.
**Q:** So what are the changes if it almost looks the same as V2?
**Q:** So what are the changes if it almost looks the same as V2?
**A:** Here's the bullet points of the changes so far;
- Reworked some of the files
- Commands and events are now classes

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

@ -1,7 +1,7 @@
import Discord from 'discord.js';
import TClient from '../client.js';
export default class GuildMemberAdd {
static async run(client:TClient, member:Discord.GuildMember){
static async run(client:TClient, member:Discord.GuildMember){
if (member.partial || member.guild?.id != client.config.dcServer.id) return;
const index = member.guild.memberCount;
const suffix = (index=>{

View File

@ -15,7 +15,7 @@ export default class FormatPlayer {
Days = Math.floor(Hours/24);
Hours = Hours-Days*24;
}
return (Days > 0 ? Days+' d ':'')+(Hours > 0 ? Hours+' h ':'')+(Minutes > 0 ? Minutes+' m':'')
}
static decoratePlayerIcons(player:FSPlayer) {

View File

@ -7,22 +7,20 @@ 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)) {
(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}\`\`\``));
}
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)) {
let passwordText = 'The farm password is ';
const mapping = {
'1149138133514981386': 'koops',
'1149138202662293555': 'junkers'
}
for (const [channelId, farmPw] of Object.entries(mapping)) {
if (message.channelId === channelId) message.reply(passwordText += `\`${farmPw}\``);
}
if (!this.SenseTrigger(message, trigger)) return;
let passwordText = 'The farm password is ';
const mapping = {
'1149138133514981386': 'koops',
'1149138202662293555': 'junkers'
}
for (const [channelId, farmPw] of Object.entries(mapping)) {
if (message.channelId === channelId) message.reply(passwordText += `\`${farmPw}\``);
}
}
}