Fix update crashing when message is too long
This commit is contained in:
parent
c25e2bae71
commit
71df7372e8
1 changed files with 13 additions and 10 deletions
|
@ -19,17 +19,20 @@ module.exports = {
|
||||||
if(stdout.includes("server.js") || stdout.includes("server/")){
|
if(stdout.includes("server.js") || stdout.includes("server/")){
|
||||||
sendText = sendText + "\nServer.js OR a file the server/ directory has been updated.\nThis requires the bot to be restarted."
|
sendText = sendText + "\nServer.js OR a file the server/ directory has been updated.\nThis requires the bot to be restarted."
|
||||||
}
|
}
|
||||||
message.channel.send(sendText).then(function(msg){
|
|
||||||
let regex = /([^\s]+)\.\.([^\s]+)/
|
let regex = /([^\s]+)\.\.([^\s]+)/
|
||||||
let commits = stdout.match(regex)[0]
|
let commits = stdout.match(regex)[0]
|
||||||
cmd = `git log --oneline ${commits}`;
|
cmd = `git log --oneline ${commits}`;
|
||||||
exec(cmd, (err, stdout, stderr) =>{
|
exec(cmd, (err, stdout, stderr) =>{
|
||||||
process.stdout.write(stdout)
|
process.stdout.write(stdout)
|
||||||
let commitCount = stdout.split(/\r\n|\r|\n/).length - 1
|
let commitCount = stdout.split(/\r\n|\r|\n/).length - 1
|
||||||
msg.edit(`${sendText}\n\nLatest commits (${commitCount}):\n${stdout}`)
|
sendText = `${sendText}\n\nLatest commits (${commitCount}):\n${stdout}`
|
||||||
|
if(sendText.length >= 2000){
|
||||||
|
sendText.slice(1955)
|
||||||
|
sendText = `${sendText}\n... Message is too long to show everything`
|
||||||
|
}
|
||||||
|
message.channel.send(sendText)
|
||||||
if (err) console.log(stderr)
|
if (err) console.log(stderr)
|
||||||
})
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
if (err) {
|
if (err) {
|
||||||
message.channel.send("Something went wrong...");
|
message.channel.send("Something went wrong...");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue