Merge pull request #53 from noamboy2006/main

fix: minor grammar/typo fixes in comments
This commit is contained in:
Helloyunho 2020-12-05 18:37:34 +09:00 committed by GitHub
commit 4db6203650
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 69 additions and 69 deletions

View File

@ -8,7 +8,7 @@ import { Collection } from '../utils/collection.ts'
*/
export class BaseManager<T, T2> {
client: Client
/** Cache Name or Key used to differentiate caches */
/** Caches Name or Key used to differentiate caches */
cacheName: string
/** Which data type does this cache have */
DataType: any
@ -19,36 +19,36 @@ export class BaseManager<T, T2> {
this.DataType = DataType
}
/** Get raw value from a cache (payload) */
/** Gets raw value from a cache (payload) */
async _get(key: string): Promise<T | undefined> {
return this.client.cache.get(this.cacheName, key)
}
/** Get a value from Cache */
/** Gets a value from Cache */
async get(key: string): Promise<T2 | undefined> {
const raw = await this._get(key)
if (raw === undefined) return
return new this.DataType(this.client, raw)
}
/** Set a value to Cache */
/** Sets a value to Cache */
async set(key: string, value: T): Promise<any> {
return this.client.cache.set(this.cacheName, key, value)
}
/** Delete a key from Cache */
/** Deletes a key from Cache */
async delete(key: string): Promise<boolean> {
return this.client.cache.delete(this.cacheName, key)
}
/** Get an Array of values from Cache */
/** Gets an Array of values from Cache */
async array(): Promise<undefined | T2[]> {
let arr = await (this.client.cache.array(this.cacheName) as T[])
if (arr === undefined) arr = []
return arr.map((e) => new this.DataType(this.client, e)) as any
}
/** Get a Collection of values from Cache */
/** Gets a Collection of values from Cache */
async collection(): Promise<Collection<string, T2>> {
const arr = await this.array()
if (arr === undefined) return new Collection()
@ -60,7 +60,7 @@ export class BaseManager<T, T2> {
return collection
}
/** Delete everything from Cache */
/** Deletes everything from Cache */
flush(): any {
return this.client.cache.deleteCache(this.cacheName)
}

View File

@ -43,7 +43,7 @@ export class ChannelsManager extends BaseManager<ChannelPayload, Channel> {
return result
}
/** Fetch a Channel by ID, cache it, resolve it */
/** Fetches a Channel by ID, cache it, resolve it */
async fetch<T = Channel>(id: string): Promise<T> {
return await new Promise((resolve, reject) => {
this.client.rest

View File

@ -20,7 +20,7 @@ export class EmojisManager extends BaseManager<EmojiPayload, Emoji> {
return emoji
}
/** Fetch an Emoji by Guild ID and Emoji ID, cache it and resolve it */
/** Fetches an Emoji by Guild ID and Emoji ID, cache it and resolve it */
async fetch(guildID: string, id: string): Promise<Emoji> {
return await new Promise((resolve, reject) => {
this.client.rest

View File

@ -11,20 +11,20 @@ import {
* Methods can return Promises too.
*/
export interface ICacheAdapter {
/** Get a key from a Cache */
/** Gets a key from a Cache */
get: (cacheName: string, key: string) => Promise<any> | any
/** Set a key to value in a Cache Name with optional expire value in MS */
/** Sets a key to value in a Cache Name with optional expire value in MS */
set: (
cacheName: string,
key: string,
value: any,
expire?: number
) => Promise<any> | any
/** Delete a key from a Cache */
/** Deletes a key from a Cache */
delete: (cacheName: string, key: string) => Promise<boolean> | boolean
/** Get array of all values in a Cache */
/** Gets array of all values in a Cache */
array: (cacheName: string) => undefined | any[] | Promise<any[] | undefined>
/** Entirely delete a Cache */
/** Entirely deletes a Cache */
deleteCache: (cacheName: string) => any
}

View File

@ -104,9 +104,9 @@ export class Client extends EventEmitter {
}
/**
* Set Cache Adapter
* Sets Cache Adapter
*
* Should NOT set after bot is already logged in or using current cache.
* Should NOT be set after bot is already logged in or using current cache.
* Please look into using `cache` option.
*/
setAdapter(adapter: ICacheAdapter): Client {
@ -114,7 +114,7 @@ export class Client extends EventEmitter {
return this
}
/** Change Presence of Client */
/** Changes Presence of Client */
setPresence(presence: ClientPresence | ClientActivity | ActivityGame): void {
if (presence instanceof ClientPresence) {
this.presence = presence
@ -122,7 +122,7 @@ export class Client extends EventEmitter {
this.gateway?.sendPresence(this.presence.create())
}
/** Emit debug event */
/** Emits debug event */
debug(tag: string, msg: string): void {
this.emit('debug', `[${tag}] ${msg}`)
}
@ -131,7 +131,7 @@ export class Client extends EventEmitter {
// fetchApplication(): Promise<Application>
/**
* This function is used for connect to discord.
* This function is used for connecting to discord.
* @param token Your token. This is required.
* @param intents Gateway intents in array. This is required.
*/

View File

@ -102,7 +102,7 @@ export class CommandClient extends Client implements CommandClientOptions {
)
}
/** Process a Message to Execute Command. */
/** Processes a Message to Execute Command. */
async processMessage(msg: Message): Promise<any> {
if (!this.allowBots && msg.author.bot === true) return
@ -223,7 +223,7 @@ export class CommandClient extends Client implements CommandClientOptions {
}
// In these checks too, Command overrides Category if present
// Check if Command is only for Owners
// Checks if Command is only for Owners
if (
(command.ownerOnly !== undefined || category === undefined
? command.ownerOnly
@ -232,7 +232,7 @@ export class CommandClient extends Client implements CommandClientOptions {
)
return this.emit('commandOwnerOnly', ctx, command)
// Check if Command is only for Guild
// Checks if Command is only for Guild
if (
(command.guildOnly !== undefined || category === undefined
? command.guildOnly
@ -241,7 +241,7 @@ export class CommandClient extends Client implements CommandClientOptions {
)
return this.emit('commandGuildOnly', ctx, command)
// Check if Command is only for DMs
// Checks if Command is only for DMs
if (
(command.dmOnly !== undefined || category === undefined
? command.dmOnly

View File

@ -12,14 +12,14 @@ export class ExtensionCommands {
this.extension = ext
}
/** Get a list of Extension's Commands */
/** Gets a list of Extension's Commands */
get list(): Collection<string, Command> {
return this.extension.client.commands.list.filter(
(c) => c.extension?.name === this.extension.name
)
}
/** Get an Extension Command */
/** Gets an Extension Command */
get(cmd: string): Command | undefined {
const find = this.extension.client.commands.find(cmd)
// linter sucks
@ -29,14 +29,14 @@ export class ExtensionCommands {
else return find
}
/** Add an Extension Command */
/** Adds an Extension Command */
add(Cmd: Command | typeof Command): boolean {
const cmd = Cmd instanceof Command ? Cmd : new Cmd()
cmd.extension = this.extension
return this.extension.client.commands.add(cmd)
}
/** Delete an Extension Command */
/** Deletes an Extension Command */
delete(cmd: Command | string): boolean {
const find = this.extension.client.commands.find(
typeof cmd === 'string' ? cmd : cmd.name
@ -50,7 +50,7 @@ export class ExtensionCommands {
else return this.extension.client.commands.delete(find)
}
/** Delete all Commands of an Extension */
/** Deletes all Commands of an Extension */
deleteAll(): void {
for (const [cmd] of this.list) {
this.delete(cmd)
@ -74,7 +74,7 @@ export class Extension {
this.client = client
}
/** Listen for an Event through Extension. */
/** Listens for an Event through Extension. */
listen(event: string, cb: ExtensionEventCallback): boolean {
if (this.events[event] !== undefined) return false
else {
@ -103,17 +103,17 @@ export class ExtensionsManager {
this.client = client
}
/** Get an Extension by name */
/** Gets an Extension by name */
get(ext: string): Extension | undefined {
return this.list.get(ext)
}
/** Check whether an Extension exists or not */
/** Checks whether an Extension exists or not */
exists(ext: string): boolean {
return this.get(ext) !== undefined
}
/** Load an Extension onto Command Client */
/** Loads an Extension onto Command Client */
load(ext: Extension | typeof Extension): void {
// eslint-disable-next-line new-cap
if (!(ext instanceof Extension)) ext = new ext(this.client)
@ -123,7 +123,7 @@ export class ExtensionsManager {
ext.load()
}
/** Unload an Extension from Command Client */
/** Unloads an Extension from Command Client */
unload(ext: Extension | string): boolean {
const name = typeof ext === 'string' ? ext : ext.name
const extension = this.get(name)

View File

@ -320,7 +320,7 @@ export class RESTManager {
}
/**
* Make a Request to Discord API
* Makes a Request to Discord API
* @param method HTTP Method to use
* @param url URL of the Request
* @param body Body to send with Request
@ -422,7 +422,7 @@ export class RESTManager {
})
}
/** Make a GET Request to API */
/** Makes a GET Request to API */
async get(
url: string,
body?: unknown,
@ -433,7 +433,7 @@ export class RESTManager {
return await this.make('get', url, body, maxRetries, bucket, rawResponse)
}
/** Make a POST Request to API */
/** Makes a POST Request to API */
async post(
url: string,
body?: unknown,
@ -444,7 +444,7 @@ export class RESTManager {
return await this.make('post', url, body, maxRetries, bucket, rawResponse)
}
/** Make a DELETE Request to API */
/** Makes a DELETE Request to API */
async delete(
url: string,
body?: unknown,
@ -455,7 +455,7 @@ export class RESTManager {
return await this.make('delete', url, body, maxRetries, bucket, rawResponse)
}
/** Make a PATCH Request to API */
/** Makes a PATCH Request to API */
async patch(
url: string,
body?: unknown,
@ -466,7 +466,7 @@ export class RESTManager {
return await this.make('patch', url, body, maxRetries, bucket, rawResponse)
}
/** Make a PUT Request to API */
/** Makes a PUT Request to API */
async put(
url: string,
body?: unknown,

View File

@ -45,7 +45,7 @@ export class GuildBans {
}
/**
* Get all bans in the Guild.
* Gets all bans in the Guild.
*/
async all(): Promise<GuildBan[]> {
const res = await this.client.rest.get(GUILD_BANS(this.guild.id))
@ -59,7 +59,7 @@ export class GuildBans {
}
/**
* Get ban details of a User if any.
* Gets ban details of a User if any.
* @param user User to get ban of, ID or User object.
*/
async get(user: string | User): Promise<GuildBan> {
@ -71,7 +71,7 @@ export class GuildBans {
}
/**
* Ban a User.
* Bans a User.
* @param user User to ban, ID or User object.
* @param reason Reason for the Ban.
* @param deleteMessagesDays Delete Old Messages? If yes, how much days.
@ -95,7 +95,7 @@ export class GuildBans {
}
/**
* Unban (remove ban from) a User.
* Unbans (removes ban from) a User.
* @param user User to unban, ID or User object.
*/
async remove(user: string | User): Promise<boolean> {
@ -271,7 +271,7 @@ export class Guild extends Base {
}
/**
* Get Everyone role of the Guild
* Gets Everyone role of the Guild
*/
async getEveryoneRole(): Promise<Role> {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
@ -279,7 +279,7 @@ export class Guild extends Base {
}
/**
* Get current client's member in the Guild
* Gets current client's member in the Guild
*/
async me(): Promise<Member> {
const get = await this.members.get(this.client.user?.id as string)
@ -288,7 +288,7 @@ export class Guild extends Base {
}
/**
* Fetch Guild's Integrations (Webhooks, Bots, etc.)
* Fetches Guild's Integrations (Webhooks, Bots, etc.)
*/
async fetchIntegrations(): Promise<GuildIntegration[]> {
const raw = (await this.client.rest.get(
@ -298,7 +298,7 @@ export class Guild extends Base {
}
/**
* Chunk the Guild Members, i.e. cache them.
* Chunks the Guild Members, i.e. cache them.
* @param options Options regarding the Members Request
* @param wait Whether to wait for all Members to come before resolving Promise or not.
* @param timeout Configurable timeout to cancel the wait to safely remove listener.
@ -344,7 +344,7 @@ export class GuildIntegration extends Base {
expireGracePeriod?: number
user?: User
account: IntegrationAccountPayload
syncedAt?: string // Actually a ISO Timestamp, but we parse in constructor'
syncedAt?: string // Actually a ISO Timestamp, but we parse in constructor
subscriberCount?: number
revoked?: boolean
application?: Application

View File

@ -65,7 +65,7 @@ export class Member extends Base {
}
/**
* Update the Member data in cache (and this object).
* Updates the Member data in cache (and this object).
*/
async fetch(): Promise<Member> {
const raw = await this.client.rest.get(this.id)
@ -76,7 +76,7 @@ export class Member extends Base {
}
/**
* Edit the Member
* Edits the Member
* @param data Data to apply
*/
async edit(data: MemberData): Promise<Member> {
@ -113,14 +113,14 @@ export class Member extends Base {
}
/**
* Reset nickname of the Member
* Resets nickname of the Member
*/
async resetNickname(): Promise<Member> {
return await this.setNickname()
}
/**
* Set mute of a Member in VC
* Sets a Member mute in VC
* @param mute Value to set
*/
async setMute(mute?: boolean): Promise<Member> {
@ -130,7 +130,7 @@ export class Member extends Base {
}
/**
* Set deaf of a Member in VC
* Sets a Member deaf in VC
* @param deaf Value to set
*/
async setDeaf(deaf?: boolean): Promise<Member> {
@ -140,14 +140,14 @@ export class Member extends Base {
}
/**
* Unmute the Member from VC.
* Unmutes the Member from VC.
*/
async unmute(): Promise<Member> {
return await this.setMute(false)
}
/**
* Kick the member.
* Kicks the member.
*/
async kick(): Promise<boolean> {
const resp = await this.client.rest.delete(
@ -162,7 +162,7 @@ export class Member extends Base {
}
/**
* Ban the Member.
* Bans the Member.
* @param reason Reason for the Ban.
* @param deleteMessagesDays Delete Old Messages? If yes, how much days.
*/

View File

@ -94,7 +94,7 @@ export class Message extends Base {
this.flags = data.flags ?? this.flags
}
/** Edit this message. */
/** Edits this message. */
async edit(text?: string, option?: MessageOption): Promise<Message> {
if (
this.client.user !== undefined &&
@ -104,7 +104,7 @@ export class Message extends Base {
return this.channel.editMessage(this.id, text, option)
}
/** Create a Reply to this Message. */
/** Creates a Reply to this Message. */
async reply(
text?: string | AllMessageOptions,
option?: AllMessageOptions
@ -112,7 +112,7 @@ export class Message extends Base {
return this.channel.send(text, option, this)
}
/** Delete the Message. */
/** Deletes the Message. */
async delete(): Promise<void> {
return this.client.rest.delete(CHANNEL_MESSAGE(this.channelID, this.id))
}

View File

@ -89,7 +89,7 @@ export class Webhook {
return this
}
/** Send a Message through Webhook. */
/** Sends a Message through Webhook. */
async send(
text?: string | AllWebhookMessageOptions,
option?: AllWebhookMessageOptions
@ -149,7 +149,7 @@ export class Webhook {
}
/**
* Create a Webhook object from URL
* Creates a Webhook object from URL
* @param url URL of the Webhook
* @param client Client (bot) object, if any.
*/
@ -165,7 +165,7 @@ export class Webhook {
}
/**
* Edit the Webhook name, avatar, or channel (requires authentication).
* Edits the Webhook name, avatar, or channel (requires authentication).
* @param options Options to edit the Webhook.
*/
async edit(options: WebhookEditOptions): Promise<Webhook> {
@ -185,7 +185,7 @@ export class Webhook {
return this
}
/** Delete the Webhook. */
/** Deletes the Webhook. */
async delete(): Promise<boolean> {
const resp = await this.rest.delete(this.url, undefined, 0, undefined, true)
if (resp.response.status !== 204) return false

View File

@ -16,7 +16,7 @@ import { UserPayload } from './user.ts'
/**
* Gateway OPcodes from Discord docs.
*/
export enum GatewayOpcodes { // 문서를 확인해본 결과 Opcode 5번은 비어있다. - UnderC -
export enum GatewayOpcodes { // Opcode 5 is empty according to discord api docs.
DISPATCH = 0,
HEARTBEAT = 1,
IDENTIFY = 2,

View File

@ -136,7 +136,7 @@ export interface GuildIntegrationPayload {
expire_grace_period?: number
user?: UserPayload
account: IntegrationAccountPayload
synced_at?: string // Actually a ISO Timestamp, but we parse in constructor'
synced_at?: string // Actually a ISO Timestamp, but we parse in constructor
subscriber_count?: number
revoked?: boolean
application?: ApplicationPayload

View File

@ -1,7 +1,7 @@
// https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice
import { MemberPayload } from './guild.ts'
export enum VoiceOpcodes { // VoiceOpcodes 추가 - UnderC -
export enum VoiceOpcodes { // add VoiceOpcodes - UnderC -
IDENTIFY = 0,
SELECT_PROTOCOL = 1,
READY = 2,

View File

@ -54,7 +54,7 @@ export class Collection<K = string, V = any> extends Map<K, V> {
return results
}
/** Check if any of the values/keys in Collection satisfy callback */
/** Check if any of the values/keys in Collection satisfies callback */
some(callback: (value: V, key: K) => boolean): boolean {
for (const key of this.keys()) {
const value = this.get(key) as V
@ -63,7 +63,7 @@ export class Collection<K = string, V = any> extends Map<K, V> {
return false
}
/** Check if every value/key in Collection satisfy callback */
/** Check if every value/key in Collection satisfies callback */
every(callback: (value: V, key: K) => boolean): boolean {
for (const key of this.keys()) {
const value = this.get(key) as V