mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 04:23:31 +01:00
feat(MessageStore): add remove() (#2468)
* MessageStore#remove() * typings
This commit is contained in:
@@ -82,6 +82,16 @@ class MessageStore extends DataStore {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a message, even if it's not cached.
|
||||||
|
* @param {MessageResolvable} message The message to delete
|
||||||
|
* @param {string} [reason] Reason for deleting this message, if it does not belong to the client user
|
||||||
|
*/
|
||||||
|
async remove(message, reason) {
|
||||||
|
message = this.resolveID(message);
|
||||||
|
if (message) await this.client.api.channels(this.channel.id).messages(message).delete({ reason });
|
||||||
|
}
|
||||||
|
|
||||||
async _fetchId(messageID, cache) {
|
async _fetchId(messageID, cache) {
|
||||||
const existing = this.get(messageID);
|
const existing = this.get(messageID);
|
||||||
if (existing && !existing.partial) return existing;
|
if (existing && !existing.partial) return existing;
|
||||||
|
|||||||
@@ -454,13 +454,11 @@ class Message extends Base {
|
|||||||
*/
|
*/
|
||||||
delete({ timeout = 0, reason } = {}) {
|
delete({ timeout = 0, reason } = {}) {
|
||||||
if (timeout <= 0) {
|
if (timeout <= 0) {
|
||||||
return this.client.api.channels(this.channel.id).messages(this.id)
|
return this.channel.messages.remove(this.id, reason).then(() =>
|
||||||
.delete({ reason })
|
this.client.actions.MessageDelete.handle({
|
||||||
.then(() =>
|
id: this.id,
|
||||||
this.client.actions.MessageDelete.handle({
|
channel_id: this.channel.id,
|
||||||
id: this.id,
|
}).message);
|
||||||
channel_id: this.channel.id,
|
|
||||||
}).message);
|
|
||||||
} else {
|
} else {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
this.client.setTimeout(() => {
|
this.client.setTimeout(() => {
|
||||||
|
|||||||
1
typings/index.d.ts
vendored
1
typings/index.d.ts
vendored
@@ -1448,6 +1448,7 @@ declare module 'discord.js' {
|
|||||||
public fetch(message: Snowflake, cache?: boolean): Promise<Message>;
|
public fetch(message: Snowflake, cache?: boolean): Promise<Message>;
|
||||||
public fetch(options?: ChannelLogsQueryOptions, cache?: boolean): Promise<Collection<Snowflake, Message>>;
|
public fetch(options?: ChannelLogsQueryOptions, cache?: boolean): Promise<Collection<Snowflake, Message>>;
|
||||||
public fetchPinned(cache?: boolean): Promise<Collection<Snowflake, Message>>;
|
public fetchPinned(cache?: boolean): Promise<Collection<Snowflake, Message>>;
|
||||||
|
public remove(message: MessageResolvable, reason?: string): Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PresenceStore extends DataStore<Snowflake, Presence, typeof Presence, PresenceResolvable> {
|
export class PresenceStore extends DataStore<Snowflake, Presence, typeof Presence, PresenceResolvable> {
|
||||||
|
|||||||
Reference in New Issue
Block a user