Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge formatting into main #698

Closed
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
33 changes: 20 additions & 13 deletions src/buttons/welcomeMessages/welcome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ const button: Button = {

const truncateString = (str: string, maxLength: number) => {
// Remove line breaks first
const cleanedStr = str.replace(/\n/g, ' ');
return cleanedStr.length > maxLength ? `${cleanedStr.substring(0, maxLength)}...` : cleanedStr;
const cleanedStr = str.replace(/\n/g, " ");
return cleanedStr.length > maxLength
? `${cleanedStr.substring(0, maxLength)}...`
: cleanedStr;
};

const welcomes = new EmbedBuilder()
Expand All @@ -40,13 +42,13 @@ const button: Button = {
guildDb?.language,
"Settings.embed.welcomeChannel",
)}: ${guildDb.welcomeChannel ? `<#${guildDb.welcomeChannel}>` : ":x:"}\n${client.translation.get(
guildDb?.language,
"Settings.embed.welcomeMessage",
)}: ${
guildDb.welcomeMessage
? truncateString(guildDb.welcomeMessage, 100)
: ":x:"
}`,
guildDb?.language,
"Settings.embed.welcomeMessage",
)}: ${
guildDb.welcomeMessage
? truncateString(guildDb.welcomeMessage, 100)
: ":x:"
}`,
)
.setColor("#0598F6")
.setFooter({
Expand Down Expand Up @@ -122,17 +124,22 @@ const button: Button = {
),
);

const welcomeButtons3 =
const welcomeButtons3 =
new ActionRowBuilder<MessageActionRowComponentBuilder>().addComponents(
new ButtonBuilder()
.setCustomId("welcomeMessage")
.setEmoji("1185973660465500180")
.setLabel(
client.translation.get(guildDb?.language, "Settings.button.welcomeMessage"),
client.translation.get(
guildDb?.language,
"Settings.button.welcomeMessage",
),
)
.setStyle(
guildDb.welcomeMessage ? ButtonStyle.Primary : ButtonStyle.Secondary,
)
guildDb.welcomeMessage
? ButtonStyle.Primary
: ButtonStyle.Secondary,
),
);

