fixed some crashes relating to dmming users outside a guild, also fixed recursive p/says
This commit is contained in:
parent
9a09f7fd49
commit
4970f1a10f
2 changed files with 120 additions and 56 deletions
|
@ -11,8 +11,10 @@ function delay(time) {
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: "dmuser",
|
name: "dmuser",
|
||||||
description: "forces bot to dm a user something (this will ghost ping them)",
|
description: "forces bot to dm a user something (this will ghost ping them)",
|
||||||
execute(message, args, client) {
|
execute(message, args) {
|
||||||
const user = message.mentions.users.first();
|
const user = message.mentions.users.first();
|
||||||
|
const guild = message.guild;
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -22,44 +24,83 @@ module.exports = {
|
||||||
|
|
||||||
console.log(typeof user);
|
console.log(typeof user);
|
||||||
console.log(user.username);
|
console.log(user.username);
|
||||||
//const usercache = client.users.fetch(user.id, false, true);
|
|
||||||
|
|
||||||
const msg = msgnoprefix.slice(0, 2000);
|
const msg = msgnoprefix.slice(0, 2000);
|
||||||
|
|
||||||
|
let ableToSend = true;
|
||||||
|
|
||||||
if (msg !== "") {
|
if (msg !== "") {
|
||||||
user.send(msg);
|
user.send(msg).catch(() => {
|
||||||
message.delete();
|
message.channel.send(
|
||||||
fs.appendFileSync(
|
`cannot send message to ${user}, this is usually caused by them not being inside the server`
|
||||||
"../pepperbot/src/logs/forcesay.log",
|
);
|
||||||
Date() +
|
fs.appendFileSync(
|
||||||
" " +
|
"../pepperbot/src/logs/forcesay.log",
|
||||||
message.author.username +
|
Date() +
|
||||||
" (" +
|
" " +
|
||||||
message.author +
|
message.author.username +
|
||||||
") forced bot to dm " +
|
" (" +
|
||||||
user.username +
|
message.author +
|
||||||
msg +
|
") attempted to force bot to dm " +
|
||||||
"\n",
|
user.username +
|
||||||
(err) => {
|
msg +
|
||||||
if (err !== null) {
|
"\n",
|
||||||
console.error(err);
|
(err) => {
|
||||||
fs.appendFileSync(
|
if (err !== null) {
|
||||||
"../pepperbot/src/logs/errors.log",
|
console.error(err);
|
||||||
err + " from: " + message.content + " at " + Date()
|
fs.appendFileSync(
|
||||||
);
|
"../pepperbot/src/logs/errors.log",
|
||||||
|
err + " from: " + message.content + " at " + Date()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
);
|
console.log(
|
||||||
console.log(
|
Date() +
|
||||||
Date() +
|
message.author.username +
|
||||||
message.author.username +
|
" (" +
|
||||||
" (" +
|
message.author +
|
||||||
message.author +
|
") attempted to force bot to dm " +
|
||||||
") forced bot to dm " +
|
user.username +
|
||||||
user.username +
|
msg +
|
||||||
msg +
|
"\n"
|
||||||
"\n"
|
);
|
||||||
);
|
ableToSend = false;
|
||||||
|
});
|
||||||
|
message.delete();
|
||||||
|
if (ableToSend) {
|
||||||
|
fs.appendFileSync(
|
||||||
|
"../pepperbot/src/logs/forcesay.log",
|
||||||
|
Date() +
|
||||||
|
" " +
|
||||||
|
message.author.username +
|
||||||
|
" (" +
|
||||||
|
message.author +
|
||||||
|
") forced bot to dm " +
|
||||||
|
user.username +
|
||||||
|
msg +
|
||||||
|
"\n",
|
||||||
|
(err) => {
|
||||||
|
if (err !== null) {
|
||||||
|
console.error(err);
|
||||||
|
fs.appendFileSync(
|
||||||
|
"../pepperbot/src/logs/errors.log",
|
||||||
|
err + " from: " + message.content + " at " + Date()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
Date() +
|
||||||
|
message.author.username +
|
||||||
|
" (" +
|
||||||
|
message.author +
|
||||||
|
") forced bot to dm " +
|
||||||
|
user.username +
|
||||||
|
msg +
|
||||||
|
"\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,30 +1,53 @@
|
||||||
const fs = require('fs')
|
const fs = require("fs");
|
||||||
|
|
||||||
const prefix = process.env.PREFIX
|
const prefix = process.env.PREFIX;
|
||||||
|
|
||||||
function delay(time) {
|
function delay(time) {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve) => {
|
||||||
setTimeout(resolve, time);
|
setTimeout(resolve, time);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'say',
|
name: "say",
|
||||||
description: 'forces bot to say something',
|
description: "forces bot to say something",
|
||||||
execute(message, args){
|
execute(message, args) {
|
||||||
const msgnoprefix = message.content.slice(prefix.length + this.name.length)
|
if (message.author.bot) return;
|
||||||
const msg = msgnoprefix.slice(0, 2000)
|
const msgnoprefix = message.content.slice(prefix.length + this.name.length);
|
||||||
|
const msg = msgnoprefix.slice(0, 2000);
|
||||||
|
|
||||||
if (msg !== '') {
|
if (msg !== "") {
|
||||||
message.channel.send(msg)
|
message.channel.send(msg);
|
||||||
message.delete()
|
message.delete();
|
||||||
fs.appendFileSync("../pepperbot/src/logs/forcesay.log", Date() + " " + message.author.username + " (" + message.author + ") forced bot to say " + msg + "\n", (err) => {
|
fs.appendFileSync(
|
||||||
if (err !== null) {
|
"../pepperbot/src/logs/forcesay.log",
|
||||||
console.error(err)
|
Date() +
|
||||||
fs.appendFileSync("../pepperbot/src/logs/errors.log", err + ' from: ' + message.content + " at " + Date())
|
" " +
|
||||||
}
|
message.author.username +
|
||||||
})
|
" (" +
|
||||||
console.log(Date() + " " + message.author.username + " (" + message.author + ") forced bot to say " + msg)
|
message.author +
|
||||||
}
|
") forced bot to say " +
|
||||||
|
msg +
|
||||||
|
"\n",
|
||||||
|
(err) => {
|
||||||
|
if (err !== null) {
|
||||||
|
console.error(err);
|
||||||
|
fs.appendFileSync(
|
||||||
|
"../pepperbot/src/logs/errors.log",
|
||||||
|
err + " from: " + message.content + " at " + Date()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
Date() +
|
||||||
|
" " +
|
||||||
|
message.author.username +
|
||||||
|
" (" +
|
||||||
|
message.author +
|
||||||
|
") forced bot to say " +
|
||||||
|
msg
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue