cleaning up a bit also radio support
This commit is contained in:
parent
29cfc2ab10
commit
3bc837efc8
2 changed files with 64 additions and 4 deletions
62
src/commands/radio.ts
Normal file
62
src/commands/radio.ts
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
import { Command } from "../command.ts";
|
||||||
|
import {
|
||||||
|
ActionRowBuilder,
|
||||||
|
ApplicationIntegrationType,
|
||||||
|
ButtonBuilder,
|
||||||
|
ButtonStyle,
|
||||||
|
ChatInputCommandInteraction,
|
||||||
|
ContainerBuilder,
|
||||||
|
InteractionContextType,
|
||||||
|
MessageFlags,
|
||||||
|
SectionBuilder,
|
||||||
|
SlashCommandBuilder,
|
||||||
|
TextDisplayBuilder,
|
||||||
|
ThumbnailBuilder,
|
||||||
|
type MessageActionRowComponentBuilder
|
||||||
|
} from "discord.js";
|
||||||
|
import { type Config } from "../config.ts";
|
||||||
|
|
||||||
|
export default class RadioCommand extends Command {
|
||||||
|
async run(interaction: ChatInputCommandInteraction, config: Config) {
|
||||||
|
await interaction.deferReply()
|
||||||
|
const nowplaying = (await (await fetch(`${config.radioURL}/api/nowplaying/${config.radioName}`)).json()).now_playing.song
|
||||||
|
const components = [
|
||||||
|
new ContainerBuilder()
|
||||||
|
.addSectionComponents(
|
||||||
|
new SectionBuilder()
|
||||||
|
.setThumbnailAccessory(
|
||||||
|
new ThumbnailBuilder()
|
||||||
|
.setURL(nowplaying.art)
|
||||||
|
)
|
||||||
|
.addTextDisplayComponents(
|
||||||
|
new TextDisplayBuilder().setContent("# " + nowplaying.title),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.addActionRowComponents(
|
||||||
|
new ActionRowBuilder<MessageActionRowComponentBuilder>()
|
||||||
|
.addComponents(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setStyle(ButtonStyle.Link)
|
||||||
|
.setLabel("join the radio")
|
||||||
|
.setURL(`${config.radioURL}/public/${config.radioName}`),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
await interaction.followUp({
|
||||||
|
components: components,
|
||||||
|
flags: [MessageFlags.IsComponentsV2],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
slashCommand = new SlashCommandBuilder()
|
||||||
|
.setName("radio")
|
||||||
|
.setDescription("see whats playing on the radio").setIntegrationTypes([
|
||||||
|
ApplicationIntegrationType.UserInstall
|
||||||
|
])
|
||||||
|
.setContexts([
|
||||||
|
InteractionContextType.BotDM,
|
||||||
|
InteractionContextType.Guild,
|
||||||
|
InteractionContextType.PrivateChannel
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
@ -1,14 +1,12 @@
|
||||||
import rawconfig from "../config.json" with {type: "json"};
|
import rawconfig from "../config.json" with {type: "json"};
|
||||||
import {z} from 'zod';
|
import {z} from 'zod';
|
||||||
import type {S3Client} from "@aws-sdk/client-s3";
|
|
||||||
const configT = z.object({
|
const configT = z.object({
|
||||||
token: z.string(),
|
token: z.string(),
|
||||||
listenbrainzAccount: z.string(),
|
listenbrainzAccount: z.string(),
|
||||||
gitapi: z.string(),
|
gitapi: z.string(),
|
||||||
sharkeyInstance:z.string(),
|
sharkeyInstance:z.string(),
|
||||||
R2AccountID: z.string(),
|
radioURL: z.string(),
|
||||||
R2AccessKeyId: z.string(),
|
radioName: z.string()
|
||||||
R2SecretAccessKey: z.string(),
|
|
||||||
});
|
});
|
||||||
export type Config = z.infer<typeof configT>;
|
export type Config = z.infer<typeof configT>;
|
||||||
export const config: Config = configT.parse(rawconfig);
|
export const config: Config = configT.parse(rawconfig);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue