Skip to content

Commit 59a5c1c

Browse files
committed
init with turborepo
1 parent 14027c0 commit 59a5c1c

File tree

241 files changed

+7982
-16467
lines changed

Some content is hidden

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

241 files changed

+7982
-16467
lines changed

Dockerfile

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

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Julius Marminge
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 139 additions & 181 deletions
Large diffs are not rendered by default.

apps/bot/package.json

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"name": "@master-bot/bot",
3+
"version": "1.0.0",
4+
"description": "a discord music bot with guild , gifs and misc commands",
5+
"private": true,
6+
"main": "dist/index.js",
7+
"scripts": {
8+
"build": "pnpm with-env tsc",
9+
"copy-scripts": "pnpx ncp ./scripts ./dist/",
10+
"dev": "pnpm build && pnpm copy-scripts && pnpm start",
11+
"start": "pnpm with-env node dist/index.js",
12+
"with-env": "dotenv -e ../../.env --"
13+
},
14+
"author": "Nir Gal",
15+
"license": "ISC",
16+
"engines": {
17+
"node": "^18"
18+
},
19+
"dependencies": {
20+
"@discordjs/collection": "^1.5.1",
21+
"@lavaclient/spotify": "^3.1.0",
22+
"@lavalink/encoding": "^0.1.2",
23+
"@master-bot/api": "^0.1.0",
24+
"@napi-rs/canvas": "^0.1.41",
25+
"@sapphire/decorators": "^6.0.1",
26+
"@sapphire/discord.js-utilities": "^7.0.0",
27+
"@sapphire/framework": "^4.5.0",
28+
"@sapphire/time-utilities": "^1.7.9",
29+
"@sapphire/utilities": "^3.12.0",
30+
"@t3-oss/env-core": "^0.6.0",
31+
"@trpc/client": "^10.34.0",
32+
"axios": "^1.4.0",
33+
"discord.js": "^14.11.0",
34+
"genius-discord-lyrics": "1.0.5",
35+
"google-translate-api-x": "^10.6.7",
36+
"ioredis": "^5.3.2",
37+
"iso-639-1": "^2.1.15",
38+
"lavaclient": "^4.1.1",
39+
"metadata-filter": "^1.3.0",
40+
"ncp": "^2.0.0",
41+
"node-fetch": "^3.3.1",
42+
"string-progressbar": "^1.0.4",
43+
"tiny-typed-emitter": "^2.1.0",
44+
"undici": "^5.22.1",
45+
"winston": "^3.10.0",
46+
"winston-daily-rotate-file": "^4.7.1",
47+
"zod": "^3.21.4"
48+
},
49+
"devDependencies": {
50+
"@lavaclient/types": "^2.1.1",
51+
"@sapphire/ts-config": "^4.0.0",
52+
"@types/ioredis": "^4.28.10",
53+
"@types/node": "^20.4.1",
54+
"@typescript-eslint/eslint-plugin": "^6.0.0",
55+
"@typescript-eslint/parser": "^6.0.0",
56+
"dotenv": "^16.3.1",
57+
"dotenv-cli": "^7.2.1",
58+
"prettier": "^3.0.0",
59+
"typescript": "^5.1.6"
60+
},
61+
"eslintConfig": {
62+
"root": true,
63+
"extends": [
64+
"@master-bot/eslint-config/base"
65+
]
66+
}
67+
}
Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,133 @@
1-
import type { MessageChannel } from '../../index';
2-
import { ApplyOptions } from '@sapphire/decorators';
3-
import { Command, CommandOptions, container } from '@sapphire/framework';
4-
import type { GuildChannel } from 'discord.js';
5-
import { isTextBasedChannel } from '@sapphire/discord.js-utilities';
6-
import { notify } from '../../lib/utils/twitch/notifyChannel';
7-
import { trpcNode } from '../../trpc';
1+
import { ApplyOptions } from "@sapphire/decorators";
2+
import { isTextBasedChannel } from "@sapphire/discord.js-utilities";
3+
import { Command, CommandOptions, container } from "@sapphire/framework";
4+
import type { GuildChannel } from "discord.js";
5+
6+
import type { MessageChannel } from "../../index";
7+
import { notify } from "../../lib/utils/twitch/notifyChannel";
8+
import { trpcNode } from "../../trpc";
89

