14 Replies
b1nzee
b1nzee•16mo ago
Refer to this thread, it will work for what you're trying to do. https://discord.com/channels/737141877803057244/1136279424896073829 Though the thread is titled Remove application commands, the same solution works for updating too.
-Carlos👑
-Carlos👑OP•16mo ago
this might be a basic question but I stopped using sapphire and generally coding for 4+ months, but where is "RegisterOption" mentioned in the thread?
b1nzee
b1nzee•16mo ago
Uncle Favna shows you a snippet in this thread (which is also shown in the thread I linked) https://discord.com/channels/737141877803057244/1135960507078156310
-Carlos👑
-Carlos👑OP•16mo ago
it logged this: [INFO] ApplicationCommandRegistries(BulkOverwrite) Successfully overwrote global application commands. The application now has 0 global commands but the bot still does not create the slash command
b1nzee
b1nzee•16mo ago
Show me the full code for your ping command file Show me your package.json too
-Carlos👑
-Carlos👑OP•16mo ago
a
b1nzee
b1nzee•16mo ago
That's not where you set the register behaviour, you set it in the SapphireClient as I stated in the thread I linked
-Carlos👑
-Carlos👑OP•16mo ago
inside const client = new SapphireClient({})?
b1nzee
b1nzee•16mo ago
No, I do it inside the login method
-Carlos👑
-Carlos👑OP•16mo ago
do you mean something like this:
b1nzee
b1nzee•16mo ago
This is from one of my bots:
import {
SapphireClient,
LogLevel,
ApplicationCommandRegistries,
RegisterBehavior,
container,
} from "@sapphire/framework";
import {
Partials,
OAuth2Scopes,
GatewayIntentBits,
ActivityType,
PresenceUpdateStatus,
} from "discord.js";
import { PrismaClient } from "@prisma/client";
import { Poru } from "poru";
import { SettingsProvider } from "./util/database/SettingsProvider";
import Logger from "./util/logger/Logger";
import APITransformers from "./util/api/APITransformers";

export default class VenoxityClient extends SapphireClient {
public constructor() {
super({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent,
],
partials: [Partials.Message],
logger: {
instance: new Logger(
process.env.NODE_ENV === "production" ? LogLevel.Info : LogLevel.Debug
),
},
api: {
listenOptions: {
port: Number(process.env.API_PORT),
},
auth: {
id: process.env.CLIENT_ID,
secret: process.env.CLIENT_SECRET,
scopes: [OAuth2Scopes.Identify, OAuth2Scopes.Guilds],
cookie: process.env.API_COOKIE,
domainOverwrite: process.env.OAUTH_DOMAIN,
transformers: [APITransformers.guilds],
},
origin: process.env.API_ORIGIN,
},
presence: {
activities: [
{
name: "commands",
type: ActivityType.Listening,
},
],
status: PresenceUpdateStatus.DoNotDisturb,
},
});
}

public override async login(token?: string) {
ApplicationCommandRegistries.setDefaultBehaviorWhenNotIdentical(
RegisterBehavior.BulkOverwrite
);

// Database connection
container.prisma = new PrismaClient();
container.settings = new SettingsProvider(container.prisma);
await container.settings.init();

// Poru
container.poru = new Poru(
this,
[
{
name: process.env.LAVALINK_NAME,
host: process.env.LAVALINK_HOST,
port: Number(process.env.LAVALINK_PORT),
password: process.env.LAVALINK_PASSWORD,
},
],
{
library: "discord.js",
defaultPlatform: "ytsearch",
}
);

return super.login(token);
}
}

declare module "@sapphire/pieces" {
interface Container {
prisma: PrismaClient;
poru: Poru;
settings: SettingsProvider;
}
}
import {
SapphireClient,
LogLevel,
ApplicationCommandRegistries,
RegisterBehavior,
container,
} from "@sapphire/framework";
import {
Partials,
OAuth2Scopes,
GatewayIntentBits,
ActivityType,
PresenceUpdateStatus,
} from "discord.js";
import { PrismaClient } from "@prisma/client";
import { Poru } from "poru";
import { SettingsProvider } from "./util/database/SettingsProvider";
import Logger from "./util/logger/Logger";
import APITransformers from "./util/api/APITransformers";

export default class VenoxityClient extends SapphireClient {
public constructor() {
super({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent,
],
partials: [Partials.Message],
logger: {
instance: new Logger(
process.env.NODE_ENV === "production" ? LogLevel.Info : LogLevel.Debug
),
},
api: {
listenOptions: {
port: Number(process.env.API_PORT),
},
auth: {
id: process.env.CLIENT_ID,
secret: process.env.CLIENT_SECRET,
scopes: [OAuth2Scopes.Identify, OAuth2Scopes.Guilds],
cookie: process.env.API_COOKIE,
domainOverwrite: process.env.OAUTH_DOMAIN,
transformers: [APITransformers.guilds],
},
origin: process.env.API_ORIGIN,
},
presence: {
activities: [
{
name: "commands",
type: ActivityType.Listening,
},
],
status: PresenceUpdateStatus.DoNotDisturb,
},
});
}

public override async login(token?: string) {
ApplicationCommandRegistries.setDefaultBehaviorWhenNotIdentical(
RegisterBehavior.BulkOverwrite
);

// Database connection
container.prisma = new PrismaClient();
container.settings = new SettingsProvider(container.prisma);
await container.settings.init();

// Poru
container.poru = new Poru(
this,
[
{
name: process.env.LAVALINK_NAME,
host: process.env.LAVALINK_HOST,
port: Number(process.env.LAVALINK_PORT),
password: process.env.LAVALINK_PASSWORD,
},
],
{
library: "discord.js",
defaultPlatform: "ytsearch",
}
);

return super.login(token);
}
}

declare module "@sapphire/pieces" {
interface Container {
prisma: PrismaClient;
poru: Poru;
settings: SettingsProvider;
}
}
-Carlos👑
-Carlos👑OP•16mo ago
worked ty
Lioness100
Lioness100•16mo ago
@_carlos123 in the future, it might be helpful to keep the name of the forum post and the problem details, so it's easier for others to find if they have a similar problem. 🙂
-Carlos👑
-Carlos👑OP•16mo ago
oh okay
Want results from more Discord servers?
Add your server