big work today!

pull/11/head
TheCodedProf 3 years ago
parent 686829f2b6
commit 94ff6deb29

@ -1,2 +1,3 @@
Server rules Server rules
verificationRequired on welcome verificationRequired on welcome
!!Premium

@ -5,6 +5,7 @@ import keyValueList from "../../utils/generateKeyValueList.js";
import addPlurals from "../../utils/plurals.js"; import addPlurals from "../../utils/plurals.js";
import client from "../../utils/client.js"; import client from "../../utils/client.js";
import { LinkWarningFooter } from "../../utils/defaults.js"; import { LinkWarningFooter } from "../../utils/defaults.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
const command = (builder: SlashCommandSubcommandBuilder) => const command = (builder: SlashCommandSubcommandBuilder) =>
@ -133,6 +134,9 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
accountCreated: entry(member.user.createdTimestamp, renderDelta(member.user.createdTimestamp)), accountCreated: entry(member.user.createdTimestamp, renderDelta(member.user.createdTimestamp)),
serverMemberCount: interaction.guild.memberCount serverMemberCount: interaction.guild.memberCount
}, },
separate: {
end: getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) + ` The user was ${notify ? "" : "not "}notified`
},
hidden: { hidden: {
guild: interaction.guild.id guild: interaction.guild.id
} }

@ -7,6 +7,7 @@ import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js"; import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js"; import keyValueList from "../../utils/generateKeyValueList.js";
import client from "../../utils/client.js"; import client from "../../utils/client.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
const command = (builder: SlashCommandSubcommandBuilder) => const command = (builder: SlashCommandSubcommandBuilder) =>
builder builder
@ -125,6 +126,9 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
timeInServer: timeInServer, timeInServer: timeInServer,
serverMemberCount: member.guild.memberCount serverMemberCount: member.guild.memberCount
}, },
separate: {
end: getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) + ` The user was ${notify ? "" : "not "}notified`
},
hidden: { hidden: {
guild: member.guild.id guild: member.guild.id
} }

@ -338,6 +338,9 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
mutedBy: entry(interaction.member!.user.id, renderUser(interaction.member!.user as Discord.User)), mutedBy: entry(interaction.member!.user.id, renderUser(interaction.member!.user as Discord.User)),
reason: entry(reason, reason ? reason : "*No reason provided*") reason: entry(reason, reason ? reason : "*No reason provided*")
}, },
separate: {
end: getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) + ` The user was ${notify ? "" : "not "}notified`
},
hidden: { hidden: {
guild: interaction.guild.id guild: interaction.guild.id
} }

@ -6,6 +6,7 @@ import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js"; import keyValueList from "../../utils/generateKeyValueList.js";
import client from "../../utils/client.js"; import client from "../../utils/client.js";
import { areTicketsEnabled, create } from "../../actions/createModActionTicket.js"; import { areTicketsEnabled, create } from "../../actions/createModActionTicket.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
const command = (builder: SlashCommandSubcommandBuilder) => builder const command = (builder: SlashCommandSubcommandBuilder) => builder
@ -165,6 +166,9 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
updated: entry(Date.now(), renderDelta(Date.now())), updated: entry(Date.now(), renderDelta(Date.now())),
updatedBy: entry(interaction.user.id, renderUser(interaction.user)) updatedBy: entry(interaction.user.id, renderUser(interaction.user))
}, },
separate: {
end: getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) + ` The user was ${notify ? "" : "not "}notified`
},
hidden: { hidden: {
guild: interaction.guild!.id guild: interaction.guild!.id
} }

