mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
committed by
Schuyler Cebulskie
parent
f0adf8f122
commit
beffb390e6
@@ -123,6 +123,19 @@ class ClientDataResolver {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves a ChannelResolvable to a Channel object
|
||||
* @param {ChannelResolvable} channel The channel resolvable to resolve
|
||||
* @returns {?string}
|
||||
*/
|
||||
resolveChannelID(channel) {
|
||||
if (channel instanceof Channel) return channel.id;
|
||||
if (typeof channel === 'string') return channel;
|
||||
if (channel instanceof Message) return channel.channel.id;
|
||||
if (channel instanceof Guild) return channel.defaultChannel.id;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Data that can be resolved to give an invite code. This can be:
|
||||
* * An invite code
|
||||
|
||||
@@ -117,6 +117,18 @@ class RESTMethods {
|
||||
);
|
||||
}
|
||||
|
||||
search(type, id, options) {
|
||||
const queryString = Object.keys(options)
|
||||
.filter(k => options[k])
|
||||
.map(k => [k, options[k]])
|
||||
.map(x => x.join('='))
|
||||
.join('&');
|
||||
const url = `${Constants.Endpoints[`${type}Search`](id)}?${queryString}`;
|
||||
return this.rest.makeRequest('get', url, true).then(body =>
|
||||
body.messages.map(x => x.map(m => new Message(this.client.channels.get(m.channel_id), m, this.client)))
|
||||
);
|
||||
}
|
||||
|
||||
createChannel(guild, channelName, channelType, overwrites) {
|
||||
if (overwrites instanceof Collection) overwrites = overwrites.array();
|
||||
return this.rest.makeRequest('post', Constants.Endpoints.guildChannels(guild.id), true, {
|
||||
|
||||
Reference in New Issue
Block a user