await client.database.updateGuild(interaction.guild?.id || "", {
Expand Down
73 changes: 48 additions & 25 deletions src/buttons/welcomeMessages/welcomeMessage.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { EmbedBuilder, ActionRowBuilder, type MessageActionRowComponentBuilder, ButtonBuilder, ButtonStyle } from "discord.js";
import {
EmbedBuilder,
ActionRowBuilder,
type MessageActionRowComponentBuilder,
ButtonBuilder,
ButtonStyle,
} from "discord.js";
import type { Button } from "../../interfaces";
import { Modal, type ModalData } from "../../util/modalHandler";

const button: Button = {
name: "welcomeMessage",
cooldown: false,
execute: async (interaction, client, guildDb) => {
const { data } = await new Modal({
const { data } = await new Modal({
title: "Set Welcome Message",
customId: "welcomeMessage",
fields: [
Expand Down Expand Up @@ -35,14 +41,18 @@ const button: Button = {

const truncateString = (str: string, maxLength: number) => {
// Remove line breaks first
const cleanedStr = str.replace(/\n/g, ' ');
return cleanedStr.length > maxLength ? `${cleanedStr.substring(0, maxLength)}...` : cleanedStr;
const cleanedStr = str.replace(/\n/g, " ");
return cleanedStr.length > maxLength
? `${cleanedStr.substring(0, maxLength)}...`
: cleanedStr;
};



const welcomeEmbed = new EmbedBuilder()
.setTitle(
client.translation.get(guildDb?.language, "Settings.embed.welcomeTitle"),
client.translation.get(
guildDb?.language,
"Settings.embed.welcomeTitle",
),
)
.setDescription(
`${client.translation.get(
Expand All @@ -60,16 +70,17 @@ const button: Button = {
)}: ${guildDb.welcomeChannel ? `<#${guildDb.welcomeChannel}>` : ":x:"}\n${client.translation.get(
guildDb?.language,
"Settings.embed.welcomeMessage",
)}: ${
truncateString(value, 100)
}`,
)}: ${truncateString(value, 100)}`,
)
.setColor("#0598F6")
.setFooter({
text: client.translation.get(guildDb?.language, "Settings.embed.footer"),
text: client.translation.get(
guildDb?.language,
"Settings.embed.footer",
),
iconURL: client?.user?.displayAvatarURL() || undefined,
});

// First button row
// Deals with toggles
const welcomeButtons1 =
Expand All @@ -94,7 +105,9 @@ const button: Button = {
),
)
.setStyle(
guildDb.welcomeChannel ? ButtonStyle.Primary : ButtonStyle.Secondary,
guildDb.welcomeChannel
? ButtonStyle.Primary
: ButtonStyle.Secondary,
),
new ButtonBuilder()
.setCustomId("welcomeTest")
Expand All @@ -105,10 +118,12 @@ const button: Button = {
),
)
.setDisabled(!guildDb.welcome)
.setStyle(guildDb.welcome ? ButtonStyle.Primary : ButtonStyle.Secondary)
.setStyle(
guildDb.welcome ? ButtonStyle.Primary : ButtonStyle.Secondary,
)
.setEmoji("1207800685928910909"),
);

// Second button row
// Deals with type, channel, test
const welcomeButtons2 =
Expand All @@ -117,7 +132,10 @@ const button: Button = {
.setCustomId("welcome")
.setEmoji("1185973660465500180")
.setLabel(
client.translation.get(guildDb?.language, "Settings.button.welcome"),
client.translation.get(
guildDb?.language,
"Settings.button.welcome",
),
)
.setStyle(
guildDb.welcome ? ButtonStyle.Success : ButtonStyle.Secondary,
Expand All @@ -135,24 +153,29 @@ const button: Button = {
guildDb.welcomePing ? ButtonStyle.Success : ButtonStyle.Secondary,
),
);
const welcomeButtons3 =

const welcomeButtons3 =
new ActionRowBuilder<MessageActionRowComponentBuilder>().addComponents(
new ButtonBuilder()
.setCustomId("welcomeMessage")
.setEmoji("1185973660465500180")
.setLabel(
client.translation.get(guildDb?.language, "Settings.button.welcomeMessage"),
client.translation.get(
guildDb?.language,
"Settings.button.welcomeMessage",
),
)
.setStyle(
guildDb.welcomeMessage ? ButtonStyle.Primary : ButtonStyle.Secondary,
)
guildDb.welcomeMessage
? ButtonStyle.Primary
: ButtonStyle.Secondary,
),
);

await client.database.updateGuild(interaction.guild?.id || "", {
...guildDb,
welcomeMessage: value,
});
await client.database.updateGuild(interaction.guild?.id || "", {
...guildDb,
welcomeMessage: value,
});

await (data?.modal as any).update({
embeds: [welcomeEmbed],
Expand Down
20 changes: 11 additions & 9 deletions src/buttons/welcomeMessages/welcomePing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ const button: Button = {

const truncateString = (str: string, maxLength: number) => {
// Remove line breaks first
const cleanedStr = str.replace(/\n/g, ' ');
return cleanedStr.length > maxLength ? `${cleanedStr.substring(0, maxLength)}...` : cleanedStr;
const cleanedStr = str.replace(/\n/g, " ");
return cleanedStr.length > maxLength
? `${cleanedStr.substring(0, maxLength)}...`
: cleanedStr;
};

const welcomes = new EmbedBuilder()
Expand All @@ -40,13 +42,13 @@ const button: Button = {
guildDb?.language,
"Settings.embed.welcomeChannel",
)}: ${guildDb.welcomeChannel ? `<#${guildDb.welcomeChannel}>` : ":x:"}\n${client.translation.get(
guildDb?.language,
"Settings.embed.welcomeMessage",
)}: ${
guildDb.welcomeMessage
? truncateString(guildDb.welcomeMessage, 100)
: ":x:"
}`,
guildDb?.language,
"Settings.embed.welcomeMessage",
)}: ${
guildDb.welcomeMessage
? truncateString(guildDb.welcomeMessage, 100)
: ":x:"
}`,
)
.setColor("#0598F6")
.setFooter({
Expand Down
16 changes: 10 additions & 6 deletions src/commands/settings/settings-subcommands/welcomes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ export default async function settingsGeneral(
) {
const truncateString = (str: string, maxLength: number) => {
// Remove line breaks first
const cleanedStr = str.replace(/\n/g, ' ');
return cleanedStr.length > maxLength ? `${cleanedStr.substring(0, maxLength)}...` : cleanedStr;
const cleanedStr = str.replace(/\n/g, " ");
return cleanedStr.length > maxLength
? `${cleanedStr.substring(0, maxLength)}...`
: cleanedStr;
};


const welcomeEmbed = new EmbedBuilder()
.setTitle(
Expand Down Expand Up @@ -119,17 +120,20 @@ export default async function settingsGeneral(
),
);

const welcomeButtons3 =
const welcomeButtons3 =
new ActionRowBuilder<MessageActionRowComponentBuilder>().addComponents(
new ButtonBuilder()
.setCustomId("welcomeMessage")
.setEmoji("1185973660465500180")
.setLabel(
client.translation.get(guildDb?.language, "Settings.button.welcomeMessage"),
client.translation.get(
guildDb?.language,
"Settings.button.welcomeMessage",
),
)
.setStyle(
guildDb.welcomeMessage ? ButtonStyle.Primary : ButtonStyle.Secondary,
)
),
);

await interaction.reply({
Expand Down
3 changes: 2 additions & 1 deletion src/commands/utility/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ const command: ChatInputCommand = {

const premiumEmoji = premium.result ? "✅" : "❌";

const { dominik, sky, skelly, paulos, tee, woofer } = client.config.emojis.info;
const { dominik, sky, skelly, paulos, tee, woofer } =
client.config.emojis.info;

const infoEmbed = new EmbedBuilder()
.setColor("#0598F6")
Expand Down
31 changes: 19 additions & 12 deletions src/commands/utility/placeholders.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { captureException } from "@sentry/node";
import {
EmbedBuilder,
type GuildMember,
type GuildMember,
SlashCommandBuilder,
} from "discord.js";
import type { ChatInputCommand } from "../../interfaces";
Expand All @@ -11,18 +11,20 @@ const command: ChatInputCommand = {
cooldown: true,
data: new SlashCommandBuilder()
.setName("placeholders")
.setDescription("Gives you a list of placeholders that you can use in your welcome messages")
.setDescription(
"Gives you a list of placeholders that you can use in your welcome messages",
)
.setContexts([0])
.setIntegrationTypes([0])
.setDescriptionLocalizations({
de: "Gibt dir eine Liste von Platzhaltern, die du in deinen Willkommensnachrichten verwenden kannst",
"es-ES": "Te da una lista de marcadores de posición que puedes usar en tus mensajes de bienvenida",
"es-ES":
"Te da una lista de marcadores de posición que puedes usar en tus mensajes de bienvenida",
fr: "Vous donne une liste de placeholders que vous pouvez utiliser dans vos messages de bienvenue",
it: "Ti fornisce un elenco di segnaposto che puoi utilizzare nei tuoi messaggi di benvenuto",
}),

execute: async (interaction, client, guildDb) => {

const member = interaction.member as GuildMember;

const placeholderMap: Record<string, string> = {
Expand All @@ -31,21 +33,26 @@ const command: ChatInputCommand = {
"{{@mention}}": `<@${member.user.id}>`,
"{{guild_name}}": member.guild.name,
"{{guild_member_count}}": member.guild.memberCount.toString(),
"{{question}}": client.translation.get(guildDb.language, "Placeholders.embed.question"),
"{{question}}": client.translation.get(
guildDb.language,
"Placeholders.embed.question",
),
"{{new_line}}": "\\n",
};

const placeholderEmbed = new EmbedBuilder()
.setColor("#0598F6")
.setTitle(client.translation.get(guildDb.language, "Placeholders.embed.title"))
.addFields(
.setTitle(
client.translation.get(guildDb.language, "Placeholders.embed.title"),
)
.addFields(
...Object.entries(placeholderMap).map(([placeholder, value]) => ({
name: placeholder,
value: value,
inline: false,
})),
name: placeholder,
value: value,
inline: false,
})),
);

await interaction
.reply({
embeds: [placeholderEmbed],
Expand Down
12 changes: 9 additions & 3 deletions src/events/guildCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,16 @@ const event: Event = {
.addFields(
{ name: "Name", value: guild.name, inline: false },
{ name: "ID", value: guild.id, inline: false },
{ name: "Users", value: guild.memberCount.toLocaleString(), inline: false },
{
name: "Users",
value: guild.memberCount.toLocaleString(),
inline: false,
},
{ name: "Server Owner", value: guild.ownerId, inline: false },
...(features ? [{ name: "Features", value: features, inline: false }] : [])
)
...(features
? [{ name: "Features", value: features, inline: false }]
: []),
),
],
allowedMentions: { parse: [] },
});
Expand Down
12 changes: 9 additions & 3 deletions src/events/guildDelete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,16 @@ const event: Event = {
.addFields([
{ name: "Name", value: guild.name, inline: false },
{ name: "ID", value: guild.id, inline: false },
{ name: "Users", value: guild.memberCount.toLocaleString(), inline: false },
{
name: "Users",
value: guild.memberCount.toLocaleString(),
inline: false,
},
{ name: "Server Owner", value: guild.ownerId, inline: false },
...(features ? [{ name: "Features", value: features, inline: false }] : []),
])
...(features
? [{ name: "Features", value: features, inline: false }]
: []),
]),
],
allowedMentions: { parse: [] },
});
Expand Down
Loading