@ -309,7 +309,7 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
} }
}; };
log(data); log(data);
let out = ""; let out = ""; // TODO: messageException throughout this file
messages.reverse().forEach((message) => { messages.reverse().forEach((message) => {
if (!message) { if (!message) {
out += "Unknown message\n\n" out += "Unknown message\n\n"

@ -6,6 +6,7 @@ import keyValueList from "../../utils/generateKeyValueList.js";
import addPlurals from "../../utils/plurals.js"; import addPlurals from "../../utils/plurals.js";
import client from "../../utils/client.js"; import client from "../../utils/client.js";
import { LinkWarningFooter } from "../../utils/defaults.js"; import { LinkWarningFooter } from "../../utils/defaults.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
const command = (builder: SlashCommandSubcommandBuilder) => const command = (builder: SlashCommandSubcommandBuilder) =>
@ -135,6 +136,9 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
accountCreated: entry(member.user.createdTimestamp, renderDelta(member.user.createdTimestamp)), accountCreated: entry(member.user.createdTimestamp, renderDelta(member.user.createdTimestamp)),
serverMemberCount: interaction.guild.memberCount serverMemberCount: interaction.guild.memberCount
}, },
separate: {
end: getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) + ` The user was ${notify ? "" : "not "}notified`
},
hidden: { hidden: {
guild: interaction.guild.id guild: interaction.guild.id
} }

@ -4,6 +4,7 @@ import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js"; import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js"; import keyValueList from "../../utils/generateKeyValueList.js";
import client from "../../utils/client.js"; import client from "../../utils/client.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
const command = (builder: SlashCommandSubcommandBuilder) => const command = (builder: SlashCommandSubcommandBuilder) =>
builder builder
@ -113,6 +114,9 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
unmuted: entry(Date.now().toString(), renderDelta(Date.now())), unmuted: entry(Date.now().toString(), renderDelta(Date.now())),
unmutedBy: entry(interaction.user.id, renderUser(interaction.user)) unmutedBy: entry(interaction.user.id, renderUser(interaction.user))
}, },
separate: {
end: getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) + ` The user was ${notify ? "" : "not "}notified`
},
hidden: { hidden: {
guild: interaction.guild.id guild: interaction.guild.id
} }

