3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 20:35:02 +00:00

Store supporters in the database

This commit is contained in:
Dragory 2020-05-28 01:29:51 +03:00
parent cb4beacf8a
commit f9568ab37b
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
4 changed files with 89 additions and 17 deletions

View file

@ -76,6 +76,7 @@ declare global {
}
import { Url, URL, URLSearchParams } from "url";
import { Supporters } from "../data/Supporters";
const ConfigSchema = t.type({
can_roles: t.boolean,
can_level: t.boolean,
@ -137,6 +138,7 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
protected cases: GuildCases;
protected savedMessages: GuildSavedMessages;
protected archives: GuildArchives;
protected supporters: Supporters;
protected lastFullMemberRefresh = 0;
protected fullMemberRefreshPromise;
@ -199,6 +201,7 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
this.cases = GuildCases.getGuildInstance(this.guildId);
this.savedMessages = GuildSavedMessages.getGuildInstance(this.guildId);
this.archives = GuildArchives.getGuildInstance(this.guildId);
this.supporters = new Supporters();
this.lastReload = Date.now();
@ -1495,38 +1498,41 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
const loadedPlugins = Array.from(this.knub.getGuildData(this.guildId).loadedPlugins.keys());
loadedPlugins.sort();
const supporters = [
["Flokie", 10],
["CmdData", 1],
["JackDaniel", 1],
];
supporters.sort(sorter(r => r[1], "DESC"));
const aboutContent: MessageContent = {
embed: {
title: `About ${this.bot.user.username}`,
fields: [
{
name: "Status",
value:
basicInfoRows
.map(([label, value]) => {
return `${label}: **${value}**`;
})
.join("\n") + embedPadding,
value: basicInfoRows
.map(([label, value]) => {
return `${label}: **${value}**`;
})
.join("\n"),
},
{
name: `Loaded plugins on this server (${loadedPlugins.length})`,
value: loadedPlugins.join(", "),
},
{
name: "Zeppelin supporters 🎉",
value: supporters.map(s => `**${s[0]}** ${s[1]}€/mo`).join("\n"),
},
],
},
};
const supporters = await this.supporters.getAll();
supporters.sort(
multiSorter([
[r => r.amount, "DESC"],
[r => r.name.toLowerCase(), "ASC"],
]),
);
if (supporters.length) {
aboutContent.embed.fields.push({
name: "Zeppelin supporters 🎉",
value: supporters.map(s => `**${s.name}** ${s.amount && `${s.amount}€/mo`}`).join("\n"),
});
}
// For the embed color, find the highest colored role the bot has - this is their color on the server as well
const botMember = await resolveMember(this.bot, this.guild, this.bot.user.id);
let botRoles = botMember.roles.map(r => (msg.channel as GuildChannel).guild.roles.get(r));