async def rm(self, ctx, ytchannel_id: str): # this will remove the yt channel from followinglist try: if not is_string(ytchannel_id): return s = self.db.Session() yt_id = self._get_yt_id(s, ytchannel_id) if yt_id is None: await ctx.send( "Channel is not on your followinglist" ) return # check if this is on followinglist if self._exists_ytfollow(s, yt_id, ctx.guild.id): # is on the guilds followinglist remove it ytf = s.query( models.YoutubeFollow ).filter( models.YoutubeFollow.youtube_id == yt_id, models.YoutubeFollow.guild_id == ctx.guild.id ).one() s.delete(ytf) # check if this is the last guild, remove it from yt if not s.query( exists() .where( models.YoutubeFollow.youtube_id == yt_id )).scalar(): ytc = s.query( models.Youtube ).get(yt_id) s.delete(ytc) s.commit() await ctx.send( "Channel was removed from your followinglist" ) else: await ctx.send( "Channel is not on your followinglist" ) s.close() except Exception as e: logging.error( f"Error in youtube.rm command: {e}" ) s.rollback() s.close()
async def rm(self, ctx, msg: str, role: str): try: s = self.db.Session() # demojize the string role_n = self._convert_emoji_to_string(msg) if not is_string(role_n): return if is_role(role): # extract role id role_id = get_role_id_from_string(role) # skip if this role is not existing on the server if ctx.guild.get_role(int(role_id)) is None: return else: return # check if this is already existing in database if self._exists_reactionrole(s, role_n, ctx.guild.id): # delete reactionrole obj = s.query(models.Reactionrole).filter( models.Reactionrole.guild_id == ctx.guild.id, models.Reactionrole.name == role_n, models.Reactionrole.role_id == role_id) obj.delete() s.commit() await ctx.channel.send("Reactionrole was deleted from list.") else: await ctx.channel.send("Reactionrole is not existing.") except Exception as e: logging.error(f"Error in reactionrole command: {e}") s.rollback() finally: s.close()
async def disable_upload_notify(self, ctx, ytchannel_id: str): # this will disable the upload notification for the yt channel if not is_string(ytchannel_id): return s = self.db.Session() self._switch_ytmod( s, ctx.guild.id, ytchannel_id, "monitor_videos", 0 ) s.commit() await ctx.send( "Upload Notifications disabled for channel." ) s.close()
async def enable_goal_notify(self, ctx, ytchannel_id: str): # this will enable the goal notification for the yt channel if not is_string(ytchannel_id): return s = self.db.Session() self._switch_ytmod( s, ctx.guild.id, ytchannel_id, "monitor_goals", 1 ) s.commit() await ctx.send( "Goal Notifications enabled for channel." ) s.close()
async def add(self, ctx, msg: str, role: str): try: s = self.db.Session() # demojize the string role_n = self._convert_emoji_to_string(msg) if not is_string(role_n): return if is_role(role): # extract role id role_id = get_role_id_from_string(role) # skip if this role is not existing on the server if ctx.guild.get_role(int(role_id)) is None: return else: return # check if this is already existing in database if self._exists_reactionrole(s, role_n, ctx.guild.id): await ctx.channel.send("Reactionrole is already existing.") return # reactionrole is not existing, add to list new_rr = models.Reactionrole(guild_id=ctx.guild.id, name=role_n, role_id=role_id) s.add(new_rr) s.commit() await ctx.channel.send("Reactionrole was added to list") except Exception as e: logging.error(f"Error in reactionrole command: {e}") s.rollback() finally: s.close()
async def add(self, ctx, ytchannel_id: str): # this will add the yt channel to followinglist try: if not is_string(ytchannel_id): return s = self.db.Session() # check if channel is already existing in database yt_id = self._get_yt_id(s, ytchannel_id) if yt_id is not None: # channel is existing, check if channel is on followlist if self._exists_ytfollow(s, yt_id, ctx.guild.id): # is already on list, send message await ctx.send( "This channel is already on your followinglist" ) else: # channel is not existing, add to list new_ytf = models.YoutubeFollow( guild_id=ctx.guild.id, youtube_id=yt_id, monitor_videos=0, monitor_goals=0, monitor_streams=0, remind_streams=0 ) s.add(new_ytf) s.commit() await ctx.send( "Channel was added to your followinglist" ) else: # channel is not existing, add to the database # check if the channel is a valid youtube channel # WIP! # new_yt = models.Youtube( valid=True, ytchannel_id=ytchannel_id ) s.add(new_yt) s.commit() yt_id = self._get_yt_id(s, ytchannel_id) new_ytf = models.YoutubeFollow( guild_id=ctx.guild.id, youtube_id=yt_id, monitor_videos=0, monitor_goals=0, monitor_streams=0, remind_streams=0, ) s.add(new_ytf) s.commit() await ctx.send( "Channel was added to your followinglist" ) s.close() except Exception as e: logging.error( f"Error in youtube.add command: {e}" ) s.rollback() s.close()