-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
173 lines (156 loc) · 6.25 KB
/
bot.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
require("dotenv").config();
const { Client, GatewayIntentBits, EmbedBuilder } = require("discord.js");
const fs = require("fs");
const path = require("path");
if (!process.env.DISCORD_TOKEN) {
console.error("Missing DISCORD_TOKEN in environment variables");
process.exit(1);
}
if (!process.env.OWNER_ID) {
console.error("Missing OWNER_ID in environment variables");
process.exit(1);
}
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
});
const OWNER_ID = process.env.OWNER_ID;
const IGNORED_USER_IDS = process.env.IGNORED_USER_IDS?.split(",") || [];
let issueResponses = [];
try {
const issuesPath = path.join(__dirname, "data/issues.json");
const issuesData = fs.readFileSync(issuesPath, "utf8");
issueResponses = JSON.parse(issuesData);
} catch (error) {
console.error("Error loading issues.json:", error);
}
client.once("ready", () => {
console.log(`Logged in as ${client.user.tag}`);
});
client.on("messageCreate", async (message) => {
if (message.author.bot) return;
if (message.content.toLowerCase() === "!info") {
if (message.author.id === OWNER_ID) {
try {
const mainEmbed = new EmbedBuilder()
.setColor(0x1f346a)
.setTitle("About Nocturne")
.setDescription(
"A modern, open-source Spotify client for the Spotify Car Thing."
)
.setThumbnail("https://usenocturne.com/images/logo.png")
.addFields([
{
name: "What is Nocturne?",
value:
"Nocturne is a web-based application that interfaces with the Spotify API to provide a rich, interactive music listening experience on the Spotify Car Thing. It's built using modern web technologies and offers a range of features for music playback and playlist management.",
},
{
name: "Key Features",
value:
"• **Playback Control**: Play, pause, skip tracks, and control volume using Car Thing's hardware\n" +
"• **Dynamic UI**: The interface updates in real-time to reflect the current playback state\n" +
"• **Playlist Management**: View and modify your Spotify playlists\n" +
"• **Artist and Album Exploration**: Browse and play top tracks from artists and albums\n" +
"• **User Library Integration**: Access and manage your liked tracks",
},
{
name: "Getting Started",
value:
"Visit the [nocturne-image](https://github.com/usenocturne/nocturne-image) GitHub repository to download the latest release and follow the setup instructions detailed in the README.md file.",
},
])
.setTimestamp();
const imageEmbed = new EmbedBuilder()
.setColor(0x1f346a)
.setTitle("nocturne-image")
.setURL("https://github.com/usenocturne/nocturne-image")
.setDescription(
"The custom OS image that users can flash onto their Spotify Car Thing devices to access Nocturne."
)
.setImage("https://usenocturne.com/images/og-image-2.png")
.setTimestamp();
const uiEmbed = new EmbedBuilder()
.setColor(0x1f346a)
.setTitle("nocturne-ui")
.setURL("https://github.com/usenocturne/nocturne-ui")
.setDescription(
"The frontend web application that interfaces with the Spotify API, providing a feature-rich interface for controlling music playback on the Spotify Car Thing."
)
.setImage("https://usenocturne.com/images/og-image.png")
.setTimestamp();
const projectEmbed = new EmbedBuilder()
.setColor(0x1f346a)
.setTitle("Project Board")
.setURL("https://github.com/orgs/usenocturne/projects/1/views/1")
.setDescription(
"Track the development progress of Nocturne. View upcoming features, reported bugs, and ongoing improvements."
)
.setThumbnail(
"https://raw.githubusercontent.com/usenocturne/nocturne/main/public/icon.png"
)
.addFields([
{
name: "Project Planning",
value:
"Check out our project board to:\n" +
"• View upcoming features and enhancements\n" +
"• Track bug reports and fixes\n" +
"• See development progress\n" +
"• Contribute to discussions",
},
])
.setTimestamp();
const donateEmbed = new EmbedBuilder()
.setColor(0x1f346a)
.setTitle("Support Nocturne Development")
.setDescription(
"Your support helps maintain and improve Nocturne! Consider donating if you find the project useful."
)
.setThumbnail(
"https://raw.githubusercontent.com/usenocturne/nocturne/main/public/icon.png"
)
.addFields([
{
name: "Donation Links",
value:
"[Buy Me a Coffee](https://www.buymeacoffee.com/brandonsaldan)\n" +
"[Ko-fi](https://ko-fi.com/brandonsaldan)",
},
])
.setFooter({
text: "Every contribution helps keep the project active and enables new features!",
})
.setTimestamp();
await message.channel.send({
embeds: [mainEmbed, imageEmbed, uiEmbed, projectEmbed, donateEmbed],
});
} catch (error) {
console.error("Error sending info embeds:", error);
message.reply("There was an error displaying the information.");
}
return;
}
return;
}
if (IGNORED_USER_IDS.includes(message.author.id)) return;
const messageContent = message.content.toLowerCase();
for (const issue of issueResponses) {
if (
issue.triggers.some((trigger) =>
messageContent.includes(trigger.toLowerCase())
)
) {
const embed = new EmbedBuilder()
.setColor(0x1f346a)
.setTitle(issue.response.title)
.setDescription(issue.response.description);
await message.reply({ embeds: [embed] });
break;
}
}
});
client.login(process.env.DISCORD_TOKEN);