DemonWayne
DemonWayne
SIASapphire - Imagine a framework
Created by DemonWayne on 3/14/2024 in #sapphire-support
logger doesn't work properly
Thanks!
11 replies
SIASapphire - Imagine a framework
Created by DemonWayne on 3/14/2024 in #sapphire-support
logger doesn't work properly
src/index.ts:
import '@sapphire/plugin-logger/register';
import 'dotenv/config';
import AdvancedClient from '#lib/AdvancedClient';

const client = new AdvancedClient<true>();

client.login().catch(() => process.exit(0));
import '@sapphire/plugin-logger/register';
import 'dotenv/config';
import AdvancedClient from '#lib/AdvancedClient';

const client = new AdvancedClient<true>();

client.login().catch(() => process.exit(0));
src/lib/AdvancedClient.ts
import { ApplicationCommandRegistries, LogLevel, RegisterBehavior, SapphireClient } from '@sapphire/framework';
import { connect, set } from 'mongoose';
import { Partials } from 'discord.js';
import type { SapphireClientOptions } from '@sapphire/framework';

ApplicationCommandRegistries.setDefaultBehaviorWhenNotIdentical(RegisterBehavior.BulkOverwrite);

export default class AdvancedClient<Ready extends boolean = boolean> extends SapphireClient<Ready> {
public constructor(options: SapphireClientOptions = {}) {
super({
intents: ['Guilds', 'GuildMembers', 'GuildMessages', 'MessageContent'],
sweepers: { messages: { interval: 120, lifetime: 60 } },
partials: [Partials.Message, Partials.Channel, Partials.GuildMember],

logger: { level: process.env.NODE_ENV === 'development' ? LogLevel.Debug : undefined },

...options,
});
}

public override login() {
this.connectDatabase();
return super.login();
}

private connectDatabase() {
set('strictQuery', true);
connect((process.env.DATABASE_URL ??= ''), {}).catch(err => {
if (err) throw err;
else this.logger.info('[Database] MongoDB successfully connected.');
});
}
}
import { ApplicationCommandRegistries, LogLevel, RegisterBehavior, SapphireClient } from '@sapphire/framework';
import { connect, set } from 'mongoose';
import { Partials } from 'discord.js';
import type { SapphireClientOptions } from '@sapphire/framework';

ApplicationCommandRegistries.setDefaultBehaviorWhenNotIdentical(RegisterBehavior.BulkOverwrite);

export default class AdvancedClient<Ready extends boolean = boolean> extends SapphireClient<Ready> {
public constructor(options: SapphireClientOptions = {}) {
super({
intents: ['Guilds', 'GuildMembers', 'GuildMessages', 'MessageContent'],
sweepers: { messages: { interval: 120, lifetime: 60 } },
partials: [Partials.Message, Partials.Channel, Partials.GuildMember],

logger: { level: process.env.NODE_ENV === 'development' ? LogLevel.Debug : undefined },

...options,
});
}

public override login() {
this.connectDatabase();
return super.login();
}

private connectDatabase() {
set('strictQuery', true);
connect((process.env.DATABASE_URL ??= ''), {}).catch(err => {
if (err) throw err;
else this.logger.info('[Database] MongoDB successfully connected.');
});
}
}
package.json
{
"dependencies": {
"@sapphire/async-queue": "^1.5.0",
"@sapphire/duration": "^1.1.2",
"@sapphire/framework": "^5.0.7",
"@sapphire/plugin-logger": "^3.0.7",
"@sapphire/plugin-subcommands": "^6.0.3",
"discord.js": "^14.14.1",
"dotenv": "^16.3.1",
"mongoose": "^8.0.3"
},
"devDependencies": {
"@sapphire/decorators": "^6.0.2",
"@sapphire/eslint-config": "^5.0.2",
"@sapphire/ts-config": "^5.0.0",
"tsc-watch": "^6.0.4",
"typescript": "^5.1.6"
}
}
{
"dependencies": {
"@sapphire/async-queue": "^1.5.0",
"@sapphire/duration": "^1.1.2",
"@sapphire/framework": "^5.0.7",
"@sapphire/plugin-logger": "^3.0.7",
"@sapphire/plugin-subcommands": "^6.0.3",
"discord.js": "^14.14.1",
"dotenv": "^16.3.1",
"mongoose": "^8.0.3"
},
"devDependencies": {
"@sapphire/decorators": "^6.0.2",
"@sapphire/eslint-config": "^5.0.2",
"@sapphire/ts-config": "^5.0.0",
"tsc-watch": "^6.0.4",
"typescript": "^5.1.6"
}
}
11 replies
SIASapphire - Imagine a framework
Created by jwn on 9/29/2023 in #sapphire-support
Client Permissions
Previously, obtaining permissions for new applications did not work due to this check:
if (isNullish(permissions))
if (isNullish(permissions))
Because permissions have always had the value of this.dmChannelPermissions (for new applications), in fix, I removed this check
19 replies
SIASapphire - Imagine a framework
Created by jwn on 9/29/2023 in #sapphire-support
Client Permissions
19 replies
SIASapphire - Imagine a framework
Created by Zaros on 9/28/2023 in #sapphire-support
ApplicationCommandRegistries.setDefaultGuildIds is not a function
What version of framework you using?
10 replies