edited premium

pull/11/head
TheCodedProf 3 years ago
parent a35b71b859
commit fc420b79d0

@ -42,14 +42,20 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
count = 3; count = 3;
} }
const closed = false; const hasPremium = await client.database.premium.hasPremium(interaction.guild!.id);
let premiumGuild = ""
if (hasPremium) {
premiumGuild = `\n\n**This server has premium!**`
}
let closed = false;
do { do {
interaction.editReply({ interaction.editReply({
embeds: [ embeds: [
new EmojiEmbed() new EmojiEmbed()
.setTitle("Premium") .setTitle("Premium")
.setDescription( .setDescription(
premium + firstDescription premium + firstDescription + premiumGuild
) )
.setEmoji("NUCLEUS.LOGO") .setEmoji("NUCLEUS.LOGO")
.setStatus("Danger") .setStatus("Danger")
@ -61,15 +67,55 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
.setStyle(ButtonStyle.Primary) .setStyle(ButtonStyle.Primary)
.setLabel("Activate Premium here") .setLabel("Activate Premium here")
.setCustomId("premiumActivate") .setCustomId("premiumActivate")
.setDisabled(count <= 0) .setDisabled(count <= 0 && hasPremium)
) )
] ]
}); });
const filter = (i: any) => i.customId === "premiumActivate" && i.user.id === interaction.user.id; const filter = (i: any) => i.customId === "premiumActivate" && i.user.id === interaction.user.id;
const collector = interaction.channel?.awaitMessageComponent({ filter, time: 60000 }); let i;
try {
i = await interaction.channel!.awaitMessageComponent({ filter, time: 60000 });
} catch (e) {
return;
}
if (i) {
i.deferUpdate();
let guild = i.guild!;
let m = await client.database.premium.fetchTotal(interaction.user.id);
if (count - m <= 0) {
interaction.editReply({
embeds: [
new EmojiEmbed()
.setTitle("Premium")
.setDescription(
`You have already activated premium on the maximum amount of servers!` + firstDescription
)
.setEmoji("NUCLEUS.LOGO")
.setStatus("Danger")
],
components: []
});
closed = true;
} else {
client.database.premium.addPremium(interaction.user.id, guild.id);
interaction.editReply({
embeds: [
new EmojiEmbed()
.setTitle("Premium")
.setDescription(
`You have activated premium on this server!` + firstDescription
)
.setEmoji("NUCLEUS.LOGO")
.setStatus("Danger")
],
components: []
});
closed = true;
}
}
} while (closed); } while (!closed);
}; };
const check = () => { const check = () => {

@ -12,7 +12,7 @@ import type { GuildConfig } from "../../utils/database.js";
const command = (builder: SlashCommandSubcommandBuilder) => const command = (builder: SlashCommandSubcommandBuilder) =>
builder builder
.setName("stats") .setName("oldstats")
.setDescription("Controls channels which update when someone joins or leaves the server") .setDescription("Controls channels which update when someone joins or leaves the server")
type ChangesType = Record<string, { name?: string; enabled?: boolean; }> type ChangesType = Record<string, { name?: string; enabled?: boolean; }>

@ -15,3 +15,6 @@ process.on("uncaughtException", (err) => { console.error(err) });
await client.login(config.enableDevelopment ? config.developmentToken : config.token) await client.login(config.enableDevelopment ? config.developmentToken : config.token)
await recordPerformance(); await recordPerformance();
import { getCommandMentionByName} from "./utils/getCommandMentionByName.js";
console.log(await getCommandMentionByName("nucleus/premium"))

@ -217,9 +217,13 @@ export class Premium {
return entry.appliesTo.length; return entry.appliesTo.length;
} }
setPremium(user: string, guild: string) { addPremium(user: string, guild: string) {
return this.premium.updateOne({ user: user }, { $addToSet: { appliesTo: guild } }, { upsert: true }); return this.premium.updateOne({ user: user }, { $addToSet: { appliesTo: guild } }, { upsert: true });
} }
removePremium(user: string, guild: string) {
return this.premium.updateOne({ user: user }, { $pull: { appliesTo: guild } });
}
} }
export interface GuildConfig { export interface GuildConfig {

Loading…
Cancel
Save