push rn
All checks were successful
Deploy bot / build-and-deploy (push) Successful in 26s

This commit is contained in:
2025-08-27 23:07:50 +02:00
parent aa193aa6a6
commit f3493fe2a6
4 changed files with 100 additions and 9 deletions

48
bot/commands/kb.js Normal file
View File

@ -0,0 +1,48 @@
const { EmbedBuilder } = require("discord.js");
exports.name = "kb";
exports.description =
":notebook_with_decorative_cover: Quickly access useful data regarding Dungeon Defenders.";
exports.usage = "CLIENT_PREFIX:kb <topic>";
exports.example =
"CLIENT_PREFIX:kb list (lists available topics)\nCLIENT_PREFIX:kb stacking\nCLIENT_PREFIX:kb cv";
exports.hidden = false;
exports.run = (client, message, args) => {
const topic = args.join(" ");
if (!topic) {
return message.channel.send(
"Topic argument missing, consult `CLIENT_PREFIX:help kb`.".replaceAll(
"CLIENT_PREFIX:",
client.prefix
)
);
}
fetch(client.sharedEndpoint + "knowledge?topic=" + topic)
.then((d) => d.json())
.then((data) => {
console.log(data);
if (data.error == "topic-not-found") {
return message.channel.send(
"Could not find data entry for the given topic. consult `CLIENT_PREFIX:help kb`.".replaceAll(
"CLIENT_PREFIX:",
client.prefix
)
);
}
if (data.topics) {
return message.channel.send(
`List of topics:\n\`\`\`\n${data.topics.join(
"\n"
)}\`\`\`\nUsage: \`CLIENT_PREFIX:kb <topic>\``.replaceAll(
"CLIENT_PREFIX:",
client.prefix
)
);
}
const { title, content } = data;
const embed = new EmbedBuilder();
embed.setTitle(title);
embed.setDescription(content);
embed.setColor("Green");
message.channel.send({ embeds: [embed] });
});
};

View File

@ -21,13 +21,16 @@ const client = new Client({
const DDRNG_GUILD_ID = 148849688722800640;
const DDRNG_ALLOWED_CHANNELS = [
496061346446835732, 499656239572058132, 771329671953776661,
556864412338749440,
];
client.commands = new Collection();
client.ownerID = 263247134147608578;
client.prefix = prefix;
client.sharedEndpoint = process.env.SHARED_ENDPOINT;
if (!client.sharedEndpoint)
return log.error("client.sharedEndpoint is undefined.");
return log.error(
"client.sharedEndpoint (process.env.SHARED_ENDPOINT) is undefined."
);
fs.readdir("./commands/", (err, files) => {
if (err) return console.error(err);
@ -68,7 +71,6 @@ client.on(Events.MessageCreate, async (message) => {
try {
await message.react(item.emoji);
} catch (err) {
message.channel.send("FAILED TO REACT TO MESSAGE! " + err);
console.error("Failed to react to message:", err);
}
}