mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
Errors Standardization (#1246)
* errors and stuff * more errors * all the errors * fix build
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const long = require('long');
|
||||
const { TypeError } = require('../../errors');
|
||||
|
||||
/**
|
||||
* @typedef {Object} MessageSearchOptions
|
||||
@@ -84,9 +85,7 @@ module.exports = function search(target, options) {
|
||||
const Guild = require('../Guild');
|
||||
const Message = require('../Message');
|
||||
|
||||
if (!(target instanceof Channel || target instanceof Guild)) {
|
||||
throw new TypeError('Target must be a TextChannel, DMChannel, GroupDMChannel, or Guild.');
|
||||
}
|
||||
if (!(target instanceof Channel || target instanceof Guild)) throw new TypeError('SEARCH_CHANNEL_TYPE');
|
||||
|
||||
let endpoint = target.client.api[target instanceof Channel ? 'channels' : 'guilds'](target.id).messages().search;
|
||||
return endpoint.get({ query: options }).then(body => {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const Util = require('../../util/Util');
|
||||
const { RangeError } = require('../../errors');
|
||||
|
||||
module.exports = function sendMessage(channel, options) {
|
||||
const User = require('../User');
|
||||
@@ -8,7 +9,7 @@ module.exports = function sendMessage(channel, options) {
|
||||
|
||||
if (typeof nonce !== 'undefined') {
|
||||
nonce = parseInt(nonce);
|
||||
if (isNaN(nonce) || nonce < 0) throw new RangeError('Message nonce must fit in an unsigned 64-bit integer.');
|
||||
if (isNaN(nonce) || nonce < 0) throw new RangeError('MESSAGE_NONCE_TYPE');
|
||||
}
|
||||
|
||||
if (content) {
|
||||
|
||||
Reference in New Issue
Block a user