Skip to content

Commit

Permalink
feat!: move session end codes to single SessionEndCodes enum
Browse files Browse the repository at this point in the history
  • Loading branch information
Amgelo563 committed Jul 8, 2024
1 parent 34e73d7 commit 3266822
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
* SOFTWARE.
*/

import type { SessionEndCode } from './SessionEndCode';

/** End code for expired sessions. */
export const SessionExpiredCode: SessionEndCode = Symbol('Expired');
/** Global end codes provided by nyx. */
export const SessionEndCodes = {
/** End code for expired sessions. */
Expired: Symbol('Expired'),
/** Conventional end code for sessions that ended by themselves. */
SelfEnded: Symbol('SelfEnded'),
} as const;
28 changes: 0 additions & 28 deletions packages/core/src/features/session/end/SessionSelfEndCode.ts

This file was deleted.

3 changes: 1 addition & 2 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,9 @@ export * from './features/schedule/schedule/Schedule';
export * from './features/session/SessionManager';
export * from './features/session/customId/PaginationCustomIdBuilder';
export * from './features/session/customId/SessionCustomIdCodec';
export * from './features/session/end/SessionEndCodes';
export * from './features/session/end/SessionEndCode';
export * from './features/session/end/SessionEndData';
export * from './features/session/end/SessionExpiredCode';
export * from './features/session/end/SessionSelfEndCode';
export * from './features/session/error/SessionErrorHandler';
export * from './features/session/errors/AbstractSessionError';
export * from './features/session/errors/SessionStartError';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ import type {
import {
AssertionError,
ObjectNotFoundError,
SessionEndCodes,
SessionEventEnum,
SessionExecutionMeta,
SessionExpiredCode,
SessionStateEnum,
} from '@nyx-discord/core';
import type { ClientEvents, Events } from 'discord.js';
Expand Down Expand Up @@ -321,8 +321,8 @@ export class DefaultSessionManager implements SessionManager {
const metadata = SessionExecutionMeta.fromSession(session);
const data = await this.executor.end(
session,
String(SessionExpiredCode),
SessionExpiredCode,
String(SessionEndCodes.Expired),
SessionEndCodes.Expired,
metadata,
);
session.setState(SessionStateEnum.Ended);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import type {
} from '@nyx-discord/core';
import {
AssertionError,
SessionSelfEndCode,
SessionEndCodes,
SessionStateEnum,
} from '@nyx-discord/core';
import type {
Expand Down Expand Up @@ -208,6 +208,6 @@ export abstract class AbstractSession<Result = void>

/** Utility to self end this session. */
protected async selfEnd(reason: string): Promise<void> {
await this.bot.sessions.end(this, reason, SessionSelfEndCode);
await this.bot.sessions.end(this, reason, SessionEndCodes.SelfEnded);
}
}

0 comments on commit 3266822

Please sign in to comment.