mirror of
https://github.com/Burn-E99/TheArtificer.git
synced 2026-06-04 00:53:50 -04:00
Implemented botlist statistic updates
config.example.ts - added botlist object(s), adjusted emoji default values since the ID won't be the same for anyone who spins this up themselves deps.ts - added botID mod.ts - Added calling of new updateListStatistics for non-local bots README.md - Added support invite link, fixed some tab vs spaces issues, added mention of development plans on the milestones pge, linked Deno and Discordeno intervals.ts - Added updateListStatistics function
This commit is contained in:
@@ -33,4 +33,23 @@ const getRandomStatus = (cache: CacheData): string => {
|
||||
return status;
|
||||
};
|
||||
|
||||
export default { getRandomStatus };
|
||||
// updateListStatistics(bot ID, current guild count) returns nothing
|
||||
// Sends the current server count to all bot list sites we are listed on
|
||||
const updateListStatistics = (botID: string, serverCount: number): void => {
|
||||
config.botLists.forEach(async e => {
|
||||
if (e.enabled) {
|
||||
const tempHeaders = new Headers();
|
||||
tempHeaders.append(e.headers[0].header, e.headers[0].value);
|
||||
tempHeaders.append("Content-Type", "application/json");
|
||||
// ?{} is a template used in config, just need to replace it with the real value
|
||||
const response = await fetch(e.apiUrl.replace("?{bot_id}", botID), {
|
||||
"method": 'POST',
|
||||
"headers": tempHeaders,
|
||||
"body": JSON.stringify(e.body).replace('"?{server_count}"', serverCount.toString()) // ?{server_count} needs the "" removed from around it aswell to make sure its sent as a number
|
||||
});
|
||||
console.log(response);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export default { getRandomStatus, updateListStatistics };
|
||||
|
||||
Reference in New Issue
Block a user