Set Prefix Tutorial? I'm bad at JS

I used this event below to check for bot prefix then no prefix exist. The question is how to set bot prefix as documents on website said there was a page about it but i can't found it
const { Listener } = require("@sapphire/framework");

class UserEvent extends Listener {
constructor(context, options) {
super(context, {
...options,
once: true,
event: "messageCreate",
});
}
async run(message) {
const prefix = this.container.client.options.defaultPrefix;
return message.channel.send(
prefix
? `My prefix in this guild is: \`${prefix}\``
: "Cannot find any Prefix for Message Commands."
);
}
}

module.exports = {
UserEvent,
};
const { Listener } = require("@sapphire/framework");

class UserEvent extends Listener {
constructor(context, options) {
super(context, {
...options,
once: true,
event: "messageCreate",
});
}
async run(message) {
const prefix = this.container.client.options.defaultPrefix;
return message.channel.send(
prefix
? `My prefix in this guild is: \`${prefix}\``
: "Cannot find any Prefix for Message Commands."
);
}
}

module.exports = {
UserEvent,
};
No description
5 Replies
Lioness100
Lioness10015mo ago
It's in the client options
new Client({ ..., defaultPrefix: '!' })
new Client({ ..., defaultPrefix: '!' })
Broseidon.Java
Broseidon.JavaOP15mo ago
got it! btw is there a way to change prefix by command? as i search there's a function that fetchPrefix but i don't know if thats right
Lioness100
Lioness10015mo ago
fetchPrefix would be called every time a message is sent to dynamically fetch the prefix. Ideally you would create a command that edits the prefix in a database, and the fetch prefix would retrieve that value from the database
Broseidon.Java
Broseidon.JavaOP15mo ago
thank you!
Lioness100
Lioness10015mo ago
Np!
Want results from more Discord servers?
Add your server