moderation.tidy: fix message count
This commit is contained in:
parent
99510766d4
commit
0006b5eaa4
1 changed files with 32 additions and 20 deletions
|
@ -19,12 +19,14 @@ tidy.callback = async function (msg, line, [subcommand, count, extra]) {
|
||||||
|
|
||||||
switch (subcommand) {
|
switch (subcommand) {
|
||||||
case "all": {
|
case "all": {
|
||||||
const messages = await msg.channel.getMessages({
|
const messages = await msg.channel
|
||||||
|
.getMessages({
|
||||||
before: msg.id,
|
before: msg.id,
|
||||||
limit: count && parseInt(count) > 0 ? parseInt(count) : 10,
|
limit: count && parseInt(count) > 0 ? parseInt(count) : 10,
|
||||||
});
|
})
|
||||||
|
.then((msgs) => msgs.map((m) => m.id));
|
||||||
await msg.channel.deleteMessages(
|
await msg.channel.deleteMessages(
|
||||||
messages.map((m) => m.id),
|
messages,
|
||||||
`Message purge by ${formatUsername(msg.author)}`
|
`Message purge by ${formatUsername(msg.author)}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -35,12 +37,16 @@ tidy.callback = async function (msg, line, [subcommand, count, extra]) {
|
||||||
if (typeof user === "string") {
|
if (typeof user === "string") {
|
||||||
return user;
|
return user;
|
||||||
} else {
|
} else {
|
||||||
const messages = await msg.channel.getMessages({
|
const messages = await msg.channel
|
||||||
|
.getMessages({
|
||||||
before: msg.id,
|
before: msg.id,
|
||||||
limit: extra && parseInt(extra) > 0 ? parseInt(extra) : 10,
|
limit: extra && parseInt(extra) > 0 ? parseInt(extra) : 10,
|
||||||
});
|
})
|
||||||
|
.then((msgs) =>
|
||||||
|
msgs.filter((m) => m.author.id == user.id).map((m) => m.id)
|
||||||
|
);
|
||||||
await msg.channel.deleteMessages(
|
await msg.channel.deleteMessages(
|
||||||
messages.filter((m) => m.author.id == user.id).map((m) => m.id),
|
messages,
|
||||||
`Message purge by ${formatUsername(
|
`Message purge by ${formatUsername(
|
||||||
msg.author
|
msg.author
|
||||||
)} targeting ${formatUsername(user)}`
|
)} targeting ${formatUsername(user)}`
|
||||||
|
@ -50,12 +56,14 @@ tidy.callback = async function (msg, line, [subcommand, count, extra]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "bots": {
|
case "bots": {
|
||||||
const messages = await msg.channel.getMessages({
|
const messages = await msg.channel
|
||||||
|
.getMessages({
|
||||||
before: msg.id,
|
before: msg.id,
|
||||||
limit: count && parseInt(count) > 0 ? parseInt(count) : 50,
|
limit: count && parseInt(count) > 0 ? parseInt(count) : 50,
|
||||||
});
|
})
|
||||||
|
.then((msgs) => msgs.filter((m) => msg.author.bot).map((m) => m.id));
|
||||||
await msg.channel.deleteMessages(
|
await msg.channel.deleteMessages(
|
||||||
messages.filter((m) => msg.author.bot).map((m) => m.id),
|
messages,
|
||||||
`Message purge by ${formatUsername(msg.author)} targeting bots`
|
`Message purge by ${formatUsername(msg.author)} targeting bots`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -65,12 +73,16 @@ tidy.callback = async function (msg, line, [subcommand, count, extra]) {
|
||||||
if (count.length === 0)
|
if (count.length === 0)
|
||||||
return "Filter must be at least 1 character long.";
|
return "Filter must be at least 1 character long.";
|
||||||
|
|
||||||
const messages = await msg.channel.getMessages({
|
const messages = await msg.channel
|
||||||
|
.getMessages({
|
||||||
before: msg.id,
|
before: msg.id,
|
||||||
limit: extra && parseInt(extra) > 0 ? parseInt(extra) : 10,
|
limit: extra && parseInt(extra) > 0 ? parseInt(extra) : 10,
|
||||||
});
|
})
|
||||||
|
.then((msgs) =>
|
||||||
|
msgs.filter((m) => m.content.indexOf(count) > -1).map((m) => m.id)
|
||||||
|
);
|
||||||
await msg.channel.deleteMessages(
|
await msg.channel.deleteMessages(
|
||||||
messages.filter((m) => m.content.indexOf(count) > -1).map((m) => m.id),
|
messages,
|
||||||
`Message purge by ${formatUsername(msg.author)} targeting "${count}"`
|
`Message purge by ${formatUsername(msg.author)} targeting "${count}"`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue