Apply patreon sharing across web/bot
This commit is contained in:
@@ -23,28 +23,12 @@ impl Recordable for Options {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let existing_link = sqlx::query!(
|
||||
"SELECT linked_at FROM patreon_link WHERE user_id = ? AND linked_at > NOW() - INTERVAL 4 WEEK",
|
||||
user_id.get()
|
||||
)
|
||||
.fetch_optional(&ctx.data().database)
|
||||
.await?;
|
||||
|
||||
if existing_link.is_some() {
|
||||
ctx.send(
|
||||
CreateReply::default()
|
||||
.content("❌ You can only link once every 4 weeks. Please try again later.")
|
||||
.ephemeral(true),
|
||||
)
|
||||
.await?;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// Insert or update the patreon_link entry
|
||||
sqlx::query!(
|
||||
"INSERT INTO patreon_link (user_id, guild_id, linked_at) VALUES (?, ?, NOW())
|
||||
ON DUPLICATE KEY UPDATE user_id = user_id",
|
||||
ON DUPLICATE KEY UPDATE guild_id = ?",
|
||||
user_id.get(),
|
||||
guild_id.get(),
|
||||
guild_id.get()
|
||||
)
|
||||
.execute(&ctx.data().database)
|
||||
@@ -61,7 +45,7 @@ impl Recordable for Options {
|
||||
}
|
||||
}
|
||||
|
||||
/// Link your Patreon subscription to this server. This command can be run once every four weeks
|
||||
/// Link your Patreon subscription to this server to allow other users Patreon access.
|
||||
#[poise::command(
|
||||
slash_command,
|
||||
rename = "link",
|
||||
|
||||
Reference in New Issue
Block a user