More work on todo list
This commit is contained in:
		@@ -388,22 +388,13 @@ pub(crate) async fn create_reminder(
 | 
			
		||||
        _ => {}
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    {
 | 
			
		||||
        // validate channel
 | 
			
		||||
        let channel = ChannelId::new(reminder.channel).to_channel_cached(&ctx.cache);
 | 
			
		||||
        let channel_exists = channel.is_some();
 | 
			
		||||
    if !check_channel_matches_guild(ctx, ChannelId::new(reminder.channel), guild_id) {
 | 
			
		||||
        warn!(
 | 
			
		||||
            "Error in `create_reminder`: channel {} not found for guild {}",
 | 
			
		||||
            reminder.channel, guild_id
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        let channel_matches_guild =
 | 
			
		||||
            channel.map_or(false, |c| c.guild(&ctx.cache).map_or(false, |c| c.id == guild_id));
 | 
			
		||||
 | 
			
		||||
        if !channel_matches_guild || !channel_exists {
 | 
			
		||||
            warn!(
 | 
			
		||||
                "Error in `create_reminder`: channel {} not found for guild {} (channel exists: {})",
 | 
			
		||||
                reminder.channel, guild_id, channel_exists
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            return Err(json!({"error": "Channel not found"}));
 | 
			
		||||
        }
 | 
			
		||||
        return Err(json!({"error": "Channel not found"}));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let channel =
 | 
			
		||||
@@ -601,6 +592,21 @@ pub(crate) async fn create_reminder(
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn check_channel_matches_guild(ctx: &Context, channel_id: ChannelId, guild_id: GuildId) -> bool {
 | 
			
		||||
    // validate channel
 | 
			
		||||
    let channel = channel_id.to_channel_cached(&ctx.cache);
 | 
			
		||||
    let channel_exists = channel.is_some();
 | 
			
		||||
 | 
			
		||||
    if !channel_exists {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let channel_matches_guild =
 | 
			
		||||
        channel.map_or(false, |c| c.guild(&ctx.cache).map_or(false, |g| g.id == guild_id));
 | 
			
		||||
 | 
			
		||||
    channel_matches_guild
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async fn create_database_channel(
 | 
			
		||||
    ctx: impl CacheHttp,
 | 
			
		||||
    channel: ChannelId,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user