Skip to content

Commit 8487065

Browse files
author
xyzjesper
committed
Fixed notifications creation.
1 parent e503bdc commit 8487065

File tree

4 files changed

+30
-14
lines changed

4 files changed

+30
-14
lines changed

src/modules/notification/modals/spotify-add-channelname-modal.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const {uuid} = pkg;
66
import {ExtendedClient} from "../../../types/client.js";
77
import {convertToEmojiPng} from "../../../helper/emojis.js";
88
import {database} from "../../../main/database.js";
9+
import {randomUUID} from "crypto";
910

1011
export default {
1112
id: "spotify-add-channelname-modal",
@@ -54,15 +55,19 @@ export default {
5455
});
5556
return;
5657
}
57-
const uuids = uuid();
58+
const uuids = randomUUID();
5859

5960
await database.guildSpotifyNotifications.create({
6061
data: {
61-
GuildId: interaction.guild?.id,
62-
ChannelId: null,
62+
Guilds: {
63+
connect: {
64+
GuildId: interaction.guild?.id
65+
}
66+
},
67+
ChannelId: "",
6368
Latests: [],
6469
ShowId: channelName,
65-
MessageTemplateId: null,
70+
MessageTemplateId: "",
6671
PingRoles: [],
6772
UUID: uuids,
6873
}

src/modules/notification/modals/twitch-add-channelname-modal.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const {uuid} = pkg
55
import {ExtendedClient} from "../../../types/client.js";
66
import {convertToEmojiPng} from "../../../helper/emojis.js";
77
import {database} from "../../../main/database.js";
8+
import {randomUUID} from "crypto";
89

910

1011
export default {
@@ -17,7 +18,7 @@ export default {
1718
*/
1819

1920
async execute(interaction: ModalSubmitInteraction, client: ExtendedClient) {
20-
const uuids = uuid();
21+
const uuids = randomUUID();
2122
if (!client.user) throw new Error("Client is not ready yet!");
2223

2324
const getChannelName = interaction.fields.getTextInputValue(
@@ -45,11 +46,15 @@ export default {
4546

4647
await database.guildTwitchNotifications.create({
4748
data: {
48-
GuildId: interaction.guild?.id,
49+
Guilds: {
50+
connect: {
51+
GuildId: interaction.guild?.id
52+
}
53+
},
4954
TwitchChannelName: getChannelName,
50-
ChannelId: null,
55+
ChannelId: "",
5156
Live: false,
52-
MessageTemplateId: null,
57+
MessageTemplateId: "",
5358
PingRoles: [],
5459
UUID: uuids
5560
}

src/modules/notification/modals/youtube-add-channelname-modal.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const {uuid} = pkg;
55
import {ExtendedClient} from "../../../types/client.js";
66
import {convertToEmojiPng} from "../../../helper/emojis.js";
77
import {database} from "../../../main/database.js";
8+
import {randomUUID} from "crypto";
89

910
export default {
1011
id: "youtube-add-channelname-modal",
@@ -18,7 +19,7 @@ export default {
1819
async execute(interaction: ModalSubmitInteraction, client: ExtendedClient) {
1920
if (!client.user) throw new Error("Client user is not defined");
2021

21-
const uuids = uuid();
22+
const uuids = randomUUID();
2223

2324
const getChannelName = interaction.fields.getTextInputValue(
2425
"youtube-add-channelname"
@@ -45,10 +46,14 @@ export default {
4546

4647
await database.guildYoutubeNotifications.create({
4748
data: {
48-
GuildId: interaction.guild?.id,
49+
Guilds: {
50+
connect: {
51+
GuildId: interaction.guild?.id
52+
}
53+
},
4954
YoutubeChannelId: getChannelName,
50-
ChannelId: null,
51-
MessageTemplateId: null,
55+
ChannelId: "",
56+
MessageTemplateId: "",
5257
PingRoles: [],
5358
UUID: uuids,
5459
Latest: []

src/systems/twitch.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {ExtendedClient} from "../types/client.js";
22
import axios from "axios";
33
import {EmbedBuilder, Guild, NewsChannel, TextChannel, ThreadChannel,} from "discord.js";
44
import {database} from "../main/database.js";
5+
import {Config} from "../main/config.js";
56

67
/**
78
*
@@ -11,7 +12,7 @@ export async function checkTwitch(client: ExtendedClient) {
1112

1213
const config = await database.disBot.findFirst({where: {GetConf: "config"}});
1314
const twitchdata = await database.guildTwitchNotifications.findMany()
14-
15+
1516
if (!twitchdata) return;
1617

1718
for (const twitchDocument of twitchdata) {
@@ -20,7 +21,7 @@ export async function checkTwitch(client: ExtendedClient) {
2021

2122
const isChannel = await axios.get(`https://api.twitch.tv/helix/users?login=${twitchDocument.TwitchChannelName}`, {
2223
headers: {
23-
"Client-Id": "dtqw2suy9vbzzhpoure8ibuq8r0vnj",
24+
"Client-Id": Config.Modules.Notifications.TwitchClientId,
2425
Authorization: `Bearer ${config?.TwitchToken}`,
2526
"Content-Type": "application/json",
2627
},

0 commit comments

Comments
 (0)