Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
509 changes: 263 additions & 246 deletions package-lock.json

Large diffs are not rendered by default.

File renamed without changes.
4 changes: 4 additions & 0 deletions src/base/types/discord.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Client, Collection } from "discord.js";
import { Command } from "../classes/command.js";

export type DiscordClient = Client & { commands: Collection<string, Command> }
5 changes: 3 additions & 2 deletions src/events/activityUpdate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ActivityType, Client, Events } from "discord.js";
import { ActivityType, Events } from "discord.js";
import { DiscordClient } from "../base/types/discord.js";

function getStatus(guilds: number, users: number) {
const statuses = [
Expand Down Expand Up @@ -35,7 +36,7 @@ export default {
name: Events.ClientReady,
once: true,

execute(client: Client) {
execute(client: DiscordClient) {
if (!client.user) return;

const updatePresence = () => {
Expand Down
5 changes: 3 additions & 2 deletions src/events/clientReady.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Client, Events } from "discord.js";
import { Events } from "discord.js";
import { logger } from "../libs/logger.js";
import { DiscordClient } from "../base/types/discord.js";

export default {
name: Events.ClientReady,
once: true,
execute(client: Client) {
execute(client: DiscordClient) {
if (!client.user) return;
logger.bot(`Ready! Logged in as ${client.user.tag}`);
},
Expand Down
32 changes: 26 additions & 6 deletions src/events/guildMemberUpdate.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import "../libs/loadVariables.js";
import {
Client,
ContainerBuilder,
EmbedBuilder,
Events,
GuildMember,
MessageFlags,
PermissionFlagsBits,
TextChannel,
} from "discord.js";
Expand All @@ -19,11 +20,13 @@ import {
} from "../services/roleService.js";
import { logger } from "../libs/logger.js";
import { prisma } from "../libs/database.js";
import { DiscordClient } from "../base/types/discord.js";
import { SystemColors } from "../libs/colors.js";

export default {
name: Events.GuildMemberUpdate,
async execute(
_client: Client,
_client: DiscordClient,
oldMember: GuildMember,
newMember: GuildMember,
) {
Expand Down Expand Up @@ -162,10 +165,27 @@ async function onBoostStart(member: GuildMember): Promise<void> {
await safeSend(logChannel, { embeds: [logEmbed] });

try {
await member.send(
`Thank you for boosting the server! You now have access to booster perks.`,
);
} catch {}
const serverImage = guild.iconURL();

const container = new ContainerBuilder().addSectionComponents(comp => {
comp.addTextDisplayComponents(text =>
text.setContent(
`## Thanks for the boost! <a:booster:1527782487349268480>\n` +
`Thank you for boosting the server **${guild.name}**\n\n`+
`Your support helps us unlock new server perks and continue making this community even better for everyone.\n\n`+
`We truly appreciate you being part of our journey. Enjoy your booster rewards! ✨`
)
);
if (serverImage) {
comp.setThumbnailAccessory(accessory => accessory.setURL(serverImage));
}
return comp;
}).setAccentColor(SystemColors.main);
await member.send({
components: [container],
flags: [MessageFlags.IsComponentsV2]
});
} catch { }
}

async function onBoostEnd(member: GuildMember): Promise<void> {
Expand Down
6 changes: 3 additions & 3 deletions src/events/helpautocomplete.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AutocompleteInteraction, ChatInputCommandInteraction, Client, Collection, Events } from "discord.js";
import { Command } from "../base/classes/command.js";
import { AutocompleteInteraction, Events } from "discord.js";
import { DiscordClient } from "../base/types/discord.js";

export default {
name: Events.InteractionCreate,
async execute(client: Client & { commands: Collection<string, Command> }, interaction: AutocompleteInteraction) {
async execute(client: DiscordClient, interaction: AutocompleteInteraction) {
if (!interaction.isAutocomplete()) return;
if (interaction.commandName != 'help') return;

Expand Down
3 changes: 2 additions & 1 deletion src/events/interactionCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import {
MessageFlags,
type InteractionReplyOptions,
} from "discord.js";
import { DiscordClient } from "../base/types/discord.js";

export default {
name: Events.InteractionCreate,
async execute(client: Client & { commands: any }, interaction: Interaction) {
async execute(client: DiscordClient, interaction: Interaction) {
if (
interaction.type !== InteractionType.ApplicationCommand ||
!interaction.isChatInputCommand()
Expand Down
3 changes: 2 additions & 1 deletion src/events/onServerAdd.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { ButtonBuilder, ButtonStyle, Client, ContainerBuilder, Events, Guild, MessageFlags } from "discord.js";
import { logger } from "../libs/logger.js";
import { SystemColors } from "../libs/colors.js";
import { DiscordClient } from "../base/types/discord.js";

export default {
name: Events.GuildCreate,
async execute(client: Client, guild: Guild,) {
async execute(client: DiscordClient, guild: Guild,) {
logger.custom(`Added to the server with ID ${guild.id}`, "ADDED", "magenta");
try {
const owner = await guild.fetchOwner();
Expand Down
3 changes: 2 additions & 1 deletion src/events/roleCleanup.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Client, Events } from "discord.js";
import { processDueCustomRoleDeletions } from "../services/customRoleCleanup.js";
import { DiscordClient } from "../base/types/discord.js";

const CUSTOM_ROLE_CLEANUP_MS = 60 * 60 * 1000;

export default {
name: Events.ClientReady,
once: true,
execute(client: Client) {
execute(client: DiscordClient) {
if (!client.user) return;

void processDueCustomRoleDeletions(client);
Expand Down
3 changes: 2 additions & 1 deletion src/events/setupResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import {
} from "discord.js";
import { prisma } from "../libs/database.js";
import { SystemColors } from "../libs/colors.js";
import { DiscordClient } from "../base/types/discord.js";

export default {
name: Events.InteractionCreate,
async execute(_client: Client, interaction: Interaction) {
async execute(_client: DiscordClient, interaction: Interaction) {
if (!interaction.isModalSubmit()) return;
if (!interaction.guild) return;
if (interaction.customId != 'setupboostifymodal' && interaction.customId != 'configboostifymodal') return;
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { fileURLToPath, pathToFileURL } from "url";
import { logger } from "./libs/logger.js";
import chalk from "chalk";
import { loadLoops } from "./libs/loops.js";
import { DiscordClient } from "./base/types/discord.js";

const __dirname = fileURLToPath(new URL(".", import.meta.url));

Expand Down Expand Up @@ -61,7 +62,7 @@ export const client = new Client({
GatewayIntentBits.GuildMessages,
],
partials: [Partials.GuildMember],
}) as Client & { commands?: Collection<string, Command> };
}) as DiscordClient;

client.commands = new Collection();

Expand Down
2 changes: 1 addition & 1 deletion src/libs/logger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import chalk from "chalk";
import { ChalkColors } from "../base/types/types.js";
import { ChalkColors } from "../base/types/chalk.js";

const timestamp = () => chalk.dim(`${new Date().toISOString()}`);

Expand Down
Loading