@ -5,6 +5,7 @@ import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js"; import keyValueList from "../../utils/generateKeyValueList.js";
import { create, areTicketsEnabled } from "../../actions/createModActionTicket.js"; import { create, areTicketsEnabled } from "../../actions/createModActionTicket.js";
import client from "../../utils/client.js"; import client from "../../utils/client.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
import { LinkWarningFooter } from "../../utils/defaults.js"; import { LinkWarningFooter } from "../../utils/defaults.js";
const command = (builder: SlashCommandSubcommandBuilder) => const command = (builder: SlashCommandSubcommandBuilder) =>
@ -124,7 +125,10 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
renderUser((interaction.options.getMember("user") as GuildMember).user) renderUser((interaction.options.getMember("user") as GuildMember).user)
), ),
warnedBy: entry(interaction.member!.user.id, renderUser(interaction.member!.user as Discord.User)), warnedBy: entry(interaction.member!.user.id, renderUser(interaction.member!.user as Discord.User)),
reason: reason ? `\n> ${reason}` : "*No reason provided*" reason: reason ? reason : "*No reason provided*"
},
separate: {
end: getEmojiByName("ICONS.NOTIFY." + (notify ? "ON" : "OFF")) + ` The user was ${notify ? "" : "not "}notified`
}, },
hidden: { hidden: {
guild: interaction.guild.id guild: interaction.guild.id

@ -3,28 +3,26 @@ import type { SlashCommandSubcommandBuilder } from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js"; import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import client from "../../utils/client.js"; import client from "../../utils/client.js";
import { LoadingEmbed } from "../../utils/defaults.js"; import { LoadingEmbed } from "../../utils/defaults.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
const command = (builder: SlashCommandSubcommandBuilder) => const command = (builder: SlashCommandSubcommandBuilder) =>
builder.setName("premium").setDescription("Information about Nucleus Premium"); builder.setName("premium").setDescription("Information about Nucleus Premium");
//TODO: Allow User to remove Premium
const callback = async (interaction: CommandInteraction): Promise<void> => { const callback = async (interaction: CommandInteraction): Promise<void> => {
await interaction.reply({embeds: LoadingEmbed, ephemeral: true}) await interaction.reply({embeds: LoadingEmbed, ephemeral: true})
const member = (await interaction.client.guilds.fetch("684492926528651336")).members.cache.get(interaction.user.id) const member = await (await interaction.client.guilds.fetch("684492926528651336")).members.fetch(interaction.user.id).catch(() => {
const firstDescription = "\n\nPremium allows your server to get access to extra features, for a fixed price per month.\nThis includes:\n" +
"- Attachment logs - Stores attachments so they can be viewed after a message is deleted.\n" +
"- Ticket Transcripts - Gives a link to view the history of a ticket after it has been closed.\n"
if(!member) {
interaction.editReply({ embeds: [ interaction.editReply({ embeds: [
new EmojiEmbed() new EmojiEmbed()
.setTitle("Premium") .setTitle("Premium")
.setDescription( .setDescription(`*You are not currently in the Clicks Server. To gain access to premium please join.*` + firstDescription)
`*You are not currently in the Clicks Server. To gain access to premium please join.*` + firstDescription
)
.setEmoji("NUCLEUS.LOGO") .setEmoji("NUCLEUS.LOGO")
.setStatus("Danger") .setStatus("Danger")
], components: [new ActionRowBuilder<ButtonBuilder>().addComponents(new ButtonBuilder().setStyle(ButtonStyle.Link).setLabel("Join").setURL("https://discord.gg/bPaNnxe"))] }); ], components: [new ActionRowBuilder<ButtonBuilder>().addComponents(new ButtonBuilder().setStyle(ButtonStyle.Link).setLabel("Join").setURL("https://discord.gg/bPaNnxe"))] });
return; })
} if (!member) return;
const firstDescription = "\n\nPremium allows servers of your choice to get access to extra features for a fixed price per month.\nThis includes:\n" +
`${getEmojiByName("MOD.IMAGES.TOOSMALL")} Attachment logs - Stores attachments so they can be viewed after a message is deleted.\n` +
`${getEmojiByName("GUILD.TICKET.ARCHIVED")} Ticket Transcripts - Gives a link to view the history of a ticket after it has been closed.\n`
const dbMember = await client.database.premium.fetchUser(interaction.user.id) const dbMember = await client.database.premium.fetchUser(interaction.user.id)
let premium = `You do not have premium! You can't activate premium on any servers.`; let premium = `You do not have premium! You can't activate premium on any servers.`;
let count = 0; let count = 0;
@ -33,19 +31,47 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
premium = `You have Infinite Premium! You have been gifted this by the developers as a thank you. You can give premium to any and all servers you are in.`; premium = `You have Infinite Premium! You have been gifted this by the developers as a thank you. You can give premium to any and all servers you are in.`;
count = 200; count = 200;
} else if (level === 1) { } else if (level === 1) {
premium = `You have Premium tier 1! You can give premium to ${1 - appliesTo.length} more servers.`; premium = `You have Premium tier 1! You can give premium to ${1 - appliesTo.length} more server(s).`;
count = 1; count = 1;
} else if (level === 2) { } else if (level === 2) {
premium = `You have Premium tier 2! You can give premium to ${3 - appliesTo.length} more servers.`; premium = `You have Premium tier 2! You can give premium to ${3 - appliesTo.length} more server(s).`;
count = 3; count = 3;
} else if (level === 3) { } else if (level === 3) {
premium = `You have Premium Mod! You can give premium to ${3 - appliesTo.length} more servers, as well as automatically giving premium to all servers you have a "manage" permission in.` premium = `You have Premium Mod! You can give premium to ${3 - appliesTo.length} more server(s), as well as automatically giving premium to all servers you have a "manage" permission in.`
count = 3; count = 3;
} }
if (dbMember?.expiresAt) {
premium = `**You can't give servers premium anymore because your subscription ended or was cancelled.** To get premium again please subscribe in the Clicks server`
count = 0;
}
const hasPremium = await client.database.premium.hasPremium(interaction.guild!.id); const hasPremium = await client.database.premium.hasPremium(interaction.guild!.id);
let premiumGuild = "" let premiumGuild = ""
if (hasPremium) { if (hasPremium) { //FIXME: Check how user applied premium
premiumGuild = `\n\n**This server has premium!**` premiumGuild = `**This server has premium! It was ${hasPremium[2] === 3 ? `automatically applied by <@${hasPremium[1]}>` : `given by <@${hasPremium[1]}>`}**\n\n`
}
const components: ActionRowBuilder<ButtonBuilder>[] = []
if (level === 0 || dbMember?.expiresAt) {
components.push(
new ActionRowBuilder<ButtonBuilder>()
.addComponents(
new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel("Join Clicks")
.setURL("https://discord.gg/bPaNnxe")
)
)
} else {
components.push(
new ActionRowBuilder<ButtonBuilder>()
.addComponents(
new ButtonBuilder()
.setStyle(premiumGuild.length > 0 ? ButtonStyle.Secondary : ButtonStyle.Success)
.setLabel(premiumGuild.length > 0 ? "This server has premium" : "Activate premium here")
.setCustomId("premiumActivate")
.setDisabled(count <= 0 || (hasPremium ? hasPremium[0] : false))
)
)
} }
interaction.editReply({ interaction.editReply({
@ -53,21 +79,13 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
new EmojiEmbed() new EmojiEmbed()
.setTitle("Premium") .setTitle("Premium")
.setDescription( .setDescription(
premium + firstDescription + premiumGuild premiumGuild + premium + firstDescription
) )
.setEmoji("NUCLEUS.LOGO") .setEmoji("NUCLEUS.LOGO")
.setStatus("Danger") .setStatus("Danger")
// .setImage("") //TODO: Add image
], ],
components: [ components: components
new ActionRowBuilder<ButtonBuilder>()
.addComponents(
new ButtonBuilder()
.setStyle(ButtonStyle.Primary)
.setLabel("Activate Premium here")
.setCustomId("premiumActivate")
.setDisabled(count <= 0 && hasPremium)
)
]
}); });
const filter = (i: ButtonInteraction) => i.customId === "premiumActivate" && i.user.id === interaction.user.id; const filter = (i: ButtonInteraction) => i.customId === "premiumActivate" && i.user.id === interaction.user.id;

