Skip to content

Commit

Permalink
fix: a bunch of things
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik K committed Dec 10, 2023
1 parent db0d4b9 commit b5c0cf1
Show file tree
Hide file tree
Showing 20 changed files with 107 additions and 385 deletions.
28 changes: 8 additions & 20 deletions src/buttons/dailyInterval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ function isFormat(str: string) {
const button: Button = {
name: "dailyInterval",
execute: async (interaction, client, guildDb) => {
interaction.showModal(modalObject).catch(() => {});

await interaction.showModal(modalObject);

interaction
.awaitModalSubmit({
filter: (mInter) => mInter.customId === modalObject.custom_id,
time: 60000,
time: 6000000,
})
.then(async (modalInteraction) => {
const value = modalInteraction.components[0].components[0].value;
Expand Down Expand Up @@ -69,27 +71,17 @@ const button: Button = {
`${client.translation.get(
guildDb?.language,
"Settings.embed.dailyMsg",
)}: ${
guildDb.dailyMsg
? `<:check:1077962440815411241>`
: `<:x_:1077962443013238814>`
}\n` +
)}: ${guildDb.dailyMsg ? ":white_check_mark:" : ":x:"}\n` +
`${client.translation.get(
guildDb?.language,
"Settings.embed.dailyChannel",
)}: ${
guildDb.dailyChannel
? `<#${guildDb.dailyChannel}>`
: `<:x_:1077962443013238814>`
guildDb.dailyChannel ? `<#${guildDb.dailyChannel}>` : ":x:"
}\n` +
`${client.translation.get(
guildDb?.language,
"Settings.embed.dailyRole",
)}: ${
guildDb.dailyRole
? `<@&${guildDb.dailyRole}>`
: `<:x_:1077962443013238814>`
}\n` +
)}: ${guildDb.dailyRole ? `<@&${guildDb.dailyRole}>` : ":x:"}\n` +
`${client.translation.get(
guildDb?.language,
"Settings.embed.dailyTimezone",
Expand All @@ -105,11 +97,7 @@ const button: Button = {
`${client.translation.get(
guildDb?.language,
"Settings.embed.dailyThread",
)}: ${
guildDb.dailyThread
? `<:check:1077962440815411241>`
: `<:x_:1077962443013238814>`
}`,
)}: ${guildDb.dailyThread ? ":white_check_mark:" : ":x:"}`,
)
.setColor("#0598F6");

Expand Down
18 changes: 4 additions & 14 deletions src/buttons/dailyMsg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,16 @@ const button: Button = {
`${client.translation.get(
guildDb?.language,
"Settings.embed.dailyMsg",
)}: ${
check ? `<:x_:1077962443013238814>` : `<:check:1077962440815411241>`
}\n${client.translation.get(
)}: ${check ? ":x:" : ":white_check_mark:"}\n${client.translation.get(
guildDb?.language,
"Settings.embed.dailyChannel",
)}: ${
guildDb.dailyChannel
? `<#${guildDb.dailyChannel}>`
: `<:x_:1077962443013238814>`
guildDb.dailyChannel ? `<#${guildDb.dailyChannel}>` : ":x:"
}\n${client.translation.get(
guildDb?.language,
"Settings.embed.dailyRole",
)}: ${
guildDb.dailyRole
? `<@&${guildDb.dailyRole}>`
: `<:x_:1077962443013238814>`
guildDb.dailyRole ? `<@&${guildDb.dailyRole}>` : ":x:"
}\n${client.translation.get(
guildDb?.language,
"Settings.embed.dailyTimezone",
Expand All @@ -48,11 +42,7 @@ const button: Button = {
`${client.translation.get(
guildDb?.language,
"Settings.embed.dailyThread",
)}: ${
guildDb.dailyThread
? `<:check:1077962440815411241>`
: `<:x_:1077962443013238814>`
}`,
)}: ${guildDb.dailyThread ? ":white_check_mark:" : ":x:"}`,
)
.setColor("#0598F6");

Expand Down
16 changes: 4 additions & 12 deletions src/buttons/dailyThread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,17 @@ const button: Button = {
guildDb?.language,
"Settings.embed.dailyMsg",
)}: ${
guildDb.dailyMsg
? `<:check:1077962440815411241>`
: `<:x_:1077962443013238814>`
guildDb.dailyMsg ? ":white_check_mark:" : ":x:"
}\n${client.translation.get(
guildDb?.language,
"Settings.embed.dailyChannel",
)}: ${
guildDb.dailyChannel
? `<#${guildDb.dailyChannel}>`
: `<:x_:1077962443013238814>`
guildDb.dailyChannel ? `<#${guildDb.dailyChannel}>` : ":x:"
}\n${client.translation.get(
guildDb?.language,
"Settings.embed.dailyRole",
)}: ${
guildDb.dailyRole
? `<@&${guildDb.dailyRole}>`
: `<:x_:1077962443013238814>`
guildDb.dailyRole ? `<@&${guildDb.dailyRole}>` : ":x:"
}\n${client.translation.get(
guildDb?.language,
"Settings.embed.dailyTimezone",
Expand All @@ -50,9 +44,7 @@ const button: Button = {
`${client.translation.get(
guildDb?.language,
"Settings.embed.dailyThread",
)}: ${
check ? `<:x_:1077962443013238814>` : `<:check:1077962440815411241>`
}`,
)}: ${check ? ":x:" : ":white_check_mark:"}`,
)
.setColor("#0598F6");

Expand Down
27 changes: 10 additions & 17 deletions src/buttons/dailyTimezone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Button } from "../models";

const modalObject = {
title: "Daily Message Timezone",
custom_id: "modal",
custom_id: "dailyTimezone",
components: [
{
type: 1,
Expand All @@ -34,7 +34,7 @@ function isValid(tz: string) {
Intl.DateTimeFormat(undefined, { timeZone: tz });
return true;
} catch (err) {
//captureException(err);
captureException(err);
return false;
}
}
Expand All @@ -50,10 +50,13 @@ function dateType(tz: string) {
const button: Button = {
name: "dailyTimezone",
execute: async (interaction, client, guildDb) => {

await interaction.showModal(modalObject);

interaction
.awaitModalSubmit({
filter: (mInter) => mInter.customId === modalObject.custom_id,
time: 60000,
time: 6000000,
})
.then(async (modalInteraction) => {
const value = modalInteraction.components[0].components[0].value;
Expand Down Expand Up @@ -95,23 +98,17 @@ const button: Button = {
guildDb?.language,
"Settings.embed.dailyMsg",
)}: ${
guildDb.dailyMsg
? `<:check:1077962440815411241>`
: `<:x_:1077962443013238814>`
guildDb.dailyMsg ? ":white_check_mark:" : ":x:"
}\n${client.translation.get(
guildDb?.language,
"Settings.embed.dailyChannel",
)}: ${
guildDb.dailyChannel
? `<#${guildDb.dailyChannel}>`
: `<:x_:1077962443013238814>`
guildDb.dailyChannel ? `<#${guildDb.dailyChannel}>` : ":x:"
}\n${client.translation.get(
guildDb?.language,
"Settings.embed.dailyRole",
)}: ${
guildDb.dailyRole
? `<@&${guildDb.dailyRole}>`
: `<:x_:1077962443013238814>`
guildDb.dailyRole ? `<@&${guildDb.dailyRole}>` : ":x:"
}\n${client.translation.get(
guildDb?.language,
"Settings.embed.dailyTimezone",
Expand All @@ -125,11 +122,7 @@ const button: Button = {
`${client.translation.get(
guildDb?.language,
"Settings.embed.dailyThread",
)}: ${
guildDb.dailyThread
? `<:check:1077962440815411241>`
: `<:x_:1077962443013238814>`
}`,
)}: ${guildDb.dailyThread ? ":white_check_mark:" : ":x:"}`,
)
.setColor("#0598F6");

Expand Down
14 changes: 3 additions & 11 deletions src/buttons/deleteDailyRole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,12 @@ const button: Button = {
guildDb?.language,
"Settings.embed.dailyMsg",
)}: ${
guildDb.dailyMsg
? `<:check:1077962440815411241>`
: `<:x_:1077962443013238814>`
guildDb.dailyMsg ? ":white_check_mark:" : ":x:"
}\n${client.translation.get(
guildDb?.language,
"Settings.embed.dailyChannel",
)}: ${
guildDb.dailyChannel
? `<#${guildDb.dailyChannel}>`
: `<:x_:1077962443013238814>`
guildDb.dailyChannel ? `<#${guildDb.dailyChannel}>` : ":x:"
}\n${client.translation.get(
guildDb?.language,
"Settings.embed.dailyRole",
Expand All @@ -45,11 +41,7 @@ const button: Button = {
`${client.translation.get(
guildDb?.language,
"Settings.embed.dailyThread",
)}: ${
guildDb.dailyThread
? `<:check:1077962440815411241>`
: `<:x_:1077962443013238814>`
}`,
)}: ${guildDb.dailyThread ? ":white_check_mark:" : ":x:"}`,
)
.setColor("#0598F6");

Expand Down
13 changes: 7 additions & 6 deletions src/buttons/replayCooldown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import { Button } from "../models";
const modalObject = {
title: "Replay Cooldown",
custom_id: "replaymodal",
custom_id: "replayCooldown",
components: [
{
type: 1,
Expand All @@ -30,10 +30,13 @@ function isNumericRegex(str: string) {
const button: Button = {
name: "replayCooldown",
execute: async (interaction, client, guildDb) => {

await interaction.showModal(modalObject);

interaction
.awaitModalSubmit({
filter: (mInter) => mInter.customId === modalObject.custom_id,
time: 60000,
time: 6000000,
})
.then(async (modalInteraction) => {
const value = modalInteraction.components[0].components[0].value;
Expand Down Expand Up @@ -83,9 +86,7 @@ const button: Button = {
)}: ${guildDb.replayType}\n${client.translation.get(
guildDb?.language,
"Settings.embed.replayCooldown",
)}: ${
guildDb.replayCooldown ? `${value}` : `<:x_:1077962443013238814>`
}\n`,
)}: ${guildDb.replayCooldown ? `${Math.min(Number(value), 86400000)}` : ":x:"}\n`,
)
.setColor("#0598F6")
.setFooter({
Expand Down Expand Up @@ -134,7 +135,7 @@ const button: Button = {

await client.database.updateGuild(interaction.guild?.id || "", {
...guildDb,
replayCooldown: Number(value),
replayCooldown: Math.min(Number(value), 86400000),
});

(modalInteraction as any).update({
Expand Down
10 changes: 3 additions & 7 deletions src/buttons/selectMenuChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,15 @@ const button: Button = {
guildDb?.language,
"Settings.embed.dailyMsg",
)}: ${
guildDb.dailyMsg
? `<:check:1077962440815411241>`
: `<:x_:1077962443013238814>`
guildDb.dailyMsg ? ":white_check_mark:" : ":x:"
}\n${client.translation.get(
guildDb?.language,
"Settings.embed.dailyChannel",
)}: <#${newChannel}>\n${client.translation.get(
guildDb?.language,
"Settings.embed.dailyRole",
)}: ${
guildDb.dailyRole
? `<@&${guildDb.dailyRole}>`
: `<:x_:1077962443013238814>`
guildDb.dailyRole ? `<@&${guildDb.dailyRole}>` : ":x:"
}\n${client.translation.get(
guildDb?.language,
"Settings.embed.dailyTimezone",
Expand All @@ -48,7 +44,7 @@ const button: Button = {
"Settings.embed.dailyThread",
)}: ${
guildDb.dailyThread
? `<:check:1077962440815411241>`
? ":white_check_mark:"
: `<:x:1077962443013238814>`
}`,
)
Expand Down
7 changes: 5 additions & 2 deletions src/buttons/selectMenuReplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Button } from "../models";

