Skip to content

Commit

Permalink
painful fix for edited messages being proxied
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruthenic committed Nov 30, 2023
1 parent 783a4c8 commit 16070c2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/utils/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,19 @@ pub async fn send_proxied_message(
collective: DBCollective,
database: &Database,
) -> Result<()> {
let message = &mut message.clone();

let channels_collection = database.collection::<DBChannel>("channels");
let messages_collection = database.collection::<DBMessage>("messages");
let guilds_collection = database.collection::<DBGuild>("guilds");

let guild_config =
get_or_create_dbguild(&guilds_collection, message.guild_id.unwrap().get() as i64).await?;
// JANK: apparently, guild_id is not returned by the message object anymore. nor does `.channel()` work. so we must do this abomination
let channel_id = message.channel_id;
let channel = http.get_channel(channel_id).await?;
let guild_id = channel.guild().unwrap().guild_id;
message.guild_id = Some(guild_id);

let guild_config = get_or_create_dbguild(&guilds_collection, guild_id.get() as i64).await?;

if let Some(allowlist_role) = guild_config.allowlist_role {
if !message
Expand Down

0 comments on commit 16070c2

Please sign in to comment.