Compare commits

...

3 Commits

Author SHA1 Message Date
jude
9a6b65f3a3 Don't delete guild data when guild becomes unavailable 2024-09-17 23:47:27 +01:00
jude
b6ff149d51 Fix macro list/delete 2024-09-14 12:07:09 +01:00
jude
748e33566b Fix patreon not sharing between guild members 2024-08-19 21:50:14 +01:00
6 changed files with 21 additions and 13 deletions

2
Cargo.lock generated
View File

@ -2431,7 +2431,7 @@ checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
[[package]]
name = "reminder-rs"
version = "1.7.24"
version = "1.7.26"
dependencies = [
"base64 0.22.1",
"chrono",

View File

@ -1,6 +1,6 @@
[package]
name = "reminder-rs"
version = "1.7.24"
version = "1.7.27"
authors = ["Jude Southworth <judesouthworth@pm.me>"]
edition = "2021"
license = "AGPL-3.0 only"

View File

@ -1,8 +1,7 @@
import { ChannelSelector } from "./ChannelSelector";
import { DateTime } from "luxon";
import { IntervalSelector } from "./IntervalSelector";
import { useQuery } from "react-query";
import { fetchUserInfo } from "../../api";
import { fetchGuildInfo, fetchUserInfo } from "../../api";
import { useReminder } from "./ReminderContext";
import { Attachment } from "./Attachment";
import { TTS } from "./TTS";
@ -11,11 +10,12 @@ import { useGuild } from "../App/useGuild";
export const Settings = () => {
const guild = useGuild();
const { isSuccess: userFetched, data: userInfo } = useQuery(fetchUserInfo());
const { isSuccess: userFetched, data: userInfo } = useQuery({ ...fetchUserInfo() });
const { isSuccess: guildFetched, data: guildInfo } = useQuery({ ...fetchGuildInfo(guild) });
const [reminder, setReminder] = useReminder();
if (!userFetched) {
if (!userFetched || !guildFetched) {
return <></>;
}
@ -59,7 +59,13 @@ export const Settings = () => {
<div class="collapses split-controls">
<div>
<div class={userInfo.patreon ? "patreon-only" : "patreon-only is-locked"}>
<div
class={
userInfo.patreon || guildInfo.patreon
? "patreon-only"
: "patreon-only is-locked"
}
>
<div class="patreon-invert foreground">
Intervals available on <a href="https://patreon.com/jellywx">Patreon</a>{" "}
or{" "}

View File

@ -20,7 +20,7 @@ pub async fn delete_macro(
SELECT m.id
FROM command_macro m
INNER JOIN guilds
ON guilds.guild = m.guild_id
ON guilds.id = m.guild_id
WHERE guild = ?
AND m.name = ?
",

View File

@ -55,9 +55,11 @@ To stay up to date on the latest features and fixes, join our [Discord](https://
}
}
FullEvent::GuildDelete { incomplete, .. } => {
let _ = sqlx::query!("DELETE FROM guilds WHERE guild = ?", incomplete.id.get())
.execute(&data.database)
.await;
if !incomplete.unavailable {
let _ = sqlx::query!("DELETE FROM guilds WHERE guild = ?", incomplete.id.get())
.execute(&data.database)
.await;
}
}
FullEvent::InteractionCreate { interaction } => {
if let Some(component) = interaction.clone().message_component() {

View File

@ -68,7 +68,7 @@ impl Data {
guild_id: GuildId,
) -> Result<Vec<CommandMacro>, Error> {
let rows = sqlx::query!(
"SELECT name, description, commands FROM macro WHERE guild_id = (SELECT id FROM guilds WHERE guild = ?)",
"SELECT name, description, commands FROM command_macro WHERE guild_id = (SELECT id FROM guilds WHERE guild = ?)",
guild_id.get()
)
.fetch_all(&self.database)
@ -76,7 +76,7 @@ impl Data {
guild_id,
name: row.name.clone(),
description: row.description.clone(),
commands: serde_json::from_str(&row.commands).unwrap(),
commands: serde_json::from_str(&row.commands.to_string()).unwrap(),
}).collect();
Ok(rows)