Compare commits
No commits in common. "d08fcc0867385e60e845fbdc7c0e0d51a740d729" and "e4b979d61c420115821f7c0d3eb87073baafc569" have entirely different histories.
d08fcc0867
...
e4b979d61c
@ -1 +0,0 @@
|
|||||||
{"last_found_secrets": [{"match": "7630852e9a6a0aecb849c91d14d426ca88187886fdf466189d67145856bdac3e", "name": "Generic Password - charts/postgresql/postgresql/templates/secrets.yaml"}]}
|
|
@ -1,5 +0,0 @@
|
|||||||
secret:
|
|
||||||
ignored_matches:
|
|
||||||
- match: 7630852e9a6a0aecb849c91d14d426ca88187886fdf466189d67145856bdac3e
|
|
||||||
name: Generic Password - charts/postgresql/postgresql/templates/secrets.yaml
|
|
||||||
version: 2
|
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,3 @@
|
|||||||
.venv/
|
|
||||||
|
|
||||||
**/.env*
|
**/.env*
|
||||||
*~
|
*~
|
||||||
packages/**/isolate/
|
packages/**/isolate/
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
repos:
|
|
||||||
- repo: https://github.com/gitguardian/ggshield
|
|
||||||
rev: v1.30.2
|
|
||||||
hooks:
|
|
||||||
- id: ggshield
|
|
||||||
language_version: python3
|
|
||||||
stages: [commit]
|
|
11
devbox.json
11
devbox.json
@ -9,21 +9,16 @@
|
|||||||
"kubernetes-helm@latest",
|
"kubernetes-helm@latest",
|
||||||
"k9s@latest",
|
"k9s@latest",
|
||||||
"ffmpeg@latest",
|
"ffmpeg@latest",
|
||||||
"yt-dlp@latest",
|
"yt-dlp@latest"
|
||||||
"python310@latest",
|
|
||||||
"python310Packages.pip@latest"
|
|
||||||
],
|
],
|
||||||
"env": {
|
"env": {
|
||||||
"DEVBOX_COREPACK_ENABLED": "true",
|
"DEVBOX_COREPACK_ENABLED": "true",
|
||||||
"ENV": "development",
|
"ENV": "development",
|
||||||
"KUBECONFIG": "$HOME/.kube/futureporn.yaml",
|
"KUBECONFIG": "$HOME/.kube/futureporn.yaml"
|
||||||
"VENV_DIR": ".venv"
|
|
||||||
},
|
},
|
||||||
"shell": {
|
"shell": {
|
||||||
"init_hook": [
|
"init_hook": [
|
||||||
"echo Welcome to Futureporn devbox",
|
"echo Welcome to Futureporn devbox"
|
||||||
". $VENV_DIR/bin/activate",
|
|
||||||
"pip install -r requirements.txt"
|
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": [
|
"test": [
|
||||||
|
142
devbox.lock
142
devbox.lock
@ -490,148 +490,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"python310@latest": {
|
|
||||||
"last_modified": "2024-07-07T07:43:47Z",
|
|
||||||
"plugin_version": "0.0.3",
|
|
||||||
"resolved": "github:NixOS/nixpkgs/b60793b86201040d9dee019a05089a9150d08b5b#python310",
|
|
||||||
"source": "devbox-search",
|
|
||||||
"version": "3.10.14",
|
|
||||||
"systems": {
|
|
||||||
"aarch64-darwin": {
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "out",
|
|
||||||
"path": "/nix/store/n0gcjj86qjx7w59bwpzqvzdwrjdc7bwy-python3-3.10.14",
|
|
||||||
"default": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"store_path": "/nix/store/n0gcjj86qjx7w59bwpzqvzdwrjdc7bwy-python3-3.10.14"
|
|
||||||
},
|
|
||||||
"aarch64-linux": {
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "out",
|
|
||||||
"path": "/nix/store/pzpn4j6hh8ayy15cb36s7i8v0mkavy0z-python3-3.10.14",
|
|
||||||
"default": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "debug",
|
|
||||||
"path": "/nix/store/h873y0nbzqlmsda6m2vfdcjw1v6c660f-python3-3.10.14-debug"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"store_path": "/nix/store/pzpn4j6hh8ayy15cb36s7i8v0mkavy0z-python3-3.10.14"
|
|
||||||
},
|
|
||||||
"x86_64-darwin": {
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "out",
|
|
||||||
"path": "/nix/store/3ia1741fyzlcjgp3kg01hlk3z1jlp9x0-python3-3.10.14",
|
|
||||||
"default": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"store_path": "/nix/store/3ia1741fyzlcjgp3kg01hlk3z1jlp9x0-python3-3.10.14"
|
|
||||||
},
|
|
||||||
"x86_64-linux": {
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "out",
|
|
||||||
"path": "/nix/store/handws5bj8l411asgs68s3bj8f05qnn5-python3-3.10.14",
|
|
||||||
"default": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "debug",
|
|
||||||
"path": "/nix/store/sl3yyz93mar0jk6cnw0lqv4xrvsbas0a-python3-3.10.14-debug"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"store_path": "/nix/store/handws5bj8l411asgs68s3bj8f05qnn5-python3-3.10.14"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"python310Packages.pip@latest": {
|
|
||||||
"last_modified": "2023-12-13T22:54:10Z",
|
|
||||||
"plugin_version": "0.0.2",
|
|
||||||
"resolved": "github:NixOS/nixpkgs/fd04bea4cbf76f86f244b9e2549fca066db8ddff#python310Packages.pip",
|
|
||||||
"source": "devbox-search",
|
|
||||||
"version": "23.2.1",
|
|
||||||
"systems": {
|
|
||||||
"aarch64-darwin": {
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "out",
|
|
||||||
"path": "/nix/store/vjyrxbxqsadvr9g6mzig6y406dhwcrqi-python3.10-pip-23.2.1",
|
|
||||||
"default": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "man",
|
|
||||||
"path": "/nix/store/2ra46imgas5srgxx8mgs424akh5j1msv-python3.10-pip-23.2.1-man",
|
|
||||||
"default": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "dist",
|
|
||||||
"path": "/nix/store/xjj6xjh21k08rkyg6hnkbyrygqhqgn8y-python3.10-pip-23.2.1-dist"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"store_path": "/nix/store/vjyrxbxqsadvr9g6mzig6y406dhwcrqi-python3.10-pip-23.2.1"
|
|
||||||
},
|
|
||||||
"aarch64-linux": {
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "out",
|
|
||||||
"path": "/nix/store/j8pxwv7vyjm8z2fqglijjvabbkmxbv9r-python3.10-pip-23.2.1",
|
|
||||||
"default": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "man",
|
|
||||||
"path": "/nix/store/bcfliw00z123ddyi8hsfxvfn2npdcpdq-python3.10-pip-23.2.1-man",
|
|
||||||
"default": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "dist",
|
|
||||||
"path": "/nix/store/2326b2sr9p2z9bsghd2pzs346g2qjn7f-python3.10-pip-23.2.1-dist"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"store_path": "/nix/store/j8pxwv7vyjm8z2fqglijjvabbkmxbv9r-python3.10-pip-23.2.1"
|
|
||||||
},
|
|
||||||
"x86_64-darwin": {
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "out",
|
|
||||||
"path": "/nix/store/7lyvqf8wl47wzgsqmlcz39ycmwxyg9zx-python3.10-pip-23.2.1",
|
|
||||||
"default": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "man",
|
|
||||||
"path": "/nix/store/0j02s5hbsdhfxvvay5dm9j68nhalm39v-python3.10-pip-23.2.1-man",
|
|
||||||
"default": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "dist",
|
|
||||||
"path": "/nix/store/8dvqh9ai83lqaaixs3bhmf1n4jxgp4v7-python3.10-pip-23.2.1-dist"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"store_path": "/nix/store/7lyvqf8wl47wzgsqmlcz39ycmwxyg9zx-python3.10-pip-23.2.1"
|
|
||||||
},
|
|
||||||
"x86_64-linux": {
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "out",
|
|
||||||
"path": "/nix/store/gdhvfi5zaqzpa5l3kk0spmv71r549slf-python3.10-pip-23.2.1",
|
|
||||||
"default": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "man",
|
|
||||||
"path": "/nix/store/p37y2fhm6l3nd624jmr2r680wf4p0544-python3.10-pip-23.2.1-man",
|
|
||||||
"default": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "dist",
|
|
||||||
"path": "/nix/store/r4qj7psryk532rkh0srhn25ygv8yk541-python3.10-pip-23.2.1-dist"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"store_path": "/nix/store/gdhvfi5zaqzpa5l3kk0spmv71r549slf-python3.10-pip-23.2.1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tilt@latest": {
|
"tilt@latest": {
|
||||||
"last_modified": "2024-07-15T21:47:20Z",
|
"last_modified": "2024-07-15T21:47:20Z",
|
||||||
"resolved": "github:NixOS/nixpkgs/b2c1f10bfbb3f617ea8e8669ac13f3f56ceb2ea2#tilt",
|
"resolved": "github:NixOS/nixpkgs/b2c1f10bfbb3f617ea8e8669ac13f3f56ceb2ea2#tilt",
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
pre-commit
|
|
||||||
ggshield
|
|
||||||
click
|
|
36
services/bot/pnpm-lock.yaml
generated
36
services/bot/pnpm-lock.yaml
generated
@ -46,6 +46,42 @@ importers:
|
|||||||
specifier: ^5.5.3
|
specifier: ^5.5.3
|
||||||
version: 5.5.4
|
version: 5.5.4
|
||||||
|
|
||||||
|
../..: {}
|
||||||
|
|
||||||
|
../../packages/image: {}
|
||||||
|
|
||||||
|
../../packages/infra: {}
|
||||||
|
|
||||||
|
../../packages/meal: {}
|
||||||
|
|
||||||
|
../../packages/old: {}
|
||||||
|
|
||||||
|
../../packages/scout: {}
|
||||||
|
|
||||||
|
../../packages/storage: {}
|
||||||
|
|
||||||
|
../../packages/taco: {}
|
||||||
|
|
||||||
|
../../packages/types: {}
|
||||||
|
|
||||||
|
../../packages/utils: {}
|
||||||
|
|
||||||
|
../../packages/video: {}
|
||||||
|
|
||||||
|
../../packages/worker: {}
|
||||||
|
|
||||||
|
../capture: {}
|
||||||
|
|
||||||
|
../mailbox: {}
|
||||||
|
|
||||||
|
../migrations: {}
|
||||||
|
|
||||||
|
../next: {}
|
||||||
|
|
||||||
|
../strapi: {}
|
||||||
|
|
||||||
|
../uppy: {}
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
'@babel/code-frame@7.24.7':
|
'@babel/code-frame@7.24.7':
|
||||||
|
@ -51,14 +51,15 @@ createCommand({
|
|||||||
async execute(interaction: Interaction) {
|
async execute(interaction: Interaction) {
|
||||||
await interaction.defer()
|
await interaction.defer()
|
||||||
|
|
||||||
// console.log('interation.data as follows')
|
console.log('interation.data as follows')
|
||||||
// console.log(interaction.data)
|
console.log(interaction.data)
|
||||||
const options = interaction.data?.options
|
const options = interaction.data?.options
|
||||||
if (!options) throw new Error(`interaction options was undefined. it's expected to be an array of options.`);
|
if (!options) throw new Error(`interaction options was undefined. it's expected to be an array of options.`);
|
||||||
const urlOption = options.find((o) => o.name === 'url')
|
const urlOption = options.find((o) => o.name === 'url')
|
||||||
if (!urlOption) throw new Error(`url option was missing from interaction data`);
|
if (!urlOption) throw new Error(`url option was missing from interaction data`);
|
||||||
const url = ''+urlOption.value
|
const url = ''+urlOption.value
|
||||||
if (!url) throw new Error(`url was missing from interaction data options`);
|
if (!url) throw new Error(`url was missing from interaction data options`);
|
||||||
|
// const url = (interaction.data?.options?.find(o => o.name === 'url')?.value) ?? undefined;
|
||||||
|
|
||||||
// respond to the interaction and get a message ID which we will then add to the database Record
|
// respond to the interaction and get a message ID which we will then add to the database Record
|
||||||
const embeds = new EmbedsBuilder()
|
const embeds = new EmbedsBuilder()
|
||||||
@ -74,8 +75,8 @@ createCommand({
|
|||||||
const response: InteractionCallbackData = { embeds }
|
const response: InteractionCallbackData = { embeds }
|
||||||
const message = await interaction.edit(response)
|
const message = await interaction.edit(response)
|
||||||
|
|
||||||
// console.log('deferred, interaction message is as follows')
|
console.log('defferred, interaction message is as follows')
|
||||||
// console.log(message)
|
console.log(message)
|
||||||
if (!message?.id) {
|
if (!message?.id) {
|
||||||
const msg = `message.id was empty, ruh roh raggy`
|
const msg = `message.id was empty, ruh roh raggy`
|
||||||
console.error(msg)
|
console.error(msg)
|
||||||
@ -84,8 +85,57 @@ createCommand({
|
|||||||
|
|
||||||
// @todo create record in db
|
// @todo create record in db
|
||||||
const record = await createRecordInDatabase(url, message.id.toString())
|
const record = await createRecordInDatabase(url, message.id.toString())
|
||||||
// console.log(record)
|
console.log(record)
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
// if (!interaction.data?.values) throw new Error('interaction data was missing values');
|
||||||
|
// console.log(`while executing record command, the following values were seen.`)
|
||||||
|
// console.log(interaction.data.values)
|
||||||
|
|
||||||
|
// const embeds = new EmbedsBuilder()
|
||||||
|
// .setTitle('My Embed')
|
||||||
|
// .setDescription('This is my new embed')
|
||||||
|
// .newEmbed()
|
||||||
|
// .setTitle('My Second Embed')
|
||||||
|
// await interaction.respond({
|
||||||
|
// embeds:
|
||||||
|
// })
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
// const statusEmbed = new EmbedBuilder()
|
||||||
|
// .setTitle('Pending')
|
||||||
|
// .setDescription('Waiting for a worker to accept the job.')
|
||||||
|
// .setColor(2326507)
|
||||||
|
|
||||||
|
// const buttonRow = new ActionRowBuilder<MessageActionRowComponentBuilder>()
|
||||||
|
// .addComponents([
|
||||||
|
// new ButtonBuilder()
|
||||||
|
// .setCustomId('stop')
|
||||||
|
// .setLabel('Stop Recording')
|
||||||
|
// .setEmoji('🛑')
|
||||||
|
// .setStyle(ButtonStyle.Danger),
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
// const command: CreateSlashApplicationCommand = {
|
||||||
|
// name: 'record',
|
||||||
|
// description: 'Record a livestream.',
|
||||||
|
// options: [
|
||||||
|
// {
|
||||||
|
// name: 'url',
|
||||||
|
// description: 'URL of the livestream',
|
||||||
|
// type: ApplicationCommandOptionTypes.String
|
||||||
|
// },
|
||||||
|
// ],
|
||||||
|
// async execute(interaction: Interaction) {
|
||||||
|
// const ping = Date.now() - snowflakeToTimestamp(interaction.id)
|
||||||
|
|
||||||
|
// const embeds = createEmbeds().setTitle(`The bot ping is ${ping}ms`)
|
||||||
|
|
||||||
|
// await interaction.respond({ embeds })
|
||||||
|
// },
|
||||||
|
// }
|
||||||
|
|
||||||
|
// export default command
|
@ -3,19 +3,29 @@ import type { RecordingState } from '@futureporn/types'
|
|||||||
import { type Task, type Helpers } from 'graphile-worker'
|
import { type Task, type Helpers } from 'graphile-worker'
|
||||||
import { add } from 'date-fns'
|
import { add } from 'date-fns'
|
||||||
import prettyBytes from 'pretty-bytes'
|
import prettyBytes from 'pretty-bytes'
|
||||||
import { EmbedsBuilder, type Component } from '@discordeno/bot'
|
import {
|
||||||
|
type APIEmbedField,
|
||||||
|
Client,
|
||||||
|
GatewayIntentBits,
|
||||||
|
TextChannel,
|
||||||
|
ActionRowBuilder,
|
||||||
|
ButtonBuilder,
|
||||||
|
type MessageActionRowComponentBuilder,
|
||||||
|
ButtonStyle,
|
||||||
|
EmbedBuilder,
|
||||||
|
Guild
|
||||||
|
} from 'discord.js';
|
||||||
|
|
||||||
|
|
||||||
interface Payload {
|
interface Payload {
|
||||||
record_id: number;
|
recordId: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function assertPayload(payload: any): asserts payload is Payload {
|
function assertPayload(payload: any): asserts payload is Payload {
|
||||||
if (typeof payload !== "object" || !payload) throw new Error("invalid payload");
|
if (typeof payload !== "object" || !payload) throw new Error("invalid payload");
|
||||||
if (!payload.record_id) throw new Error(`record_id was absent in the payload`);
|
if (!payload.recordId) throw new Error(`recordId was absent in the payload`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -101,8 +111,7 @@ async function getRecordFromDatabase(recordId: number) {
|
|||||||
export const updateDiscordMessage: Task = async function (payload, helpers: Helpers) {
|
export const updateDiscordMessage: Task = async function (payload, helpers: Helpers) {
|
||||||
try {
|
try {
|
||||||
assertPayload(payload)
|
assertPayload(payload)
|
||||||
const { record_id } = payload
|
const { recordId } = payload
|
||||||
const recordId = record_id
|
|
||||||
helpers.logger.info(`updateDiscordMessage() with recordId=${recordId}`)
|
helpers.logger.info(`updateDiscordMessage() with recordId=${recordId}`)
|
||||||
const record = await getRecordFromDatabase(recordId)
|
const record = await getRecordFromDatabase(recordId)
|
||||||
const { discord_message_id, recording_state, file_size, url } = record
|
const { discord_message_id, recording_state, file_size, url } = record
|
||||||
@ -124,97 +133,64 @@ export const updateDiscordMessage: Task = async function (payload, helpers: Help
|
|||||||
function getStatusEmbed({
|
function getStatusEmbed({
|
||||||
recordingState, recordId, fileSize, url
|
recordingState, recordId, fileSize, url
|
||||||
}: { fileSize: number, recordingState: RecordingState, recordId: number, url: string }) {
|
}: { fileSize: number, recordingState: RecordingState, recordId: number, url: string }) {
|
||||||
const embeds = new EmbedsBuilder()
|
let title, description, color, fields;
|
||||||
.setTitle(`Record ${recordId}`)
|
title = `Record ${recordId}`
|
||||||
.setFields([
|
fields = [
|
||||||
{ name: 'Status', value: 'Pending', inline: true },
|
{ name: 'Status', value: 'Pending', inline: true },
|
||||||
{ name: 'Filesize', value: `${fileSize} bytes (${prettyBytes(fileSize)})`, inline: true },
|
{ name: 'Filesize', value: `${fileSize} bytes (${prettyBytes(fileSize)})`, inline: true },
|
||||||
{ name: 'URL', value: url, inline: false },
|
{ name: 'URL', value: url, inline: false },
|
||||||
])
|
] as APIEmbedField[]
|
||||||
if (recordingState === 'pending') {
|
if (recordingState === 'pending') {
|
||||||
embeds
|
description = "Waiting for a worker to accept the job."
|
||||||
.setDescription("Waiting for a worker to accept the job.")
|
color = 2326507
|
||||||
.setColor(2326507)
|
|
||||||
} else if (recordingState === 'recording') {
|
} else if (recordingState === 'recording') {
|
||||||
embeds
|
description = 'The stream is being recorded.'
|
||||||
.setDescription('The stream is being recorded.')
|
color = 392960
|
||||||
.setColor(392960)
|
|
||||||
} else if (recordingState === 'aborted') {
|
} else if (recordingState === 'aborted') {
|
||||||
embeds
|
description = "The recording was stopped by the user."
|
||||||
.setDescription("The recording was stopped by the user.")
|
color = 8289651
|
||||||
.setColor(8289651)
|
|
||||||
} else if (recordingState === 'ended') {
|
} else if (recordingState === 'ended') {
|
||||||
embeds
|
description = "The recording has stopped."
|
||||||
.setDescription("The recording has stopped.")
|
color = 10855845
|
||||||
.setColor(10855845)
|
|
||||||
} else {
|
} else {
|
||||||
embeds
|
description = 'The recording is in an unknown state? (this is a bug.)'
|
||||||
.setDescription('The recording is in an unknown state? (this is a bug.)')
|
color = 10855845
|
||||||
.setColor(10855845)
|
|
||||||
}
|
}
|
||||||
return embeds
|
return new EmbedBuilder().setTitle(title).setDescription(description).setColor(color).setFields(fields)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function getButtonRow(state: RecordingState) {
|
function getButtonRow(state: RecordingState) {
|
||||||
|
let id, label, emoji, style;
|
||||||
const button = new Component()
|
|
||||||
.setType("BUTTON")
|
|
||||||
|
|
||||||
// // Button with raw types
|
|
||||||
// const button2 = new Component()
|
|
||||||
// .setType(2)
|
|
||||||
// .setStyle(4)
|
|
||||||
// .setLabel("DO NOT CLICK")
|
|
||||||
// .setCustomId("12345")
|
|
||||||
// .toJSON();
|
|
||||||
|
|
||||||
// const actionRow = new Component()
|
|
||||||
// .setType("ACTION_ROW")
|
|
||||||
// .setComponents(button, button2)
|
|
||||||
// .toJSON();
|
|
||||||
|
|
||||||
// return actionRow
|
|
||||||
|
|
||||||
// Message to send
|
|
||||||
// const messageOptions = { content: "hello", components: [actionRow] };
|
|
||||||
|
|
||||||
// await client.helpers.sendMessage(channelId, messageOptions); // You can also use the Message Structure
|
|
||||||
|
|
||||||
if (state === 'pending') {
|
if (state === 'pending') {
|
||||||
button
|
id = 'stop';
|
||||||
.setCustomId('stop')
|
label = 'Cancel';
|
||||||
.setLabel('Cancel')
|
emoji = '❌';
|
||||||
.setEmoji('❌')
|
style = ButtonStyle.Danger;
|
||||||
.setStyle('DANGER')
|
|
||||||
} else if (state === 'recording') {
|
} else if (state === 'recording') {
|
||||||
button
|
id = 'stop';
|
||||||
.setCustomId('stop')
|
label = 'Stop Recording';
|
||||||
.setLabel('Stop Recording')
|
emoji = '🛑';
|
||||||
.setEmoji('🛑')
|
style = ButtonStyle.Danger;
|
||||||
.setStyle('DANGER')
|
|
||||||
} else if (state === 'aborted') {
|
} else if (state === 'aborted') {
|
||||||
button
|
id = 'retry';
|
||||||
.setCustomId('retry')
|
label = 'Retry Recording';
|
||||||
.setLabel('Retry Recording')
|
emoji = '🔄';
|
||||||
.setEmoji('🔄')
|
style = ButtonStyle.Success;
|
||||||
.setStyle('SUCCESS')
|
|
||||||
} else if (state === 'ended') {
|
} else if (state === 'ended') {
|
||||||
button
|
id = 'download';
|
||||||
.setCustomId('download')
|
label = 'Download Recording';
|
||||||
.setLabel('Download Recording')
|
emoji = '📥';
|
||||||
.setEmoji('📥')
|
style = ButtonStyle.Primary;
|
||||||
.setStyle('PRIMARY')
|
|
||||||
} else {
|
} else {
|
||||||
button
|
id = 'unknown';
|
||||||
.setCustomId('unknown')
|
label = 'Unknown State';
|
||||||
.setLabel('Unknown State')
|
emoji = '🤔';
|
||||||
.setEmoji('🤔')
|
style = ButtonStyle.Secondary;
|
||||||
.setStyle('SECONDARY')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const actionRow = new Component
|
|
||||||
return new ActionRowBuilder<MessageActionRowComponentBuilder>()
|
return new ActionRowBuilder<MessageActionRowComponentBuilder>()
|
||||||
.addComponents([
|
.addComponents([
|
||||||
new ButtonBuilder()
|
new ButtonBuilder()
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
|
|
||||||
CREATE FUNCTION public.tg__update_discord_message() RETURNS trigger
|
|
||||||
LANGUAGE plpgsql SECURITY DEFINER
|
|
||||||
SET search_path TO 'pg_catalog', 'public', 'pg_temp'
|
|
||||||
AS $$
|
|
||||||
begin
|
|
||||||
PERFORM graphile_worker.add_job('update_discord_message', json_build_object(
|
|
||||||
'record_id', NEW.record_id
|
|
||||||
), max_attempts := 3);
|
|
||||||
return NEW;
|
|
||||||
end;
|
|
||||||
$$;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- when a record is updated, we add a job in graphile to update_discord_message
|
|
||||||
CREATE TRIGGER record_update
|
|
||||||
AFTER UPDATE ON api.records
|
|
||||||
FOR EACH ROW
|
|
||||||
EXECUTE PROCEDURE public.tg__update_discord_message('update_discord_message');
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user