Skip to content

Commit

Permalink
use cli version for config checking
Browse files Browse the repository at this point in the history
  • Loading branch information
catplvsplus committed Oct 28, 2023
1 parent 5357b13 commit 1b9b97d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions packages/reciple/src/bin.mts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

import { ContextMenuCommandBuilder, Logger, MessageCommandBuilder, SlashCommandBuilder, buildVersion, version } from '@reciple/core';
import { ContextMenuCommandBuilder, Logger, MessageCommandBuilder, SlashCommandBuilder, buildVersion } from '@reciple/core';
import { createLogger, addEventListenersToClient } from './utils/logger.js';
import { setTimeout as setTimeoutAsync } from 'node:timers/promises';
import { checkLatestUpdate } from '@reciple/update-checker';
Expand Down Expand Up @@ -53,8 +53,8 @@ if (cli.shardmode) {
if (process.send) process.send(message);
}

if (config.version && !semver.satisfies(version, config.version)) {
logger?.error(`Your config version doesn't support Reciple client v${version}`);
if (config.version && !semver.satisfies(cliVersion, config.version)) {
logger?.error(`Your config version doesn't support Reciple CLI v${cliVersion}`);
process.exit(1);
}

Expand Down
7 changes: 4 additions & 3 deletions packages/reciple/src/classes/Config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Logger, RecipleClientConfig, RecipleError, version } from '@reciple/core';
import { Logger, RecipleClientConfig, RecipleError } from '@reciple/core';
import { recursiveDefaults, getDirModuleType } from '@reciple/utils';
import { mkdir, readFile, writeFile } from 'node:fs/promises';
import { kleur } from 'fallout-utility/strings';
import { cliVersion } from '../utils/cli';
import { Awaitable } from 'discord.js';
import { existsSync } from 'node:fs';
import path from 'node:path';
Expand Down Expand Up @@ -42,8 +43,8 @@ export class ConfigReader {
public static async getDefaultConfigData(useCommonJS?: boolean): Promise<string> {
let defaultConfig = await readFile(this.defaultConfigFile, 'utf-8');

defaultConfig = defaultConfig.replace(`import { version } from '@reciple/core';\n`, '');
defaultConfig = defaultConfig.replace('version: `^${version}`', 'version: `^'+ version +'`');
defaultConfig = defaultConfig.replace(`import { cliVersion } from 'reciple';\n`, '');
defaultConfig = defaultConfig.replace('version: `^${cliVersion}`', 'version: `^'+ cliVersion +'`');

if (useCommonJS) {
defaultConfig = defaultConfig.replace(`import { CooldownPrecondition, CommandPermissionsPrecondition } from 'reciple';`, `const { CooldownPrecondition, CommandPermissionsPrecondition } = require('reciple');`);
Expand Down
4 changes: 2 additions & 2 deletions packages/reciple/static/config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CooldownPrecondition, CommandPermissionsPrecondition } from 'reciple';
import { IntentsBitField } from 'discord.js';
import { version } from '@reciple/core';
import { cliVersion } from 'reciple';

// @ts-check

Expand Down Expand Up @@ -75,5 +75,5 @@ export const config = {
timer: 1000 * 60 * 60
},
checkForUpdates: true,
version: `^${version}`
version: `^${cliVersion}`
};

0 comments on commit 1b9b97d

Please sign in to comment.