@ -48,15 +48,13 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
new EmojiEmbed() new EmojiEmbed()
.setTitle("Link scanning and Transcripts") .setTitle("Link scanning and Transcripts")
.setDescription( .setDescription(
"**Facebook** - Facebook trackers include data such as your date of birth, and guess your age if not entered, your preferences, who you interact with and more.\n" + "Transcripts allow you to store all messages sent in a channel. Transcripts are stored in our database along with the rest of the server's settings but is accessible by anyone with the link, so a leaked link could show all messages sent in the channel.\n"
"**AMP** - AMP is a technology that allows websites to be served by Google. This means Google can store and track data, and are pushing this to as many pages as possible.\n\n" +
"Transcripts allow you to store all messages sent in a channel. This is stored in our database along with the rest of the servers settings but is accessible by anyone with the link, so a leaked link could show all messages sent in the channel.\n"
) )
.setEmoji("NUCLEUS.LOGO") .setEmoji("NUCLEUS.LOGO")
.setStatus("Danger") .setStatus("Danger")
) )
.setTitle("Link scanning and Transcripts") .setTitle("Link scanning and Transcripts")
.setDescription("Regarding Facebook and AMP filter types, and ticket transcripts") .setDescription("Information about how links and images are scanned, and transcripts are stored")
.setPageId(2) .setPageId(2)
].concat( ].concat(
(interaction.member as Discord.GuildMember).permissions.has("Administrator") (interaction.member as Discord.GuildMember).permissions.has("Administrator")

@ -1,5 +1,5 @@
import { LoadingEmbed } from "../../../utils/defaults.js"; import { LoadingEmbed } from "../../../utils/defaults.js";
import Discord, { CommandInteraction, ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelSelectMenuBuilder } from "discord.js"; import Discord, { CommandInteraction, ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelSelectMenuBuilder, ChannelType } from "discord.js";
import EmojiEmbed from "../../../utils/generateEmojiEmbed.js"; import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../../utils/getEmojiByName.js"; import getEmojiByName from "../../../utils/getEmojiByName.js";
import type { SlashCommandSubcommandBuilder } from "discord.js"; import type { SlashCommandSubcommandBuilder } from "discord.js";
@ -38,6 +38,7 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
new ChannelSelectMenuBuilder() new ChannelSelectMenuBuilder()
.setCustomId("channel") .setCustomId("channel")
.setPlaceholder("Select a channel") .setPlaceholder("Select a channel")
.setChannelTypes(ChannelType.GuildText)
); );
const buttons = new ActionRowBuilder<ButtonBuilder>() const buttons = new ActionRowBuilder<ButtonBuilder>()
.addComponents( .addComponents(
@ -58,7 +59,7 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
const embed = new EmojiEmbed() const embed = new EmojiEmbed()
.setTitle("Attachments") .setTitle("Attachments")
.setDescription( .setDescription(
`The channel to send all attachments from the server, allowing you to check them if they are deleted` + `The channel to send all attachments from the server, allowing you to check them if they are deleted\n` +
`**Channel:** ${channel ? `<#${channel}>` : "*None*"}\n` `**Channel:** ${channel ? `<#${channel}>` : "*None*"}\n`
) )
.setStatus("Success") .setStatus("Success")

@ -1,5 +1,5 @@
import { LoadingEmbed } from "../../../utils/defaults.js"; import { LoadingEmbed } from "../../../utils/defaults.js";
import Discord, { CommandInteraction, ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelSelectMenuBuilder } from "discord.js"; import Discord, { CommandInteraction, ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelSelectMenuBuilder, ChannelType } from "discord.js";
import EmojiEmbed from "../../../utils/generateEmojiEmbed.js"; import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../../utils/getEmojiByName.js"; import getEmojiByName from "../../../utils/getEmojiByName.js";
import type { SlashCommandSubcommandBuilder } from "discord.js"; import type { SlashCommandSubcommandBuilder } from "discord.js";
@ -27,6 +27,7 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
new ChannelSelectMenuBuilder() new ChannelSelectMenuBuilder()
.setCustomId("channel") .setCustomId("channel")
.setPlaceholder("Select a channel") .setPlaceholder("Select a channel")
.setChannelTypes(ChannelType.GuildText)
); );
const buttons = new ActionRowBuilder<ButtonBuilder>() const buttons = new ActionRowBuilder<ButtonBuilder>()
.addComponents( .addComponents(

@ -28,7 +28,7 @@
"REORDER": "1069323453909454890", "REORDER": "1069323453909454890",
"NOTIFY": { "NOTIFY": {
"ON": "1000726394579464232", "ON": "1000726394579464232",
"OFF": "1000726363495477368" "OFF": "1078058136092541008"
}, },
"OPP": { "OPP": {
"ADD": "837355918831124500", "ADD": "837355918831124500",

@ -5,6 +5,7 @@ import Discord, { ActionRowBuilder, ButtonBuilder, ButtonStyle, ContextMenuComma
import client from "../../utils/client.js"; import client from "../../utils/client.js";
import getEmojiByName from '../../utils/getEmojiByName.js'; import getEmojiByName from '../../utils/getEmojiByName.js';
import { JSONTranscriptFromMessageArray, JSONTranscriptToHumanReadable } from "../../utils/logTranscripts.js"; import { JSONTranscriptFromMessageArray, JSONTranscriptToHumanReadable } from "../../utils/logTranscripts.js";
import { messageException } from '../../utils/createTemporaryStorage.js';
const command = new ContextMenuCommandBuilder() const command = new ContextMenuCommandBuilder()
.setName("Purge up to here") .setName("Purge up to here")
@ -185,6 +186,7 @@ const callback = async (interaction: MessageContextMenuCommandInteraction) => {
}; };
log(data); log(data);
const messages: Message[] = deleted.map(m => m).filter(m => m instanceof Message).map(m => m as Message); const messages: Message[] = deleted.map(m => m).filter(m => m instanceof Message).map(m => m as Message);
if (messages.length === 1) messageException(interaction.guild!.id, interaction.channel.id, messages[0]!.id)
const transcript = JSONTranscriptToHumanReadable(JSONTranscriptFromMessageArray(messages)!); const transcript = JSONTranscriptToHumanReadable(JSONTranscriptFromMessageArray(messages)!);
const attachmentObject = { const attachmentObject = {
attachment: Buffer.from(transcript), attachment: Buffer.from(transcript),

@ -5,6 +5,7 @@ const command = new ContextMenuCommandBuilder()
.setName("User info") .setName("User info")
const callback = async (interaction: UserContextMenuCommandInteraction) => { const callback = async (interaction: UserContextMenuCommandInteraction) => {
console.log("callback")
const guild = interaction.guild! const guild = interaction.guild!
let member = interaction.targetMember let member = interaction.targetMember
if (!member) member = await guild.members.fetch(interaction.targetId) if (!member) member = await guild.members.fetch(interaction.targetId)
@ -12,6 +13,7 @@ const callback = async (interaction: UserContextMenuCommandInteraction) => {
} }
const check = async (_interaction: UserContextMenuCommandInteraction) => { const check = async (_interaction: UserContextMenuCommandInteraction) => {
console.log("check")
return true; return true;
} }

@ -7,6 +7,9 @@ export const event = "guildMemberUpdate";
export async function callback(client: NucleusClient, before: GuildMember, after: GuildMember) { export async function callback(client: NucleusClient, before: GuildMember, after: GuildMember) {
const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = client.logger; const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = client.logger;
if(before.guild.id === "684492926528651336") {
await client.database.premium.checkAllPremium(after)
}
if(!before.roles.cache.equals(after.roles.cache)) { if(!before.roles.cache.equals(after.roles.cache)) {
const auditLog = (await getAuditLog(after.guild, AuditLogEvent.MemberRoleUpdate)) const auditLog = (await getAuditLog(after.guild, AuditLogEvent.MemberRoleUpdate))

@ -13,10 +13,9 @@ client.on("ready", async () => {
} else { } else {
client.fetchedCommands = await client.application?.commands.fetch()!; client.fetchedCommands = await client.application?.commands.fetch()!;
} }
setInterval(async () => { await client.database.premium.checkAllPremium();
await client.database.premium.checkAllPremium();
}, 1000 * 60 * 3);
}); });
process.on("unhandledRejection", (err) => { console.error(err) }); process.on("unhandledRejection", (err) => { console.error(err) });
process.on("uncaughtException", (err) => { console.error(err) }); process.on("uncaughtException", (err) => { console.error(err) });

@ -14,6 +14,7 @@ import EmojiEmbed from "../utils/generateEmojiEmbed.js";
import getEmojiByName from "../utils/getEmojiByName.js"; import getEmojiByName from "../utils/getEmojiByName.js";
import { PasteClient, Publicity, ExpireDate } from "pastebin-api"; import { PasteClient, Publicity, ExpireDate } from "pastebin-api";
import client from "../utils/client.js"; import client from "../utils/client.js";
import { messageException } from '../utils/createTemporaryStorage.js';
const pbClient = new PasteClient(client.config.pastebinApiKey); const pbClient = new PasteClient(client.config.pastebinApiKey);
@ -95,6 +96,7 @@ export default async function (interaction: CommandInteraction | MessageComponen
const deleted = await (interaction.channel as TextChannel).bulkDelete(fetched, true); const deleted = await (interaction.channel as TextChannel).bulkDelete(fetched, true);
deletedCount = deleted.size; deletedCount = deleted.size;
messages = messages.concat(Array.from(deleted.values() as Iterable<Message>)); messages = messages.concat(Array.from(deleted.values() as Iterable<Message>));
if (messages.length === 1) messageException(interaction.guild!.id, interaction.channel.id, messages[0]!.id)
} while (deletedCount === 100); } while (deletedCount === 100);
let out = ""; let out = "";

@ -32,14 +32,13 @@ class NucleusClient extends Client {
callback: (interaction: Interaction) => Promise<void>, callback: (interaction: Interaction) => Promise<void>,
check: (interaction: Interaction, partial: boolean) => Promise<boolean> | boolean, check: (interaction: Interaction, partial: boolean) => Promise<boolean> | boolean,
autocomplete: (interaction: AutocompleteInteraction) => Promise<string[]> autocomplete: (interaction: AutocompleteInteraction) => Promise<string[]>
} | undefined,{name: string, description: string}]> = {}; } | undefined, {name: string, description: string}]> = {};
fetchedCommands = new Collection<string, Discord.ApplicationCommand>(); fetchedCommands = new Collection<string, Discord.ApplicationCommand>();
constructor(database: typeof NucleusClient.prototype.database) { constructor(database: typeof NucleusClient.prototype.database) {
super({ intents: 0b1100011011011111111111}); super({ intents: 0b1100011011011111111111});
this.database = database; this.database = database;
} }
} }
const client = new NucleusClient({ const client = new NucleusClient({
guilds: await new Guilds().setup(), guilds: await new Guilds().setup(),
history: new History(), history: new History(),

@ -111,7 +111,7 @@ async function registerContextMenus() {
context.command.setNameLocalizations(context.nameLocalizations ?? {}) context.command.setNameLocalizations(context.nameLocalizations ?? {})
commands.push(context.command); commands.push(context.command);
client.commands["contextCommands/message/" + context.command.name] = context; client.commands["contextCommands/message/" + context.command.name] = [context, {name: context.name ?? context.command.name, description: context.description ?? context.command.description}];
console.log(`${last.replace("└", " ").replace("├", "│")} └─ ${colors.green}Loaded ${file.name} [${i} / ${totalFiles}]${colors.none}`) console.log(`${last.replace("└", " ").replace("├", "│")} └─ ${colors.green}Loaded ${file.name} [${i} / ${totalFiles}]${colors.none}`)
} catch (e) { } catch (e) {
@ -181,6 +181,7 @@ async function registerCommandHandler() {
} }
async function execute(check: Function | undefined, callback: Function | undefined, data: CommandInteraction) { async function execute(check: Function | undefined, callback: Function | undefined, data: CommandInteraction) {
console.log(client.commands["contextCommands/user/User info"])
if (!callback) return; if (!callback) return;
if (check) { if (check) {
let result; let result;
@ -197,7 +198,7 @@ async function execute(check: Function | undefined, callback: Function | undefin
.setColor(NucleusColors.red) .setColor(NucleusColors.red)
.setEmoji(getEmojiByName("CONTROL.BLOCKCROSS")) .setEmoji(getEmojiByName("CONTROL.BLOCKCROSS"))
], ephemeral: true}); ], ephemeral: true});
}; }
} }
callback(data); callback(data);
} }

