fix split
This commit is contained in:
parent
7ff1e84f21
commit
14ec1867d5
29
commands.js
29
commands.js
@ -29,21 +29,28 @@ client.on("messageCreate", async function (message) {
|
||||
if (typeof x == "undefined") return void await message.react(config.eval_undefined_emoji);
|
||||
let t = typeof x == 'string' ? 'txt' : 'js';
|
||||
if (typeof x != 'string' && typeof x != "function") x = require('util').inspect(x, {depth: 1});
|
||||
message.channel.send(`\`\`\`${t}\n${x}\`\`\``, {split:{maxLength:2000,prepend:`\`\`\`${t}\n`,append:'```'}});
|
||||
let cb = `\`\`\`${t}\n${x}\`\`\``;
|
||||
if (cb.length <= 2000)
|
||||
message.channel.send(cb);
|
||||
else
|
||||
message.channel.send({files:[{
|
||||
attachment: Buffer.from(x),
|
||||
name: `output.${t}`
|
||||
}]});
|
||||
}
|
||||
|
||||
else if (message.content.startsWith("!$")) {
|
||||
let cp = require("child_process").spawn("bash", ["-c", message.content.substr(2).trim()]);
|
||||
cp.stdout.on("data", data => {
|
||||
message.channel.send(data.toString(), {split:{char:'\n',length:2000}}).catch(()=>{
|
||||
message.channel.send(data.toString(), {split:{char:'',length:2000}});
|
||||
});
|
||||
});
|
||||
cp.stderr.on("data", data => {
|
||||
message.channel.send(data.toString(), {split:{char:'\n',length:2000}}).catch(()=>{
|
||||
message.channel.send(data.toString(), {split:{char:'',length:2000}});
|
||||
});
|
||||
});
|
||||
function ondat(a) {
|
||||
try {
|
||||
var split = Discord.Util.splitMessage(a.toString(), {split:{char:'\n',length:2000}});
|
||||
} catch(x) {
|
||||
var split = Discord.Util.splitMessage(a.toString(), {split:{char:'',length:2000}});
|
||||
}
|
||||
split.forEach(say);
|
||||
}
|
||||
cp.stdout.on("data", ondat);
|
||||
cp.stderr.on("data", ondat);
|
||||
}
|
||||
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user