mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 16:30:58 -05:00
Compare commits
No commits in common. "08115380f88f39d41bc53120fd2814deb9168fb4" and "fcfd11431a5ef56ddf420e56011771df2a37e126" have entirely different histories.
08115380f8
...
fcfd11431a
@ -55,6 +55,9 @@ export class MPServerSvc {
|
||||
})
|
||||
this.model.sync();
|
||||
}
|
||||
async getServers() {
|
||||
return await this.model.findAll();
|
||||
}
|
||||
async fetchPlayerData(serverName:string) {
|
||||
const findServerByName = await this.model.findOne({where: {serverName: serverName}});
|
||||
if (findServerByName) return findServerByName.dataValues.playerData;
|
||||
@ -115,4 +118,14 @@ export class MPServerSvc {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
async getServerData(serverName:string):Promise<IServer> {
|
||||
return new Promise(async resolve=>{
|
||||
const serverInfo = await this.findInCache();
|
||||
|
||||
for (let i = 0; i < serverInfo.length; i++) {
|
||||
if (serverInfo[i].serverName === serverName) resolve(serverInfo[i]);
|
||||
break;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,10 @@ export class DailyMsgsSvc {
|
||||
return await this.model.findAll();
|
||||
// Fetch every rows from database.
|
||||
}
|
||||
async fetchSpecificDay(dayId:number) {
|
||||
return await this.model.findOne({where: {day: dayId}});
|
||||
// Fetch a specific row from database by id column.
|
||||
}
|
||||
async newDay(formattedDate:number, total:number) {
|
||||
if (await this.model.findOne({where: {day: formattedDate}})) return console.log('This day already exists!')
|
||||
return await this.model.create({day: formattedDate, total: total});
|
||||
|
@ -112,9 +112,8 @@ async function multifarmWebhook(client:TClient, server:IServer, webhookId:string
|
||||
}
|
||||
};
|
||||
const getMappedValue =<T>(map:Record<string, T>, key:string, fallback:T):T=>map[key] ?? fallback;
|
||||
const data = await requestServerData(client, server);
|
||||
if (!data) return Logger.console('log', loggingPrefix, 'Couldn\'t get data for webhook');
|
||||
const {csg} = data;// :tutelBRUH: (https://cdn.discordapp.com/emojis/1155276126176956486.webp)
|
||||
const {csg} = await requestServerData(client, server);
|
||||
if (!csg) return Logger.console('log', loggingPrefix, 'Couldn\'t get data for webhook');
|
||||
const fields:Discord.APIEmbedField[] = [
|
||||
{name: 'Seasonal Growth', value: getMappedValue(txtMapping.growthMode, csg?.settings.growthMode, dataUnavailable), inline: true},
|
||||
{name: 'Crop Destruction', value: getMappedValue(txtMapping.genericBools, csg?.settings.fruitDestruction, dataUnavailable), inline: true},
|
||||
|
Loading…
Reference in New Issue
Block a user