@ -1,3 +1,4 @@
import type { GuildMember } from "discord.js";
import type Discord from "discord.js"; import type Discord from "discord.js";
import { Collection, MongoClient } from "mongodb"; import { Collection, MongoClient } from "mongodb";
import config from "../config/main.js"; import config from "../config/main.js";
@ -245,11 +246,36 @@ export class Premium {
await this.premium.insertOne({ user: user, appliesTo: [], level: level }); await this.premium.insertOne({ user: user, appliesTo: [], level: level });
} }
async hasPremium(guild: string) { async hasPremium(guild: string): Promise<[boolean, string, number] | null> {
const entries = await this.premium.find({}).toArray();
const members = await (await client.guilds.fetch(guild)).members.fetch()
for(const {user} of entries) {
const member = members.get(user);
if(member) {
const modPerms = //TODO: Create list in config for perms
member.permissions.has("Administrator") ||
member.permissions.has("ManageChannels") ||
member.permissions.has("ManageRoles") ||
member.permissions.has("ManageEmojisAndStickers") ||
member.permissions.has("ManageWebhooks") ||
member.permissions.has("ManageGuild") ||
member.permissions.has("KickMembers") ||
member.permissions.has("BanMembers") ||
member.permissions.has("ManageEvents") ||
member.permissions.has("ManageMessages") ||
member.permissions.has("ManageThreads")
const entry = entries.find(e => e.user === member.id);
if(entry && (entry.level === 3) && modPerms) return [true, member.id, entry.level];
}
}
const entry = await this.premium.findOne({ const entry = await this.premium.findOne({
appliesTo: { $in: [guild] } appliesTo: {
$elemMatch: {
$eq: guild
}
}
}); });
return entry ? true : false; return entry ? [true, entry.user, entry.level] : null;
} }
async fetchUser(user: string): Promise<PremiumSchema | null> { async fetchUser(user: string): Promise<PremiumSchema | null> {
@ -258,26 +284,55 @@ export class Premium {
return entry; return entry;
} }
async checkAllPremium() { async checkAllPremium(member?: GuildMember) {
const entries = await this.premium.find({}).toArray(); const entries = await this.premium.find({}).toArray();
for(const {user, expiresAt} of entries) { if(member) {
if(expiresAt) expiresAt < Date.now() ? await this.premium.deleteOne({user: user}) : null; const entry = entries.find(e => e.user === member.id);
const member = await (await client.guilds.fetch("684492926528651336")).members.fetch(user) if(entry) {
let level: number = 0; const expiresAt = entry.expiresAt;
if (member.roles.cache.has("1066468879309750313")) { if(expiresAt) expiresAt < Date.now() ? await this.premium.deleteOne({user: member.id}) : null;
}
const roles = member.roles;
let level = 0;
if (roles.cache.has("1066468879309750313")) {
level = 99; level = 99;
} else if (member.roles.cache.has("1066465491713003520")) { } else if (roles.cache.has("1066465491713003520")) {
level = 1; level = 1;
} else if (member.roles.cache.has("1066439526496604194")) { } else if (roles.cache.has("1066439526496604194")) {
level = 2; level = 2;
} else if (member.roles.cache.has("1066464134322978912")) { } else if (roles.cache.has("1066464134322978912")) {
level = 3; level = 3;
} }
await this.updateUser(member.id, level);
if (level > 0) { if (level > 0) {
await this.updateUser(user, level); await this.premium.updateOne({ user: member.id }, {$unset: { expiresAt: ""}})
} else { } else {
await this.premium.updateOne({ user: user }, { expiresAt: (Date.now() + (1000*60*60*24*3)) }) await this.premium.updateOne({ user: member.id }, {$set: { expiresAt: (Date.now() + (1000*60*60*24*3)) }})
}
} else {
const members = await (await client.guilds.fetch('684492926528651336')).members.fetch();
for(const {roles, id} of members.values()) {
const entry = entries.find(e => e.user === id);
if(entry) {
const expiresAt = entry.expiresAt;
if(expiresAt) expiresAt < Date.now() ? await this.premium.deleteOne({user: id}) : null;
}
let level: number = 0;
if (roles.cache.has("1066468879309750313")) {
level = 99;
} else if (roles.cache.has("1066465491713003520")) {
level = 1;
} else if (roles.cache.has("1066439526496604194")) {
level = 2;
} else if (roles.cache.has("1066464134322978912")) {
level = 3;
}
await this.updateUser(id, level);
if (level > 0) {
await this.premium.updateOne({ user: id }, {$unset: { expiresAt: ""}})
} else {
await this.premium.updateOne({ user: id }, {$set: { expiresAt: (Date.now() + (1000*60*60*24*3)) }})
}
} }
} }
} }

Loading…
Cancel
Save