Skip to content

Commit 048750b

Browse files
Add support for user apps (#473)
* fix: add woobly code * Add more support :) * Possible pagination fix * fix: no any type * fix: split button/command handler * fix: rework interaction create * fix: run formatter * fix: button cooldown * fix: format * fix: button + command support * add: game buttons support * add: even more button support * chore(app commands): finished --------- Co-authored-by: ForGetFulSkyBro <forgetfulskybro9@gmail.com>
1 parent 50d8a41 commit 048750b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1692
-1006
lines changed

json.json

Lines changed: 476 additions & 0 deletions
Large diffs are not rendered by default.

src/buttons/wycustom_accept.ts renamed to src/buttons/customQuestions/wycustom_accept.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
EmbedBuilder,
55
MessageActionRowComponentBuilder,
66
} from "discord.js";
7-
import { Button } from "../interfaces";
7+
import { Button } from "../../interfaces";
88

99
const button: Button = {
1010
name: "wycustom_accept",

src/buttons/wycustom_add.ts renamed to src/buttons/customQuestions/wycustom_add.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
EmbedBuilder,
55
MessageActionRowComponentBuilder,
66
} from "discord.js";
7-
import { Button } from "../interfaces";
7+
import { Button } from "../../interfaces";
88

99
const button: Button = {
1010
name: "wycustom_add",

src/buttons/wycustom_decline.ts renamed to src/buttons/customQuestions/wycustom_decline.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
EmbedBuilder,
55
MessageActionRowComponentBuilder,
66
} from "discord.js";
7-
import { Button } from "../interfaces";
7+
import { Button } from "../../interfaces";
88

99
const button: Button = {
1010
name: "wycustom_decline",

src/buttons/wycustom_remove.ts renamed to src/buttons/customQuestions/wycustom_remove.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
MessageActionRowComponentBuilder,
66
ButtonStyle,
77
} from "discord.js";
8-
import { Button } from "../interfaces";
8+
import { Button } from "../../interfaces";
99

1010
const button: Button = {
1111
name: "wycustom_remove",

src/buttons/dailyChannel.ts renamed to src/buttons/dailyTasks/dailyChannel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
ChannelSelectMenuBuilder,
55
MessageActionRowComponentBuilder,
66
} from "discord.js";
7-
import { Button } from "../interfaces";
7+
import { Button } from "../../interfaces";
88

99
const button: Button = {
1010
name: "dailyChannel",

src/buttons/deleteDailyRole.ts renamed to src/buttons/dailyTasks/dailyDeleteRole.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
ButtonStyle,
66
MessageActionRowComponentBuilder,
77
} from "discord.js";
8-
import { Button } from "../interfaces";
8+
import { Button } from "../../interfaces";
99

1010
const button: Button = {
1111
name: "deleteDailyRole",

src/buttons/dailyInterval.ts renamed to src/buttons/dailyTasks/dailyInterval.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
ButtonStyle,
66
MessageActionRowComponentBuilder,
77
} from "discord.js";
8-
import { Button } from "../interfaces";
8+
import { Button } from "../../interfaces";
99

1010
const modalObject = {
1111
title: "Daily Post Time",

src/buttons/dailyMsg.ts renamed to src/buttons/dailyTasks/dailyMsg.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
ButtonStyle,
66
MessageActionRowComponentBuilder,
77
} from "discord.js";
8-
import { Button } from "../interfaces";
8+
import { Button } from "../../interfaces";
99

1010
const button: Button = {
1111
name: "dailyMsg",

src/buttons/dailyRole.ts renamed to src/buttons/dailyTasks/dailyRole.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
MessageActionRowComponentBuilder,
66
ButtonStyle,
77
} from "discord.js";
8-
import { Button } from "../interfaces";
8+
import { Button } from "../../interfaces";
99

1010
const button: Button = {
1111
name: "dailyRole",

src/buttons/dailyThread.ts renamed to src/buttons/dailyTasks/dailyThread.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
ButtonStyle,
66
MessageActionRowComponentBuilder,
77
} from "discord.js";
8-
import { Button } from "../interfaces";
8+
import { Button } from "../../interfaces";
99

1010
const button: Button = {
1111
name: "dailyThread",

src/buttons/dailyTimezone.ts renamed to src/buttons/dailyTasks/dailyTimezone.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
ButtonStyle,
66
} from "discord.js";
77
import { captureException } from "@sentry/node";
8-
import { Button } from "../interfaces";
8+
import { Button } from "../../interfaces";
99

1010
const modalObject = {
1111
title: "Daily Message Timezone",

src/buttons/dailyType.ts renamed to src/buttons/dailyTasks/dailyType.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
MessageActionRowComponentBuilder,
44
StringSelectMenuBuilder,
55
} from "discord.js";
6-
import { Button } from "../interfaces";
6+
import { Button } from "../../interfaces";
77