const modalObject = {
title: "Replay Cooldown",
custom_id: "replaymodal",
custom_id: "selectMenuReplay",
components: [
{
type: 1,
Expand All @@ -32,10 +32,13 @@ function isNumericRegex(str: string) {
const button: Button = {
name: "selectMenuReplay",
execute: async (interaction, client, guildDb) => {

await interaction.showModal(modalObject);

interaction
.awaitModalSubmit({
filter: (mInter) => mInter.customId === modalObject.custom_id,
time: 60000,
time: 600000,
})
.then(async (modalInteraction) => {
const value = modalInteraction.components[0].components[0].value;
Expand Down
14 changes: 3 additions & 11 deletions src/buttons/selectMenuRole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,12 @@ const button: Button = {
guildDb?.language,
"Settings.embed.dailyMsg",
)}: ${
guildDb.dailyMsg
? `<:check:1077962440815411241>`
: `<:x_:1077962443013238814>`
guildDb.dailyMsg ? ":white_check_mark:" : ":x:"
}\n${client.translation.get(
guildDb?.language,
"Settings.embed.dailyChannel",
)}: ${
guildDb.dailyChannel
? `<#${guildDb.dailyChannel}>`
: `<:x_:1077962443013238814>`
guildDb.dailyChannel ? `<#${guildDb.dailyChannel}>` : ":x:"
}\n${client.translation.get(
guildDb?.language,
"Settings.embed.dailyRole",
Expand All @@ -46,11 +42,7 @@ const button: Button = {
`${client.translation.get(
guildDb?.language,
"Settings.embed.dailyThread",
)}: ${
guildDb.dailyThread
? `<:check:1077962440815411241>`
: `<:x_:1077962443013238814>`
}`,
)}: ${guildDb.dailyThread ? ":white_check_mark:" : ":x:"}`,
)
.setColor("#0598F6");

Expand Down
Loading

0 comments on commit b5c0cf1

Please sign in to comment.