910
@ApplyOptions<CommandOptions>({
10-
name: 'add-streamer',
11-
description: 'Add a Stream alert from your favorite Twitch streamer',
12-
requiredUserPermissions: 'ModerateMembers',
13-
preconditions: ['GuildOnly', 'isCommandDisabled']
11+
name: "add-streamer",
12+
description: "Add a Stream alert from your favorite Twitch streamer",
13+
requiredUserPermissions: "ModerateMembers",
14+
preconditions: ["GuildOnly", "isCommandDisabled"],
1415
})
1516
export class AddStreamerCommand extends Command {
1617
public override async chatInputRun(
17-
interaction: Command.ChatInputCommandInteraction
18+
interaction: Command.ChatInputCommandInteraction,
1819
) {
19-
const streamerName = interaction.options.getString('streamer-name', true);
20-
const channelData = interaction.options.getChannel('channel-name', true);
20+
const streamerName = interaction.options.getString("streamer-name", true);
21+
const channelData = interaction.options.getChannel("channel-name", true);
2122
const { client } = container;
2223

2324
let isError = false;
2425
let user;
2526
try {
2627
user = await client.twitch.api.getUser({
2728
login: streamerName,
28-
token: client.twitch.auth.access_token
29+
token: client.twitch.auth.access_token,
2930
});
3031
} catch (error: any) {
3132
isError = true;
3233
if (error.status == 400) {
3334
return await interaction.reply({
34-
content: `:x: "${streamerName}" was Invalid, Please try again.`
35+
content: `:x: "${streamerName}" was Invalid, Please try again.`,
3536
});
3637
}
3738
if (error.status === 401) {
3839
return await interaction.reply({
39-
content: `:x: You are not authorized to use this command.`
40+
content: `:x: You are not authorized to use this command.`,
4041
});
4142
}
4243
if (error.status == 429) {
4344
return await interaction.reply({
44-
content: ':x: Rate Limit exceeded. Please try again in a few minutes.'
45+
content:
46+
":x: Rate Limit exceeded. Please try again in a few minutes.",
4547
});
4648
}
4749
if (error.status == 500) {
4850
return await interaction.reply({
49-
content: `:x: Twitch service's are currently unavailable. Please try again later.`
51+
content: `:x: Twitch service's are currently unavailable. Please try again later.`,
5052
});
5153
} else {
5254
return await interaction.reply({
53-
content: `:x: Something went wrong.`
55+
content: `:x: Something went wrong.`,
5456
});
5557
}
5658
}
5759

5860
if (isError) return;
5961
if (!user)
6062
return await interaction.reply({
61-
content: `:x: ${streamerName} was not Found`
63+
content: `:x: ${streamerName} was not Found`,
6264
});
6365
if (!isTextBasedChannel(channelData as GuildChannel))
6466
return await interaction.reply({
65-
content: `:x: Can't send messages to ${channelData.name}`
67+
content: `:x: Can't send messages to ${channelData.name}`,
6668
});
6769

6870
const guildDB = await trpcNode.guild.getGuild.query({
69-
id: interaction.guild!.id
71+
id: interaction.guild!.id,
7072
});
7173

7274
if (!guildDB.guild) {
7375
return await interaction.reply({
74-
content: `:x: Something went wrong.`
76+
content: `:x: Something went wrong.`,
7577
});
7678
}
7779

7880
// check if streamer is already on notify list
7981
if (guildDB?.guild.notifyList.includes(user.id))
8082
return await interaction.reply({
81-
content: `:x: ${user.display_name} is already on your Notification list`
83+
content: `:x: ${user.display_name} is already on your Notification list`,
8284
});
8385

8486
// make sure channel is not already on notify list
8587
for (const twitchChannel in client.twitch.notifyList) {
86-
for (const channelToMsg of client.twitch.notifyList[twitchChannel]
88+
for (const channelToMsg of client.twitch.notifyList[twitchChannel]!
8789
.sendTo) {
8890
const query = client.channels.cache.get(channelToMsg) as MessageChannel;
8991
if (query)
9092
if (query.guild.id == interaction.guild?.id) {
9193
if (twitchChannel == user.id)
9294
return await interaction.reply({
93-
content: `:x: **${user.display_name}** is already has a notification in **#${query.name}**`
95+
content: `:x: **${user.display_name}** is already has a notification in **#${query.name}**`,
9496
});
9597
}
9698
}
9799
}
98100
// make sure no one else is already sending alerts about this streamer
99101
if (client.twitch.notifyList[user.id]?.sendTo.includes(channelData.id))
100102
return await interaction.reply({
101-
content: `:x: **${user.display_name}** is already messaging ${channelData.name}`
103+
content: `:x: **${user.display_name}** is already messaging ${channelData.name}`,
102104
});
103105

104106
let channelArray;
105107
if (client.twitch.notifyList[user.id])
106108
channelArray = [
107-
...client.twitch.notifyList[user.id].sendTo,
108-
...[channelData.id]
109+
...client.twitch.notifyList[user.id]!.sendTo,
110+
...[channelData.id],
109111
];
110112
else channelArray = [channelData.id];
111113

112114
// add notification to twitch object on client
113115
client.twitch.notifyList[user.id]
114-
? (client.twitch.notifyList[user.id].sendTo = channelArray)
116+
? (client.twitch.notifyList[user.id]!.sendTo = channelArray)
115117
: (client.twitch.notifyList[user.id] = {
116118
sendTo: [channelData.id],
117119
live: false,
118120
logo: user.profile_image_url,
119121
messageSent: false,
120-
messageHandler: {}
122+
messageHandler: {},
121123
});
122124

123125
// add notification to database
124126
await trpcNode.twitch.create.mutate({
125127
userId: user.id,
126128
userImage: user.profile_image_url,
127129
channelId: channelData.id,
128-
sendTo: client.twitch.notifyList[user.id].sendTo
130+
sendTo: client.twitch.notifyList[user.id]!.sendTo,
129131
});
130132

131133
// add notification to guild on database
@@ -137,11 +139,11 @@ export class AddStreamerCommand extends Command {
137139
guildId: guild.id,
138140
notifyList: concatedArray,
139141
ownerId: guild.ownerId,
140-
userId: interaction.user.id
142+
userId: interaction.user.id,
141143
});
142144

143145
await interaction.reply({
144-
content: `**${user.display_name}** Stream Notification will be sent to **#${channelData.name}**`
146+
content: `**${user.display_name}** Stream Notification will be sent to **#${channelData.name}**`,
145147
});
146148
const newQuery: string[] = [];
147149
// pickup newly added entries
@@ -153,30 +155,30 @@ export class AddStreamerCommand extends Command {
153155
}
154156

155157
public override registerApplicationCommands(
156-
registry: Command.Registry
158+
registry: Command.Registry,
157159
): void {
158160
if (!process.env.TWITCH_CLIENT_ID || !process.env.TWITCH_CLIENT_SECRET) {
159161
return;
160162
}
161163

162-
registry.registerChatInputCommand(builder =>
164+
registry.registerChatInputCommand((builder) =>
163165
builder
164166
.setName(this.name)
165167
.setDescription(this.description)
166-
.addStringOption(option =>
168+
.addStringOption((option) =>
167169
option
168-
.setName('streamer-name')
169-
.setDescription('What is the name of the Twitch streamer?')
170-
.setRequired(true)
170+
.setName("streamer-name")
171+
.setDescription("What is the name of the Twitch streamer?")
172+
.setRequired(true),
171173
)
172-
.addChannelOption(option =>
174+
.addChannelOption((option) =>
173175
option
174-
.setName('channel-name')
176+
.setName("channel-name")
175177
.setDescription(
176-
'What is the name of the Channel you would like the alert to be sent to?'
178+
"What is the name of the Channel you would like the alert to be sent to?",
177179
)
178-
.setRequired(true)
179-
)
180+
.setRequired(true),
181+
),
180182
);
181183
}
182184
}

0 commit comments

Comments
 (0)