pub async fn post_channel(
        &self,
        ctx: &Context,
        training: &db::Training,
    ) -> Result<GuildChannel> {
        let date = training.date.date();
        let channel = match db::SignupBoardChannel::by_day(ctx, date).await {
            Ok(ch) => Some(ch),
            Err(diesel::NotFound) => None,
            Err(e) => return Err(e.into()),
        };
        if let Some(ch) = channel {
            if let Ok(ch) = ctx.http.get_channel(*ch.channel().as_u64()).await {
                if let Some(gch) = ch.guild() {
                    return Ok(gch);
                }
            }
            // Something is weird, remove db entry
            ch.delete(ctx).await?;
        }
        // create new channel
        let channel = insert_channel_ordered(
            ctx,
            load_guild_id(ctx).await?,
            self.get_category_channel()?,
            date,
        )
        .await?;
        // add to db
        db::SignupBoardChannel::insert(ctx, date, channel.id).await?;
        return Ok(channel);
    }
// Posts a channel for a day if it does not exist yet
Posts a channel for a day if it does not exist yet
Posts a channel for a day if it does not exist yet
pub async fn post_channel(
        &self,
        ctx: &Context,
        training: &db::Training,
    ) -> Result<GuildChannel> {
        let date = training.date.date();
        let channel = match db::SignupBoardChannel::by_day(ctx, date).await {
            Ok(ch) => Some(ch),
            Err(diesel::NotFound) => None,
            Err(e) => return Err(e.into()),
        };
        if let Some(ch) = channel {
            if let Ok(ch) = ctx.http.get_channel(*ch.channel().as_u64()).await {
                if let Some(gch) = ch.guild() {
                    return Ok(gch);
                }
            }
            // Something is weird, remove db entry
            ch.delete(ctx).await?;
        }
        // create new channel
        let channel = insert_channel_ordered(
            ctx,
            load_guild_id(ctx).await?,
            self.get_category_channel()?,
            date,
        )
        .await?;
        // add to db
        db::SignupBoardChannel::insert(ctx, date, channel.id).await?;
        return Ok(channel);
    }
pub async fn post_channel ( & self , ctx : & Context , training : & db :: Training , ) -> Result < GuildChannel > { let date = training . date . date ( ) ; let channel = match db :: SignupBoardChannel :: by_day ( ctx , date ) . await { Ok ( ch ) => Some ( ch ) , Err ( diesel :: NotFound ) => None , Err ( e ) => return Err ( e . into ( ) ) , } ; if let Some ( ch ) = channel { if let Ok ( ch ) = ctx . http . get_channel ( * ch . channel ( ) . as_u64 ( ) ) . await { if let Some ( gch ) = ch . guild ( ) { return Ok ( gch ) ; } } // Something is weird, remove db entry ch . delete ( ctx ) . await ? ; } // create new channel let channel = insert_channel_ordered ( ctx , load_guild_id ( ctx ) . await ? , self . get_category_channel ( ) ? , date , ) . await ? ; // add to db db :: SignupBoardChannel :: insert ( ctx , date , channel . id ) . await ? ; return Ok ( channel ) ; }
Posts a channel for a day if it does not exist yet
Posts a channel for a day if it does not exist yet
&self
ctx
&Context
training
&db::Training