-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
70 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Discord, Guard, Slash, SlashGroup, SlashOption } from "discordx"; | ||
import { Category, PermissionGuard } from "@discordx/utilities"; | ||
import { ApplicationCommandOptionType, type CommandInteraction } from "discord.js"; | ||
|
||
import { Firebase } from "../../firebase.js"; | ||
import { RequirePermissions } from "../../utility.js"; | ||
import Embed from "../../embed-presets.js"; | ||
|
||
@Discord() | ||
@Category("Meta") | ||
@Guard(RequirePermissions(["Administrator"])) | ||
@SlashGroup({ | ||
name: "data", | ||
description: "Commands to look at or modify data (soon)" | ||
}) | ||
export class Data { | ||
@Slash({ description: "View the data at `path`" }) | ||
@SlashGroup("data") | ||
public async view( | ||
@SlashOption({ | ||
description: "The path of the data", | ||
name: "path", | ||
required: true, | ||
type: ApplicationCommandOptionType.String, | ||
minLength: 3, | ||
}) | ||
path: string, | ||
command: CommandInteraction | ||
): Promise<void> { | ||
if (!command.channel) return; | ||
|
||
const pathParts = path.split("/"); | ||
const root = pathParts.shift()!; | ||
const db = new Firebase(root, process.env.FIREBASE_URL!); | ||
const result = await db.get(pathParts.join("/")); | ||
if (result === undefined) | ||
return void await command.reply({ | ||
embeds: [Embed.error(`There is no data at path \`${path}\`.`)] | ||
}); | ||
|
||
await command.reply({ | ||
embeds: [Embed.success(`\`\`\`json\n${JSON.stringify(result)}\`\`\``)] | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters