def remove_event(self, event): if len(event.args) >= 1: #Loading the storage guilds = storage.load() #Setting some variables guild_id = str(event.guild.id) channel_id = str(event.msg.channel_id) not_log_event = [] not_logging = [] removed_log_event = [] #Checking permissions if not is_allowed(guild=event.msg.guild, user=event.msg.author): return event.msg.reply(response.command.invalid_permissions) #Make sure the channel is a log channel if channel_id not in guilds[guild_id]: return event.msg.reply(response.command.not_log_event) #Make sure the log event is valid for log_event in event.args: log_event = log_event.upper() if log_event in user_events: if log_event not in guilds[guild_id][channel_id]["events"]: not_logging.append(log_event) else: guilds[guild_id][channel_id]["events"].remove( log_event) removed_log_event.append(log_event) else: not_log_event.append(log_event) storage.write(guilds) if len(removed_log_event): event.msg.reply( response.command.removed_log_events.format( "`, `".join(removed_log_event))) if len(not_logging): event.msg.reply( response.command.not_logging.format( "`, `".join(not_logging))) if len(not_log_event): event.msg.reply( response.command.not_log_events.format( "`, `".join(not_log_event))) else: return event.msg.reply(response.not_enough_arguments)
def log_type(self, event): #Assigning some variables guilds = storage.load() guild_id = str(event.guild.id) channel_id = str(event.msg.channel_id) log_types = { "simple": "compact", "plain": "compact", "compact": "compact", "fanceh": "fanceh", "fancy-ish": "fanceh", "fancy": "rich", "rich": "rich" } #Permission checking if not is_allowed(guild=event.msg.guild, user=event.msg.author): event.msg.reply(response.command.invalid_permissions) #Checking the guild for data if guild_id not in guilds: return event.msg.reply(response.command.no_guild_data) #Checking if the channel is a log if channel_id not in guilds[guild_id]: return event.msg.reply(response.command.not_log) #Make sure they supplied an argument if len(event.args): if event.args[0] in log_types: #Check if the log is already that style if log_types[ event.args[0]] == guilds[guild_id][channel_id]["type"]: return event.msg.reply(response.command.already_log_type) guilds[guild_id][channel_id]["type"] = log_types[event.args[0]] storage.write(guilds) event.msg.reply( response.command.changed_log_type.format( log_types[event.args[0]])) else: event.msg.reply(response.command.not_enough_arguments)
def log_list(self, event): #loading storage guilds = storage.load() #Assigning some variables guild_id = str(event.guild.id) #Checking to make sure the guild exists in the database if guild_id not in guilds: return event.msg.reply(response.command.no_guild_data) #Checking permissions if not is_allowed(guild=event.msg.guild, user=event.msg.author): return event.msg.reply(response.command.invalid_permissions) #Creating and sending the message logs = "<#" + ">, <#".join(guilds[guild_id].keys()) + ">" event.msg.reply(response.command.log_list.format(logs))
def list_events(self, event): #Loading the storage guilds = storage.load() #Assigning some variables guild_id = str(event.guild.id) channel_id = str(event.msg.channel_id) #Checking permissions if not is_allowed(guild=event.msg.guild, user=event.msg.author): return event.msg.reply(response.command.invalid_permissions) #Ensuring the channel is a logging channel if channel_id not in guilds[guild_id]: return event.msg.reply(response.command.no_event_list) #Sending the channel list to chat. events = ", ".join(guilds[guild_id][channel_id]["events"]) return event.msg.reply(response.command.event_list.format(events))
def remove_log(self, event, channel_id=None): #Load the storage guilds = storage.load() #Setting some variables guild_id = str(event.guild.id) channel_id = str(event.msg.channel_id) #Checking permissions if not is_allowed(guild=event.msg.guild, user=event.msg.author): return event.msg.reply(response.command.invalid_permissions) #Make sure the guild is in the database if guild_id not in guilds: return event.msg.reply(response.command.no_guild_data) if channel_id not in guilds[guild_id]: return event.msg.reply(response.command.not_log_remove) else: storage.remove_log(guild_id, channel_id) return event.msg.reply(response.command.log_removed)
def add_log(self, event): #Load the storage guilds = storage.load() #Setting some variables guild_id = str(event.msg.guild.id) channel_id = str(event.msg.channel_id) #Checking permissions if not is_allowed(guild=event.msg.guild, user=event.msg.author): return event.msg.reply(response.command.invalid_permissions) #Add the guild if they are not in the database then reload the database if guild_id not in guilds: storage.add_guild(guild_id) guilds = storage.load() #Erroring if the channel is already a log if channel_id in guilds[guild_id]: return event.msg.reply(response.command.already_log) else: storage.add_log(guild_id, channel_id) return event.msg.reply(response.command.log_added)