async def create_autodaily_settings(bot: discord.ext.commands.Bot, guild_id: int) -> AutoDailySettings: if guild_id is None or bot is None: raise Exception( 'No parameters given. You need to specify both parameters \'bot\' and \'guild_id\'.' ) autodaily_settings = await _prepare_create_autodaily_settings(guild_id) _, channel_id, can_post, latest_message_id, delete_on_change, notify_id, notify_type, latest_message_create_date, latest_message_modify_date = autodaily_settings[ 0] try: channel = bot.get_channel(channel_id) except Exception as error: channel = None try: guild = bot.get_guild(guild_id) except Exception as error: guild = None notify = None if notify_id and notify_type and guild: if notify_type == AutoDailyNotifyType.USER: notify = guild.get_member(notify_id) elif notify_type == AutoDailyNotifyType.ROLE: notify = guild.get_role(notify_id) return AutoDailySettings(guild, channel, can_post, latest_message_id, delete_on_change, notify, latest_message_create_date, latest_message_modify_date)
def _schedule_event(bot: discord.ext.commands.Bot): task_info_list = execute_statement( create_select_query("configure__schedule")).all(as_dict=True) for task_info in task_info_list: local_guild: discord.Guild = bot.get_guild(task_info.get("guild_id")) re_schedule_task( bot, _get_task(task_info.get("task")), task_info.get("weekday"), task_info.get("at_time"), task_info.get("tag"), message=task_info.get("message"), channel=bot.get_channel(int(task_info.get("channel_id"))), number=task_info.get("number"), guild=local_guild, category=None if local_guild is None else discord.utils.get( local_guild.categories, id=int(task_info.get("category_id"))))
async def report_infraction(bot: discord.ext.commands.Bot, infraction: Infraction): """Logs the infraction to the infraction report channel Required parameters: - bot: discord.ext.commands.Bot object - infraction: models.Infraction.Infraction object Returns: None """ # Get the channel the report should be send to ch = bot.get_guild(config.guild).get_channel(config.infrepch) # Send the infraction await ch.send(embed=str(infraction)) del ch