Skip to content

Commit 189c01f

Browse files
committed
fix: change Awaited to Awaitable
This matches the change made in sapphiredev/utilities#193 BREAKING CHANGE: `Awaited` type has been renamed to `Awaitable`
1 parent 6d332aa commit 189c01f

File tree

12 files changed

+183
-295
lines changed

12 files changed

+183
-295
lines changed

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
"prepare": "husky install .github/husky"
2929
},
3030
"dependencies": {
31-
"@sapphire/discord-utilities": "^2.1.5",
31+
"@sapphire/discord-utilities": "next",
3232
"@sapphire/discord.js-utilities": "next",
3333
"@sapphire/pieces": "^3.0.0",
34-
"@sapphire/ratelimits": "^2.0.1",
35-
"@sapphire/utilities": "^2.0.1",
34+
"@sapphire/ratelimits": "next",
35+
"@sapphire/utilities": "next",
3636
"lexure": "^0.17.0",
3737
"tslib": "^2.3.1"
3838
},
@@ -45,15 +45,15 @@
4545
"@sapphire/prettier-config": "^1.1.6",
4646
"@sapphire/ts-config": "^3.0.0",
4747
"@types/jest": "^27.0.2",
48-
"@types/node": "^16.9.1",
48+
"@types/node": "^16.10.2",
4949
"@types/ws": "^8.2.0",
5050
"cz-conventional-changelog": "^3.3.0",
5151
"discord.js": "^13.1.0",
5252
"gen-esm-wrapper": "^1.1.3",
5353
"husky": "^7.0.2",
5454
"jest": "^27.2.4",
5555
"jest-circus": "^27.2.4",
56-
"lint-staged": "^11.1.2",
56+
"lint-staged": "^11.2.0",
5757
"pretty-quick": "^3.1.1",
5858
"rollup": "^2.58.0",
5959
"rollup-plugin-version-injector": "^1.3.3",

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export {
1313
StoreRegistry,
1414
StoreRegistryEntries
1515
} from '@sapphire/pieces';
16-
export type { Awaited } from '@sapphire/utilities';
16+
export type { Awaitable } from '@sapphire/utilities';
1717
export * from './lib/errors/ArgumentError';
1818
export * from './lib/errors/Identifiers';
1919
export * from './lib/errors/PreconditionError';

src/lib/SapphireClient.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { container, Store, StoreRegistry } from '@sapphire/pieces';
2-
import type { Awaited } from '@sapphire/utilities';
2+
import type { Awaitable } from '@sapphire/utilities';
33
import { Client, ClientOptions, Message, Snowflake } from 'discord.js';
44
import { join } from 'path';
55
import type { Plugin } from './plugins/Plugin';
@@ -22,7 +22,7 @@ import { Logger } from './utils/logger/Logger';
2222
export type SapphirePrefix = string | readonly string[] | null;
2323

2424
export interface SapphirePrefixHook {
25-
(message: Message): Awaited<SapphirePrefix>;
25+
(message: Message): Awaitable<SapphirePrefix>;
2626
}
2727

