mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Fix bulk deletion error if < 2 messages
Also return error if no server (dm)
This commit is contained in:
@@ -849,7 +849,7 @@ var InternalClient = (function () {
|
||||
|
||||
InternalClient.prototype.deleteMessages = function deleteMessages(_messages) {
|
||||
if (!_messages instanceof Array) return Promise.reject(new Error("Messages provided must be in an array"));
|
||||
if (_messages.length < 1) return Promise.reject(new Error("You must provide at least one message to delete"));
|
||||
if (_messages.length < 2) return Promise.reject(new Error("You must provide at least two messages to delete"));
|
||||
|
||||
var messages = [];
|
||||
var channel;
|
||||
@@ -870,6 +870,10 @@ var InternalClient = (function () {
|
||||
var message = this.resolver.resolveMessage(_message);
|
||||
if (!message) return Promise.reject(new Error("Something other than a message could not be resolved in the array..."));
|
||||
|
||||
if (!message.server) {
|
||||
return Promise.reject(new Error("You can only bulk delete messages on guild channels"));
|
||||
}
|
||||
|
||||
// ensure same channel
|
||||
if (!channel) {
|
||||
channel = message.channel;
|
||||
|
||||
Reference in New Issue
Block a user