summaryrefslogtreecommitdiff
path: root/eval_handler.py
diff options
context:
space:
mode:
authorromangraef <roman.graef@gmail.com>2018-05-05 13:07:04 +0200
committerromangraef <roman.graef@gmail.com>2018-05-05 13:07:04 +0200
commit50787a7a3c14b8cbe1890cfdc62bc1d27171209c (patch)
tree9701c8fa2d124568cf67c029a0a5d8e706962987 /eval_handler.py
parent167d09793bcbbc29282507f6ff911dde174faa1d (diff)
downloadfuckingselfbot-50787a7a3c14b8cbe1890cfdc62bc1d27171209c.tar.gz
fuckingselfbot-50787a7a3c14b8cbe1890cfdc62bc1d27171209c.tar.bz2
fuckingselfbot-50787a7a3c14b8cbe1890cfdc62bc1d27171209c.zip
added eval guild support
Diffstat (limited to 'eval_handler.py')
-rw-r--r--eval_handler.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/eval_handler.py b/eval_handler.py
index 89e8e09..f4690a5 100644
--- a/eval_handler.py
+++ b/eval_handler.py
@@ -3,7 +3,7 @@ from typing import List, Dict, Pattern
import discord
REPLACEMENTS: Dict[Pattern, str] = {
- re.compile(r'<@!?(?P<id>[0-9]+)>'): '(guild.get_member({id}) or client.get_user({id}))',
+ re.compile(r'<@!?(?P<id>[0-9]+)>'): '(guild.get_member({id}) if guild is not None else client.get_user({id}))',
re.compile(r'<#(?P<id>[0-9]+)>'): '(discord.utils.get(all_channels, id={id}))',
re.compile(r'<@&(?P<id>[0-9]+)>'): '(discord.utils.get(all_roles, id={id}))',
# Maybe later emoji support
@@ -32,6 +32,8 @@ async def handle_eval(message: discord.Message, client: discord.Client):
'client': client,
'discord': discord,
}
+ if channel.guild is not None:
+ variables['guild'] = channel.guild
lines: List[str] = content[command_start:].strip().split('\n')
lines[-1] = 'return ' + lines[-1]
block: str = '\n'.join(' ' + line for line in lines)