88
const button: Button = {
99
name: "dailyType",

src/buttons/dare.ts renamed to src/buttons/gamesActivities/dare.ts

Lines changed: 51 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,56 +8,68 @@ import {
88
ButtonInteraction,
99
} from "discord.js";
1010
import { captureException } from "@sentry/node";
11-
import shuffle from "../util/shuffle";
12-
import { Button } from "../interfaces";
13-
import { getDare } from "../util/Functions/jsonImport";
11+
import shuffle from "../../util/shuffle";
12+
import { Button } from "../../interfaces";
13+
14+
import { getDare } from "../../util/Functions/jsonImport";
1415

1516
const button: Button = {
1617
name: "dare",
1718
execute: async (interaction: any, client, guildDb) => {
18-
if (interaction.channel.isThread()) {
19-
if (
20-
!interaction.channel
21-
?.permissionsFor(interaction.user.id)
22-
.has(PermissionFlagsBits.SendMessagesInThreads)
23-
) {
24-
return interaction.reply({
25-
content:
26-
"You don't have permission to use this button in this channel!",
27-
ephemeral: true,
28-
});
29-
}
30-
} else {
31-
if (
32-
!interaction.channel
33-
?.permissionsFor(interaction.user.id)
34-
.has(PermissionFlagsBits.SendMessages)
35-
) {
36-
return interaction.reply({
37-
content:
38-
"You don't have permission to use this button in this channel!",
39-
ephemeral: true,
40-
});
19+
if (interaction.guild) {
20+
if (interaction.channel.isThread()) {
21+
if (
22+
!interaction.channel
23+
?.permissionsFor(interaction.user.id)
24+
.has(PermissionFlagsBits.SendMessagesInThreads)
25+
) {
26+
return interaction.reply({
27+
content:
28+
"You don't have permission to use this button in this channel!",
29+
ephemeral: true,
30+
});
31+
}
32+
} else {
33+
if (
34+
!interaction.channel
35+
?.permissionsFor(interaction.user.id)
36+
.has(PermissionFlagsBits.SendMessages)
37+
) {
38+
return interaction.reply({
39+
content:
40+
"You don't have permission to use this button in this channel!",
41+
ephemeral: true,
42+
});
43+
}
4144
}
4245
}
4346

44-
let Dare = await getDare(guildDb.language);
45-
const dbquestions = guildDb.customMessages.filter((c) => c.type === "dare");
47+
let Dare = await getDare(
48+
guildDb?.language != null ? guildDb.language : "en_EN",
49+
);
50+
51+
let dbquestions;
4652

4753
let truthordare = [] as string[];
4854

49-
if (!dbquestions.length) guildDb.customTypes = "regular";
55+
if (guildDb != null) {
56+
dbquestions = guildDb.customMessages.filter((c) => c.type === "dare");
5057

51-
switch (guildDb.customTypes) {
52-
case "regular":
53-
truthordare = shuffle([...Dare]);
54-
break;
55-
case "mixed":
56-
truthordare = shuffle([...Dare, ...dbquestions.map((c) => c.msg)]);
57-
break;
58-
case "custom":
59-
truthordare = shuffle(dbquestions.map((c) => c.msg));
60-
break;
58+
if (!dbquestions.length) guildDb.customTypes = "regular";
59+
60+
switch (guildDb.customTypes) {
61+
case "regular":
62+
truthordare = shuffle([...Dare]);
63+
break;
64+
case "mixed":
65+
truthordare = shuffle([...Dare, ...dbquestions.map((c) => c.msg)]);
66+
break;
67+
case "custom":
68+
truthordare = shuffle(dbquestions.map((c) => c.msg));
69+
break;
70+
}
71+
} else {
72+
truthordare = shuffle([...Dare]);
6173
}
6274

6375
const Random = Math.floor(Math.random() * truthordare.length);

src/buttons/higher.ts renamed to src/buttons/gamesActivities/higher.ts

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import {
66
AttachmentBuilder,
77
MessageActionRowComponentBuilder,
88
} from "discord.js";
9-
import { HigherlowerModel } from "../util/Models/higherlowerModel";
10-
import LOSE from "../util/Classes/generateLOSE";
11-
import HOR from "../util/Classes/generateHOR";
12-
import { Button } from "../interfaces";
13-
import { getHigherLower } from "../util/Functions/jsonImport";
9+
import { HigherlowerModel } from "../../util/Models/higherlowerModel";
10+
import LOSE from "../../util/Classes/generateLOSE";
11+
import HOR from "../../util/Classes/generateHOR";
12+
import { Button } from "../../interfaces";
13+
14+
import { getHigherLower } from "../../util/Functions/jsonImport";
1415

1516
const button: Button = {
1617
name: "higher",
@@ -83,14 +84,20 @@ const button: Button = {
8384
const gameEmbed = new EmbedBuilder()
8485

8586
.setDescription(
86-
client.translation.get(guildDb?.language, "HigherLower.description", {
87-
keyword: game.items.current.keyword,
88-
history: game.items.history[game.items.history.length - 1].keyword,
89-
source: game.items.current.link || "https://wouldyoubot.gg/nolink",
90-
source2:
91-
game.items.history[game.items.history.length - 1].link ||
92-
"https://wouldyoubot.gg/nolink",
93-
}),
87+
client.translation.get(
88+
guildDb?.language != null ? guildDb.language : "en_EN",
89+
"HigherLower.description",
90+
{
91+
keyword: game.items.current.keyword,
92+
history:
93+
game.items.history[game.items.history.length - 1].keyword,
94+
source:
95+
game.items.current.link || "https://wouldyoubot.gg/nolink",
96+
source2:
97+
game.items.history[game.items.history.length - 1].link ||
98+
"https://wouldyoubot.gg/nolink",
99+
},
100+
),
94101
)
95102
.setColor("Green")
96103
.setImage("attachment://game.png")
@@ -127,11 +134,14 @@ const button: Button = {
127134
} else {
128135
const loseEmbed = new EmbedBuilder()
129136
.setTitle(
130-
client.translation.get(guildDb?.language, "HigherLower.game.title"),
137+
client.translation.get(
138+
guildDb?.language != null ? guildDb.language : "en_EN",
139+
"HigherLower.game.title",
140+
),
131141
)
132142
.setDescription(
133143
`${client.translation.get(
134-
guildDb?.language,
144+
guildDb?.language != null ? guildDb.language : "en_EN",
135145
"HigherLower.game.description",
136146
{
137147
score: game?.score,

src/buttons/lower.ts renamed to src/buttons/gamesActivities/lower.ts

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@ import {
66
AttachmentBuilder,
77
MessageActionRowComponentBuilder,
88
} from "discord.js";
9-
import { HigherlowerModel } from "../util/Models/higherlowerModel";
10-
import LOSE from "../util/Classes/generateLOSE";
11-
import HOR from "../util/Classes/generateHOR";
12-
import { Button } from "../interfaces";
13-
import { getHigherLower } from "../util/Functions/jsonImport";
9+
import { HigherlowerModel } from "../../util/Models/higherlowerModel";
10+
import LOSE from "../../util/Classes/generateLOSE";
11+
import HOR from "../../util/Classes/generateHOR";
12+
import { Button } from "../../interfaces";
13+
14+
import { getHigherLower } from "../../util/Functions/jsonImport";
1415

1516
const button: Button = {
1617
name: "lower",
1718
execute: async (interaction, client, guildDb) => {
1819
if (interaction.message.interaction?.user.id !== interaction.user.id) {
1920
interaction.reply({
2021
content: client.translation.get(
21-
guildDb?.language,
22+
guildDb?.language != null ? guildDb.language : "en_EN",
2223
"HigherLower.error.user",
2324
{
2425
user: interaction.message.interaction?.user.username,
@@ -83,14 +84,20 @@ const button: Button = {
8384
const gameEmbed = new EmbedBuilder()
8485

8586
.setDescription(
86-
client.translation.get(guildDb?.language, "HigherLower.description", {
87-
keyword: game.items.current.keyword,
88-
history: game.items.history[game.items.history.length - 1].keyword,
89-
source: game.items.current.link || "https://wouldyoubot.gg/nolink",
90-
source2:
91-
game.items.history[game.items.history.length - 1].link ||
92-
"https://wouldyoubot.gg/nolink",
93-
}),
87+
client.translation.get(
88+
guildDb?.language != null ? guildDb.language : "en_EN",
89+
"HigherLower.description",
90+
{
91+
keyword: game.items.current.keyword,
92+
history:
93+
game.items.history[game.items.history.length - 1].keyword,
94+
source:
95+
game.items.current.link || "https://wouldyoubot.gg/nolink",
96+
source2:
97+
game.items.history[game.items.history.length - 1].link ||
98+
"https://wouldyoubot.gg/nolink",
99+
},
100+
),
94101
)
95102
.setColor("Green")
96103
.setImage("attachment://game.png")
@@ -127,11 +134,14 @@ const button: Button = {
127134
} else {
128135
const loseEmbed = new EmbedBuilder()
129136
.setTitle(
130-
client.translation.get(guildDb?.language, "HigherLower.game.title"),
137+
client.translation.get(
138+
guildDb?.language != null ? guildDb.language : "en_EN",
139+
"HigherLower.game.title",
140+
),
131141
)
132142
.setDescription(
133143
`${client.translation.get(
134-
guildDb?.language,
144+
guildDb?.language != null ? guildDb.language : "en_EN",
135145
"HigherLower.game.description",
136146
{
137147
score: game?.score,

0 commit comments

Comments
 (0)