From 55f68a242d00daf116c3e6e36941dab2155c9a12 Mon Sep 17 00:00:00 2001 From: Ayyan Date: Sun, 3 Jan 2021 19:12:13 +0400 Subject: [PATCH] types(structures): add return type for methods (#341) --- src/api/structures/channel.ts | 2 +- src/api/structures/guild.ts | 19 +++++++++---------- src/api/structures/member.ts | 25 +++++++++++++++++++------ src/api/structures/message.ts | 26 ++++++++++++++++---------- src/api/structures/role.ts | 4 ++-- 5 files changed, 47 insertions(+), 29 deletions(-) diff --git a/src/api/structures/channel.ts b/src/api/structures/channel.ts index 2b795494d..af94b6fc0 100644 --- a/src/api/structures/channel.ts +++ b/src/api/structures/channel.ts @@ -116,5 +116,5 @@ export interface Channel { // METHODS /** Send a message to the channel. Requires SEND_MESSAGES permission. */ - send(content: string | MessageContent): Promise; + send(content: string | MessageContent): ReturnType; } diff --git a/src/api/structures/guild.ts b/src/api/structures/guild.ts index 7984f210b..65f5dddca 100644 --- a/src/api/structures/guild.ts +++ b/src/api/structures/guild.ts @@ -1,6 +1,5 @@ import { botID } from "../../bot.ts"; import { - BannedUser, BanOptions, ChannelCreatePayload, CreateGuildPayload, @@ -329,23 +328,23 @@ export interface Guild { /** The full URL of the icon from Discords CDN. Undefined when no icon is set. */ iconURL(size?: ImageSize, format?: ImageFormats): string | undefined; /** Delete a guild permanently. User must be owner. Returns 204 No Content on success. Fires a Guild Delete Gateway event. */ - delete(): Promise; + delete(): ReturnType; /** Leave a guild */ - leave(): Promise; + leave(): ReturnType; /** Edit the server. Requires the MANAGE_GUILD permission. */ - edit(options: GuildEditOptions): Promise; + edit(options: GuildEditOptions): ReturnType; /** Returns the audit logs for the guild. Requires VIEW AUDIT LOGS permission */ - auditLogs(options: GetAuditLogsOptions): Promise; + auditLogs(options: GetAuditLogsOptions): ReturnType; /** Returns a ban object for the given user or a 404 not found if the ban cannot be found. Requires the BAN_MEMBERS permission. */ - getBan(memberID: string): Promise; + getBan(memberID: string): ReturnType; /** Returns a list of ban objects for the users banned from this guild. Requires the BAN_MEMBERS permission. */ - bans(): Promise>; + bans(): ReturnType; /** Ban a user from the guild and optionally delete previous messages sent by the user. Requires the BAN_MEMBERS permission. */ - ban(memberID: string, options: BanOptions): Promise; + ban(memberID: string, options: BanOptions): ReturnType; /** Remove the ban for a user. Requires BAN_MEMBERS permission */ - unban(memberID: string): Promise; + unban(memberID: string): ReturnType; /** Get all the invites for this guild. Requires MANAGE_GUILD permission */ - invites(): Promise; + invites(): ReturnType; } interface CleanVoiceState extends VoiceState { diff --git a/src/api/structures/member.ts b/src/api/structures/member.ts index 26824d686..14bc5b743 100644 --- a/src/api/structures/member.ts +++ b/src/api/structures/member.ts @@ -174,15 +174,28 @@ export interface Member { /** Get the nickname */ guildMember(guildID: string): GuildMember | undefined; /** Send a direct message to the user is possible */ - sendDM(content: string | MessageContent): Promise; + sendDM( + content: string | MessageContent, + ): ReturnType; /** Kick the member from a guild */ - kick(guildID: string, reason?: string): Promise; + kick(guildID: string, reason?: string): ReturnType; /** Edit the member in a guild */ - edit(guildID: string, options: EditMemberOptions): Promise; + edit( + guildID: string, + options: EditMemberOptions, + ): ReturnType; /** Ban a member in a guild */ - ban(guildID: string, options: BanOptions): Promise; + ban(guildID: string, options: BanOptions): ReturnType; /** Add a role to the member */ - addRole(guildID: string, roleID: string, reason?: string): Promise; + addRole( + guildID: string, + roleID: string, + reason?: string, + ): ReturnType; /** Remove a role from the member */ - removeRole(guildID: string, roleID: string, reason?: string): Promise; + removeRole( + guildID: string, + roleID: string, + reason?: string, + ): ReturnType; } diff --git a/src/api/structures/message.ts b/src/api/structures/message.ts index 393ed4fdd..fae678b4b 100644 --- a/src/api/structures/message.ts +++ b/src/api/structures/message.ts @@ -231,19 +231,25 @@ export interface Message { // METHODS /** Delete the message */ - delete(reason?: string, delayMilliseconds?: number): Promise; + delete( + reason?: string, + delayMilliseconds?: number, + ): ReturnType; /** Edit the message */ - edit(content: string | MessageContent): Promise; + edit(content: string | MessageContent): ReturnType; /** Pins the message in the channel */ - pin(): Promise; + pin(): ReturnType; /** Add a reaction to the message */ - addReaction(reaction: string): Promise; + addReaction(reaction: string): ReturnType; /** Add multiple reactions to the message without or without order. */ - addReactions(reactions: string[], ordered?: boolean): Promise; + addReactions( + reactions: string[], + ordered?: boolean, + ): ReturnType; /** Send a inline reply to this message */ - reply(content: string | MessageContent): Promise; + reply(content: string | MessageContent): ReturnType; /** Send a message to this channel where this message is */ - send(content: string | MessageContent): Promise; + send(content: string | MessageContent): ReturnType; /** Send a message to this channel and then delete it after a bit. By default it will delete after 10 seconds with no reason provided. */ alert( content: string | MessageContent, @@ -257,9 +263,9 @@ export interface Message { reason?: string, ): Promise; /** Remove all reactions */ - removeAllReactions(): Promise; + removeAllReactions(): ReturnType; /** Remove all reactions */ - removeReactionEmoji(reaction: string): Promise; + removeReactionEmoji(reaction: string): ReturnType; /** Remove all reactions */ - removeReaction(reaction: string): Promise; + removeReaction(reaction: string): ReturnType; } diff --git a/src/api/structures/role.ts b/src/api/structures/role.ts index 49bbb01bc..0c3611b5a 100644 --- a/src/api/structures/role.ts +++ b/src/api/structures/role.ts @@ -122,9 +122,9 @@ export interface Role { // METHODS /** Delete the role */ - delete(guildID?: string): Promise; + delete(guildID?: string): ReturnType; /** Edits the role */ - edit(options: CreateRoleOptions): Promise; + edit(options: CreateRoleOptions): ReturnType; /** Checks if this role is higher than another role. */ higherThanRoleID(roleID: string, position?: number): boolean; }