Skip to content

Commit 77d4111

Browse files
author
Dominik K
committed
feat(language): allow language change in dms
1 parent 5a76b01 commit 77d4111

File tree

16 files changed

+156
-125
lines changed

16 files changed

+156
-125
lines changed

.deepsource.toml

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/buttons/gamesActivities/dare.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import shuffle from "../../util/shuffle";
1212
import { Button } from "../../interfaces";
1313

1414
import { getDare } from "../../util/Functions/jsonImport";
15+
import { UserModel, IUserModel } from "../../util/Models/userModel";
1516

1617
const button: Button = {
1718
name: "dare",
@@ -45,8 +46,10 @@ const button: Button = {
4546
}
4647
}
4748

49+
const userDb = await UserModel.findOne({ userID: interaction.user?.id }) as IUserModel;
50+
4851
let Dare = await getDare(
49-
guildDb?.language != null ? guildDb.language : "en_EN",
52+
guildDb?.language != null ? guildDb.language : userDb.language,
5053
);
5154

5255
let dbquestions;

src/buttons/gamesActivities/higherlower.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { getHigherLower } from "../../util/Functions/jsonImport";
1515
import { HigherLowerEmbed } from "../../util/Defaults/Embeds/Games/HigherLowerEmbed";
1616
import { HigherlowerModel } from "../../util/Models/higherlowerModel";
1717
import HOR from "../../util/Classes/generateHOR";
18+
import { IUserModel, UserModel } from "../../util/Models/userModel";
1819

