async def custom_command(ev: SigmaEvent, message: discord.Message): if message.guild: prefix = await ev.db.get_prefix(message) if message.content.startswith(prefix): if message.content != prefix and not message.content.startswith( prefix + ' '): cmd = message.content[len(prefix):].lower().split()[0] if cmd not in ev.bot.modules.commands and cmd not in ev.bot.modules.alts: perms = ServerCommandPermissions(ev, message) await perms.check_perms() if perms.permitted: custom_commands = await ev.db.get_guild_settings( message.guild.id, 'CustomCommands') if custom_commands is None: custom_commands = {} if cmd in custom_commands: cmd_text = custom_commands[cmd] img = False if cmd_text.startswith('http'): img_endings = ['.gif', '.png', '.jpg', '.jpeg'] for ending in img_endings: if cmd_text.endswith(ending): img = True break if img: response = discord.Embed().set_image( url=cmd_text) await message.channel.send(embed=response) else: response = command_message_parser( message, cmd_text) await message.channel.send(response) log_command_usage(ev.log, message, cmd)
async def auto_responder(ev: SigmaEvent, message: discord.Message): if message.guild: if message.content: pfx = await ev.db.get_prefix(message) if not message.content.startswith(pfx): triggers = await ev.db.get_guild_settings(message.guild.id, 'responder_triggers') if triggers is None: triggers = {} arguments = message.content.split(' ') for arg in arguments: arg = clean_word(arg) if arg in triggers: response = triggers[arg] response = command_message_parser(message, response) await message.channel.send(response) break
async def custom_command(ev, pld): """ :param ev: The event object referenced in the event. :type ev: sigma.core.mechanics.event.SigmaEvent :param pld: The event payload data to process. :type pld: sigma.core.mechanics.payload.MessagePayload """ if pld.msg.guild: prefix = ev.db.get_prefix(pld.settings) if pld.msg.content.startswith(prefix): if pld.msg.content != prefix and not pld.msg.content.startswith( prefix + ' '): cmd = pld.msg.content[len(prefix):].lower().split()[0] if cmd not in ev.bot.modules.commands and cmd not in ev.bot.modules.alts: perms = ServerCommandPermissions(ev, pld.msg) await perms.check_perms() if perms.permitted: custom_commands = pld.settings.get('custom_commands') if custom_commands is None: custom_commands = {} if cmd in custom_commands: delcmd = pld.settings.get('delete_commands') if delcmd: try: await pld.msg.delete() except (discord.NotFound, discord.Forbidden): pass cmd_text = custom_commands[cmd] img = False if cmd_text.startswith('http'): img_endings = ['.gif', '.png', '.jpg', '.jpeg'] for ending in img_endings: if cmd_text.endswith(ending): img = True break if img: response = discord.Embed().set_image( url=cmd_text) await pld.msg.channel.send(embed=response) else: response = command_message_parser( pld.msg, cmd_text) await pld.msg.channel.send( escape_mentions(response, pld.msg.guild)) log_command_usage(ev.log, pld.msg, cmd)
async def custom_command(ev, message): if message.guild: prefix = ev.bot.get_prefix(message) if message.content.startswith(prefix): if message.content != prefix: cmd = message.content[len(prefix):].lower().split()[0] if cmd not in ev.bot.modules.commands: perms = GlobalCommandPermissions(ev, message) if perms.permitted: custom_commands = ev.db.get_guild_settings( message.guild.id, 'CustomCommands') if custom_commands is None: custom_commands = {} if cmd in custom_commands: cmd_text = custom_commands[cmd] response = command_message_parser( message, cmd_text) log_command_usage(ev.log, message, cmd) await message.channel.send(response)
async def auto_responder(ev, pld): """ :param ev: The event object referenced in the event. :type ev: sigma.core.mechanics.event.SigmaEvent :param pld: The event payload data to process. :type pld: sigma.core.mechanics.payload.MessagePayload """ if pld.msg.guild: if pld.msg.content: pfx = ev.db.get_prefix(pld.settings) if not pld.msg.content.startswith(pfx): triggers = pld.settings.get('responder_triggers') or {} # sort triggers by word count to avoid longer ones never triggering triggers = sorted(triggers.items(), key=lambda x: len(x[0].split()), reverse=True) for trigger, response in triggers: match = match_trigger(pld.msg.content, trigger) if match: response = command_message_parser(pld.msg, response) await pld.msg.channel.send(response) break