mirror of
https://github.com/Wessel/yorushika.git
synced 2026-07-26 10:12:24 +02:00
Eval fix + add silent
This commit is contained in:
@@ -52,4 +52,5 @@ developer:
|
||||
eval :
|
||||
0 : <a:voting:501106582915121154> # Invalid snippet
|
||||
1 : <a:agoogleoctopus:494927680911704067> # Evaluating
|
||||
2 : <a:voting:501106582915121154> # Result
|
||||
2 : <:ok_hand:497396122416054287> # Result (silent)
|
||||
3 : <a:voting:501106582915121154> # Result
|
||||
@@ -65,15 +65,16 @@ image:
|
||||
failed_cache: 'Click here if the image didn''t load properly'
|
||||
|
||||
developer:
|
||||
echo : '$[emoji#0] Invalid content to echo'
|
||||
eval :
|
||||
args : '$[emoji#0] Invalid snippet of code to evaluate'
|
||||
busy: '$[emoji#1] Evaluating, this may take some time...'
|
||||
types:
|
||||
echo : '$[emoji#0] Invalid content to echo'
|
||||
eval :
|
||||
args : '$[emoji#0] Invalid snippet of code to evaluate'
|
||||
busy : '$[emoji#1] Evaluating, this may take some time...'
|
||||
silent: '$[emoji#2] Silently executed your snippet'
|
||||
types :
|
||||
- 'succeed'
|
||||
- 'failed'
|
||||
result:
|
||||
- '$[emoji#2] **Result** (`$[result:type]`):'
|
||||
- '$[emoji#3] **Result** (`$[result:type]`):'
|
||||
- '```js'
|
||||
- '$[result:message]'
|
||||
- '```'
|
||||
@@ -23,15 +23,19 @@ module.exports = class Eval extends DiscordCommand {
|
||||
|
||||
async execute(msg, args) {
|
||||
let result;
|
||||
let silent = args.join(' ').endsWith('--slient') || args.join(' ').endsWith('-s');
|
||||
let asynchr = args.join(' ').includes('return') || args.join(' ').includes('await');
|
||||
let errored = false;
|
||||
|
||||
if (args.length <= 0) return msg.channel.createMessage(this.localize(msg.author.locale['developer']['eval']['args']));
|
||||
|
||||
const message = await msg.channel.createMessage(this.localize(msg.author.locale['developer']['eval']['busy']));
|
||||
if (silent) args = args.join(' ').replace(/--silent$|-s$/g, '').split(' ');
|
||||
const message = await msg.channel.createMessage(this.localize(msg.author.locale['developer']['eval']['busy']));
|
||||
|
||||
try { result = eval(args.join(' ')); }
|
||||
try { result = (asynchr ? eval(`(async() => {${args.join(' ')}})();`) : eval(args.join(' '))); }
|
||||
catch (ex) { result = ex; errored = true; }
|
||||
finally {
|
||||
if (silent) return message.edit(this.localize(msg.author.locale['developer']['eval']['silent']));
|
||||
result = this.sanitize(String(inspect(result)));
|
||||
|
||||
message.edit({
|
||||
@@ -63,6 +67,7 @@ module.exports = class Eval extends DiscordCommand {
|
||||
return msg
|
||||
.replace(/\$\[emoji#0]/g, this.bot.emote('developer', 'eval', '0'))
|
||||
.replace(/\$\[emoji#1]/g, this.bot.emote('developer', 'eval', '1'))
|
||||
.replace(/\$\[emoji#2]/g, this.bot.emote('developer', 'eval', '2'));
|
||||
.replace(/\$\[emoji#2]/g, this.bot.emote('developer', 'eval', '2'))
|
||||
.replace(/\$\[emoji#3]/g, this.bot.emote('developer', 'eval', '3'));
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user