types(structures): add return type for methods (#341)

This commit is contained in:
Ayyan
2021-01-03 19:12:13 +04:00
committed by GitHub
parent 22011b4227
commit 55f68a242d
5 changed files with 47 additions and 29 deletions
+1 -1
View File
@@ -116,5 +116,5 @@ export interface Channel {
// METHODS // METHODS
/** Send a message to the channel. Requires SEND_MESSAGES permission. */ /** Send a message to the channel. Requires SEND_MESSAGES permission. */
send(content: string | MessageContent): Promise<Message>; send(content: string | MessageContent): ReturnType<typeof sendMessage>;
} }
+9 -10
View File
@@ -1,6 +1,5 @@
import { botID } from "../../bot.ts"; import { botID } from "../../bot.ts";
import { import {
BannedUser,
BanOptions, BanOptions,
ChannelCreatePayload, ChannelCreatePayload,
CreateGuildPayload, CreateGuildPayload,
@@ -329,23 +328,23 @@ export interface Guild {
/** The full URL of the icon from Discords CDN. Undefined when no icon is set. */ /** The full URL of the icon from Discords CDN. Undefined when no icon is set. */
iconURL(size?: ImageSize, format?: ImageFormats): string | undefined; 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 a guild permanently. User must be owner. Returns 204 No Content on success. Fires a Guild Delete Gateway event. */
delete(): Promise<any>; delete(): ReturnType<typeof deleteServer>;
/** Leave a guild */ /** Leave a guild */
leave(): Promise<any>; leave(): ReturnType<typeof leaveGuild>;
/** Edit the server. Requires the MANAGE_GUILD permission. */ /** Edit the server. Requires the MANAGE_GUILD permission. */
edit(options: GuildEditOptions): Promise<any>; edit(options: GuildEditOptions): ReturnType<typeof editGuild>;
/** Returns the audit logs for the guild. Requires VIEW AUDIT LOGS permission */ /** Returns the audit logs for the guild. Requires VIEW AUDIT LOGS permission */
auditLogs(options: GetAuditLogsOptions): Promise<any>; auditLogs(options: GetAuditLogsOptions): ReturnType<typeof getAuditLogs>;
/** Returns a ban object for the given user or a 404 not found if the ban cannot be found. Requires the BAN_MEMBERS permission. */ /** 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<BannedUser>; getBan(memberID: string): ReturnType<typeof getBan>;
/** Returns a list of ban objects for the users banned from this guild. Requires the BAN_MEMBERS permission. */ /** Returns a list of ban objects for the users banned from this guild. Requires the BAN_MEMBERS permission. */
bans(): Promise<Collection<string, BannedUser>>; bans(): ReturnType<typeof getBans>;
/** Ban a user from the guild and optionally delete previous messages sent by the user. Requires the BAN_MEMBERS permission. */ /** 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<any>; ban(memberID: string, options: BanOptions): ReturnType<typeof ban>;
/** Remove the ban for a user. Requires BAN_MEMBERS permission */ /** Remove the ban for a user. Requires BAN_MEMBERS permission */
unban(memberID: string): Promise<any>; unban(memberID: string): ReturnType<typeof unban>;
/** Get all the invites for this guild. Requires MANAGE_GUILD permission */ /** Get all the invites for this guild. Requires MANAGE_GUILD permission */
invites(): Promise<any>; invites(): ReturnType<typeof getInvites>;
} }
interface CleanVoiceState extends VoiceState { interface CleanVoiceState extends VoiceState {
+19 -6
View File
@@ -174,15 +174,28 @@ export interface Member {
/** Get the nickname */ /** Get the nickname */
guildMember(guildID: string): GuildMember | undefined; guildMember(guildID: string): GuildMember | undefined;
/** Send a direct message to the user is possible */ /** Send a direct message to the user is possible */
sendDM(content: string | MessageContent): Promise<any>; sendDM(
content: string | MessageContent,
): ReturnType<typeof sendDirectMessage>;
/** Kick the member from a guild */ /** Kick the member from a guild */
kick(guildID: string, reason?: string): Promise<any>; kick(guildID: string, reason?: string): ReturnType<typeof kick>;
/** Edit the member in a guild */ /** Edit the member in a guild */
edit(guildID: string, options: EditMemberOptions): Promise<any>; edit(
guildID: string,
options: EditMemberOptions,
): ReturnType<typeof editMember>;
/** Ban a member in a guild */ /** Ban a member in a guild */
ban(guildID: string, options: BanOptions): Promise<any>; ban(guildID: string, options: BanOptions): ReturnType<typeof ban>;
/** Add a role to the member */ /** Add a role to the member */
addRole(guildID: string, roleID: string, reason?: string): Promise<any>; addRole(
guildID: string,
roleID: string,
reason?: string,
): ReturnType<typeof addRole>;
/** Remove a role from the member */ /** Remove a role from the member */
removeRole(guildID: string, roleID: string, reason?: string): Promise<any>; removeRole(
guildID: string,
roleID: string,
reason?: string,
): ReturnType<typeof removeRole>;
} }
+16 -10
View File
@@ -231,19 +231,25 @@ export interface Message {
// METHODS // METHODS
/** Delete the message */ /** Delete the message */
delete(reason?: string, delayMilliseconds?: number): Promise<unknown>; delete(
reason?: string,
delayMilliseconds?: number,
): ReturnType<typeof deleteMessageByID>;
/** Edit the message */ /** Edit the message */
edit(content: string | MessageContent): Promise<Message>; edit(content: string | MessageContent): ReturnType<typeof editMessage>;
/** Pins the message in the channel */ /** Pins the message in the channel */
pin(): Promise<void>; pin(): ReturnType<typeof pin>;
/** Add a reaction to the message */ /** Add a reaction to the message */
addReaction(reaction: string): Promise<unknown>; addReaction(reaction: string): ReturnType<typeof addReaction>;
/** Add multiple reactions to the message without or without order. */ /** Add multiple reactions to the message without or without order. */
addReactions(reactions: string[], ordered?: boolean): Promise<void>; addReactions(
reactions: string[],
ordered?: boolean,
): ReturnType<typeof addReactions>;
/** Send a inline reply to this message */ /** Send a inline reply to this message */
reply(content: string | MessageContent): Promise<Message>; reply(content: string | MessageContent): ReturnType<typeof sendMessage>;
/** Send a message to this channel where this message is */ /** Send a message to this channel where this message is */
send(content: string | MessageContent): Promise<Message>; send(content: string | MessageContent): ReturnType<typeof sendMessage>;
/** 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. */ /** 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( alert(
content: string | MessageContent, content: string | MessageContent,
@@ -257,9 +263,9 @@ export interface Message {
reason?: string, reason?: string,
): Promise<unknown>; ): Promise<unknown>;
/** Remove all reactions */ /** Remove all reactions */
removeAllReactions(): Promise<unknown>; removeAllReactions(): ReturnType<typeof removeAllReactions>;
/** Remove all reactions */ /** Remove all reactions */
removeReactionEmoji(reaction: string): Promise<any>; removeReactionEmoji(reaction: string): ReturnType<typeof removeReactionEmoji>;
/** Remove all reactions */ /** Remove all reactions */
removeReaction(reaction: string): Promise<any>; removeReaction(reaction: string): ReturnType<typeof removeReaction>;
} }
+2 -2
View File
@@ -122,9 +122,9 @@ export interface Role {
// METHODS // METHODS
/** Delete the role */ /** Delete the role */
delete(guildID?: string): Promise<unknown>; delete(guildID?: string): ReturnType<typeof deleteRole>;
/** Edits the role */ /** Edits the role */
edit(options: CreateRoleOptions): Promise<unknown>; edit(options: CreateRoleOptions): ReturnType<typeof editRole>;
/** Checks if this role is higher than another role. */ /** Checks if this role is higher than another role. */
higherThanRoleID(roleID: string, position?: number): boolean; higherThanRoleID(roleID: string, position?: number): boolean;
} }