2828
export interface SapphireClientOptions {

src/lib/parsers/Result.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { Awaitable, isFunction } from '@sapphire/utilities';
12
import type * as Lexure from 'lexure';
2-
import { isFunction, Awaited } from '@sapphire/utilities';
33

44
/**
55
* A type used to express computations that can fail.
@@ -88,7 +88,7 @@ export function from<T, E = Error>(cb: (...args: unknown[]) => T): Result<T, E>
8888
* @typeparam T The result's type.
8989
* @typeparam E The error's type.
9090
*/
91-
export async function fromAsync<T, E = Error>(promiseOrCb: Awaited<T> | ((...args: unknown[]) => Awaited<T>)): Promise<Result<T, E>> {
91+
export async function fromAsync<T, E = Error>(promiseOrCb: Awaitable<T> | ((...args: unknown[]) => Awaitable<T>)): Promise<Result<T, E>> {
9292
try {
9393
return ok(await (isFunction(promiseOrCb) ? promiseOrCb() : promiseOrCb));
9494
} catch (error) {

src/lib/plugins/Plugin.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Awaited } from '@sapphire/utilities';
1+
import type { Awaitable } from '@sapphire/utilities';
22
import type { ClientOptions } from 'discord.js';
33
import type { SapphireClient } from '../SapphireClient';
44
import { postInitialization, postLogin, preGenericsInitialization, preInitialization, preLogin } from './symbols';
@@ -8,6 +8,6 @@ export abstract class Plugin {
88
public static [preGenericsInitialization]?: (this: SapphireClient, options: ClientOptions) => void;
99
public static [preInitialization]?: (this: SapphireClient, options: ClientOptions) => void;
1010
public static [postInitialization]?: (this: SapphireClient, options: ClientOptions) => void;
11-
public static [preLogin]?: (this: SapphireClient, options: ClientOptions) => Awaited<void>;
12-
public static [postLogin]?: (this: SapphireClient, options: ClientOptions) => Awaited<void>;
11+
public static [preLogin]?: (this: SapphireClient, options: ClientOptions) => Awaitable<void>;
12+
public static [postLogin]?: (this: SapphireClient, options: ClientOptions) => Awaitable<void>;
1313
}

src/lib/plugins/PluginManager.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Awaited } from '@sapphire/utilities';
1+
import type { Awaitable } from '@sapphire/utilities';
22
import type { ClientOptions } from 'discord.js';
33
import type { SapphireClient } from '../SapphireClient';
44
import { PluginHook } from '../types/Enums';
@@ -7,7 +7,7 @@ import { postInitialization, postLogin, preGenericsInitialization, preInitializa
77

88
export type AsyncPluginHooks = PluginHook.PreLogin | PluginHook.PostLogin;
99
export interface SapphirePluginAsyncHook {
10-
(this: SapphireClient, options: ClientOptions): Awaited<unknown>;
10+
(this: SapphireClient, options: ClientOptions): Awaitable<unknown>;
1111
}
1212

1313
export type SyncPluginHooks = Exclude<PluginHook, AsyncPluginHooks>;

src/lib/resolvers/message.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { MessageLinkRegex, SnowflakeRegex } from '@sapphire/discord-utilities';
22
import { GuildBasedChannelTypes, isNewsChannel, isTextChannel, TextBasedChannelTypes } from '@sapphire/discord.js-utilities';
33
import { container } from '@sapphire/pieces';
4-
import type { Awaited } from '@sapphire/utilities';
4+
import type { Awaitable } from '@sapphire/utilities';
55
import { Message, Permissions, Snowflake } from 'discord.js';
66
import { Identifiers } from '../errors/Identifiers';
77
import { err, ok, Result } from '../parsers/Result';
@@ -18,7 +18,7 @@ export async function resolveMessage(parameter: string, options: MessageResolver
1818
return err(Identifiers.ArgumentMessageError);
1919
}
2020

21-
function resolveById(parameter: string, channel: TextBasedChannelTypes): Awaited<Message | null> {
21+
function resolveById(parameter: string, channel: TextBasedChannelTypes): Awaitable<Message | null> {
2222
return SnowflakeRegex.test(parameter) ? channel.messages.fetch(parameter as Snowflake) : null;
2323
}
2424

src/lib/structures/Argument.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AliasPiece, AliasPieceOptions } from '@sapphire/pieces';
2-
import type { Awaited } from '@sapphire/utilities';
2+
import type { Awaitable } from '@sapphire/utilities';
33
import type { Message } from 'discord.js';
44
import type { ArgumentError } from '../errors/ArgumentError';
55
import type { UserError } from '../errors/UserError';
@@ -10,7 +10,7 @@ import type { Command, CommandContext } from './Command';
1010
/**
1111
* Defines a synchronous result of an {@link Argument}, check {@link AsyncArgumentResult} for the asynchronous version.
1212
*/
13-
export type ArgumentResult<T> = Awaited<Result<T, UserError>>;
13+
export type ArgumentResult<T> = Awaitable<Result<T, UserError>>;
1414

1515
/**
1616
* Defines an asynchronous result of an {@link Argument}, check {@link ArgumentResult} for the synchronous version.

src/lib/structures/Command.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AliasPiece, AliasPieceJSON, AliasPieceOptions, PieceContext } from '@sapphire/pieces';
2-
import { Awaited, isNullish } from '@sapphire/utilities';
2+
import { Awaitable, isNullish } from '@sapphire/utilities';
33
import { Message, PermissionResolvable, Permissions, Snowflake } from 'discord.js';
44
import * as Lexure from 'lexure';
55
import { Args } from '../parsers/Args';
@@ -95,7 +95,7 @@ export abstract class Command<T = Args> extends AliasPiece {
9595
* @param parameters The raw parameters as a single string.
9696
* @param context The command-context used in this execution.
9797
*/
98-
public preParse(message: Message, parameters: string, context: CommandContext): Awaited<T> {
98+
public preParse(message: Message, parameters: string, context: CommandContext): Awaitable<T> {
9999
const parser = new Lexure.Parser(this.lexer.setInput(parameters).lex()).setUnorderedStrategy(this.strategy);
100100
const args = new Lexure.Args(parser.parse());
101101
return new Args(message, this as any, args, context) as any;
@@ -142,7 +142,7 @@ export abstract class Command<T = Args> extends AliasPiece {
142142
* @param message The message that triggered the command.
143143
* @param args The value returned by {@link Command.preParse}, by default an instance of {@link Args}.
144144
*/
145-
public abstract run(message: Message, args: T, context: CommandContext): Awaited<unknown>;
145+
public abstract run(message: Message, args: T, context: CommandContext): Awaitable<unknown>;
146146

147147
/**
148148
* Defines the JSON.stringify behavior of the command.

src/lib/structures/Precondition.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { Piece, PieceContext, PieceOptions } from '@sapphire/pieces';
2-
import type { Awaited } from '@sapphire/utilities';
2+
import type { Awaitable } from '@sapphire/utilities';
33
import type { Message, Permissions } from 'discord.js';
44
import type { CooldownContext } from '../../preconditions/Cooldown';
55
import { PreconditionError } from '../errors/PreconditionError';
66
import type { UserError } from '../errors/UserError';
77
import { err, ok, Result } from '../parsers/Result';
88
import type { Command } from './Command';
99

10-
export type PreconditionResult = Awaited<Result<unknown, UserError>>;
10+
export type PreconditionResult = Awaitable<Result<unknown, UserError>>;
1111
export type AsyncPreconditionResult = Promise<Result<unknown, UserError>>;
1212

1313
export abstract class Precondition extends Piece {

src/lib/utils/preconditions/IPreconditionContainer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Awaited } from '@sapphire/utilities';
1+
import type { Awaitable } from '@sapphire/utilities';
22
import type { Message } from 'discord.js';
33
import type { UserError } from '../../errors/UserError';
44
import type { Result } from '../../parsers/Result';
@@ -15,7 +15,7 @@ export type PreconditionContainerResult = Result<unknown, UserError>;
1515
* Defines the return type of the generic {@link IPreconditionContainer.run}.
1616
* @since 1.0.0
1717
*/
18-
export type PreconditionContainerReturn = Awaited<PreconditionContainerResult>;
18+
export type PreconditionContainerReturn = Awaitable<PreconditionContainerResult>;
1919

2020
/**
2121
* Async-only version of {@link PreconditionContainerReturn}, to be used when the run method is async.

0 commit comments

Comments
 (0)