1920
const button: Button = {
2021
name: "higherlower",
@@ -49,6 +50,8 @@ const button: Button = {
4950
}
5051
await interaction.deferReply();
5152

53+
const userDb = await UserModel.findOne({ userID: interaction.user?.id }) as IUserModel;
54+
5255
const initembed = new HigherLowerEmbed(interaction, client, guildDb);
5356

5457
await interaction.editReply({ embeds: [initembed] });
@@ -93,7 +96,7 @@ const button: Button = {
9396

9497
.setDescription(
9598
`${client.translation.get(
96-
guildDb?.language,
99+
guildDb?.language != null ? guildDb.language : userDb.language,
97100
"HigherLower.description",
98101
{
99102
keyword: game.items.current.keyword,

src/buttons/gamesActivities/neverhaveiever.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import shuffle from "../../util/shuffle";
1111
import { Button } from "../../interfaces";
1212

1313
import { getNeverHaveIEver } from "../../util/Functions/jsonImport";
14+
import { UserModel, IUserModel } from "../../util/Models/userModel";
1415

1516
const button: Button = {
1617
name: "neverhaveiever",
@@ -44,8 +45,10 @@ const button: Button = {
4445
}
4546
}
4647

48+
const userDb = await UserModel.findOne({ userID: interaction.user?.id }) as IUserModel;
49+
4750
let { Funny, Basic, Young, Food, RuleBreak } = await getNeverHaveIEver(
48-
guildDb?.language != null ? guildDb.language : "en_EN",
51+
guildDb?.language != null ? guildDb.language : userDb.language,
4952
);
5053

5154
let dbquestions;

src/commands/game/dare.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import shuffle from "../../util/shuffle";
1010
import { captureException } from "@sentry/node";
1111
import { ChatInputCommand } from "../../interfaces";
1212
import { getDare } from "../../util/Functions/jsonImport";
13+
import { UserModel, IUserModel } from "../../util/Models/userModel";
1314

1415
const command: ChatInputCommand = {
1516
requireGuild: true,
@@ -29,8 +30,11 @@ const command: ChatInputCommand = {
2930
* @param {guildModel} guildDb
3031
*/
3132
execute: async (interaction, client, guildDb) => {
33+
34+
const userDb = await UserModel.findOne({ userID: interaction.user?.id }) as IUserModel;
35+
3236
let Dare = await getDare(
33-
guildDb?.language != null ? guildDb.language : "en_EN",
37+
guildDb?.language != null ? guildDb.language : userDb.language,
3438
);
3539

3640
let dbquestions;

src/commands/game/higherlower.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { ChatInputCommand } from "../../interfaces";
1313
import { HigherlowerModel } from "../../util/Models/higherlowerModel";
1414
import { getHigherLower } from "../../util/Functions/jsonImport";
1515
import { HigherLowerEmbed } from "../../util/Defaults/Embeds/Games/HigherLowerEmbed";
16+
import { UserModel, IUserModel } from "../../util/Models/userModel";
1617

1718
const command: ChatInputCommand = {
1819
requireGuild: true,
@@ -35,6 +36,8 @@ const command: ChatInputCommand = {
3536
execute: async (interaction, client, guildDb) => {
3637
await interaction.deferReply();
3738

39+
const userDb = await UserModel.findOne({ userID: interaction.user?.id }) as IUserModel;
40+
3841
const initembed = new HigherLowerEmbed(interaction, client, guildDb);
3942

4043
await interaction.editReply({ embeds: [initembed] });
@@ -79,7 +82,7 @@ const command: ChatInputCommand = {
7982

8083
.setDescription(
8184
`${client.translation.get(
82-
guildDb?.language,
85+
guildDb?.language != null ? guildDb.language : userDb.language,
8386
"HigherLower.description",
8487
{
8588
keyword: game.items.current.keyword,

src/commands/game/leaderboard.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { EmbedBuilder, SlashCommandBuilder } from "discord.js";
22
import { ChatInputCommand } from "../../interfaces";
33
import Paginator from "../../util/pagination";
4-
import { UserModel } from "../../util/Models/userModel";
4+
import { IUserModel, UserModel } from "../../util/Models/userModel";
55

66
const command: ChatInputCommand = {
77
requireGuild: true,
@@ -38,6 +38,10 @@ const command: ChatInputCommand = {
3838
* @param {guildModel} guildDb
3939
*/
4040
execute: async (interaction, client, guildDb) => {
41+
const userDb = await UserModel.findOne({ userID: interaction.user?.id }) as IUserModel;
42+
43+
let language = guildDb?.language != null ? guildDb.language : userDb.language;
44+
4145
switch (interaction.options.getString("game")) {
4246
case "higherlower":
4347
const page = new Paginator({
@@ -67,7 +71,7 @@ const command: ChatInputCommand = {
6771
if (data.length === 0) {
6872
interaction.reply({
6973
content: client.translation.get(
70-
guildDb?.language,
74+
language,
7175
"Leaderboard.none",
7276
),
7377
});
@@ -79,11 +83,11 @@ const command: ChatInputCommand = {
7983
`${i++}. ${
8084
s.user === "Anonymous"
8185
? `${s.user} • **${s.score}** ${client.translation.get(
82-
guildDb?.language,
86+
language,
8387
"Leaderboard.points",
8488
)}`
8589
: `<@${s.user}> • **${s.score}** ${client.translation.get(
86-
guildDb?.language,
90+
language,
8791
"Leaderboard.points",
8892
)}`
8993
}`,
@@ -93,7 +97,7 @@ const command: ChatInputCommand = {
9397
new EmbedBuilder()
9498
.setTitle(
9599
client.translation.get(
96-
guildDb?.language,
100+
language,
97101
"Leaderboard.global",
98102
),
99103
)
@@ -113,7 +117,7 @@ const command: ChatInputCommand = {
113117
new EmbedBuilder()
114118
.setTitle(
115119
client.translation.get(
116-
guildDb?.language,
120+
language,
117121
"Leaderboard.global",
118122
),
119123
)
@@ -144,7 +148,7 @@ const command: ChatInputCommand = {
144148
if (data.length === 0) {
145149
interaction.reply({
146150
content: client.translation.get(
147-
guildDb?.language,
151+
language,
148152
"Leaderboard.none",
149153
),
150154
});
@@ -156,11 +160,11 @@ const command: ChatInputCommand = {
156160
`${i++}. ${
157161
s.user === "Anonymous"
158162
? `${s.user} • **${s.score}** ${client.translation.get(
159-
guildDb?.language,
163+
language,
160164
"Leaderboard.points",
161165
)}`
162166
: `<@${s.user}> • **${s.score}** ${client.translation.get(
163-
guildDb?.language,
167+
language,
164168
"Leaderboard.points",
165169
)}`
166170
}`,
@@ -178,7 +182,7 @@ const command: ChatInputCommand = {
178182
new EmbedBuilder()
179183
.setTitle(
180184
client.translation.get(
181-
guildDb?.language,
185+
language,
182186
"Leaderboard.guild",
183187
),
184188
)

src/commands/game/neverhaveiever.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { captureException } from "@sentry/node";
1010
import shuffle from "../../util/shuffle";
1111
import { ChatInputCommand } from "../../interfaces";
1212
import { getNeverHaveIEver } from "../../util/Functions/jsonImport";
13+
import { UserModel, IUserModel } from "../../util/Models/userModel";
1314

1415
const command: ChatInputCommand = {
1516
requireGuild: true,
@@ -30,8 +31,11 @@ const command: ChatInputCommand = {
3031
*/
3132

3233
execute: async (interaction, client, guildDb) => {
34+
35+
let userDb = await UserModel.findOne({ userID: interaction.user?.id }) as IUserModel;
36+
3337
let { Funny, Basic, Young, Food, RuleBreak } = await getNeverHaveIEver(
34-
guildDb?.language != null ? guildDb.language : "en_EN",
38+
guildDb?.language != null ? guildDb.language : userDb.language,
3539
);
3640

3741
let dbquestions;

src/commands/game/random.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import shuffle from "../../util/shuffle";
1010
import { captureException } from "@sentry/node";
1111
import { ChatInputCommand } from "../../interfaces";
1212
import { getRandomTod } from "../../util/Functions/jsonImport";
13+
import { UserModel, IUserModel } from "../../util/Models/userModel";
1314

1415
const command: ChatInputCommand = {
1516
requireGuild: true,
@@ -30,8 +31,11 @@ const command: ChatInputCommand = {
3031
* @param {guildModel} guildDb
3132
*/
3233
execute: async (interaction, client, guildDb) => {
34+
35+
const userDb = await UserModel.findOne({ userID: interaction.user?.id }) as IUserModel;
36+
3337
let Randomtod = await getRandomTod(
34-
guildDb?.language != null ? guildDb.language : "en_EN",
38+
guildDb?.language != null ? guildDb.language : userDb.language,
3539
);
3640

3741
let dbquestions;

src/commands/game/truth.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import shuffle from "../../util/shuffle";
1010
import { captureException } from "@sentry/node";
1111
import { ChatInputCommand } from "../../interfaces";
1212
import { getTruth } from "../../util/Functions/jsonImport";
13+
import { UserModel, IUserModel } from "../../util/Models/userModel";
1314

1415
const command: ChatInputCommand = {
1516
requireGuild: true,
@@ -29,8 +30,11 @@ const command: ChatInputCommand = {
2930
* @param {guildModel} guildDb
3031
*/
3132
execute: async (interaction, client, guildDb) => {
33+
34+
const userDb = await UserModel.findOne({ userID: interaction.user?.id }) as IUserModel;
35+
3236
let Truth = await getTruth(
33-
guildDb?.language != null ? guildDb.language : "en_EN",
37+
guildDb?.language != null ? guildDb.language : userDb.language,
3438
);
3539

3640
let dbquestions;

src/commands/game/whatwouldyoudo.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import shuffle from "../../util/shuffle";
1010
import { captureException } from "@sentry/node";
1111
import { ChatInputCommand } from "../../interfaces";
1212
import { getWwyd } from "../../util/Functions/jsonImport";
13+
import { IUserModel, UserModel } from "../../util/Models/userModel";
1314

1415
const command: ChatInputCommand = {
1516
requireGuild: true,
@@ -28,8 +29,11 @@ const command: ChatInputCommand = {
2829
* @param {guildModel} guildDb
2930
*/
3031
execute: async (interaction, client, guildDb) => {
32+
33+
const userDb = await UserModel.findOne({ userID: interaction.user?.id }) as IUserModel;
34+
3135
let WWYD = await getWwyd(
32-
guildDb?.language != null ? guildDb.language : "en_EN",
36+
guildDb?.language != null ? guildDb.language : userDb.language,
3337
);
3438

3539
let dbquestions;

src/commands/game/wouldyourather.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { captureException } from "@sentry/node";
99
import { ChatInputCommand } from "../../interfaces";
1010
import { getWouldYouRather } from "../../util/Functions/jsonImport";
1111
import { DefaultGameEmbed } from "../../util/Defaults/Embeds/Games/DefaultGameEmbed";
12+
import { IUserModel, UserModel } from "../../util/Models/userModel";
1213

1314
const command: ChatInputCommand = {
1415
requireGuild: true,
@@ -29,8 +30,11 @@ const command: ChatInputCommand = {
2930
*/
3031

3132
execute: async (interaction, client, guildDb) => {
33+
34+
const userDb = await UserModel.findOne({ userID: interaction.user?.id }) as IUserModel;
35+
3236
let General = await getWouldYouRather(
33-
guildDb?.language != null ? guildDb.language : "en_EN",
37+
guildDb?.language != null ? guildDb.language : userDb.language,
3438
);
3539

3640
let dbquestions;

src/commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ const commandInteractionEvent: Event = {
7272
"whatwouldyoudo",
7373
"leaderboard",
7474
"privacy",
75+
"language",
7576
];
7677
if (
7778
!interaction.guild &&

0 commit comments

Comments
 (0)