WOKCommands
Search…
Configuring a feature
Currently WOKCommands doesn't have the ability for server owners to enable or disable features per server/guild, however this functionality is being worked on. Once it is launched your feature files will need to export an additional object to provide some more information about your feature. Here is an example:
JavaScript
TypeScript
welcome-message.js
// Basic welcome message feature
module.exports = (client, instance) => {
// Listen for new members joining a guild
client.on("guildMemberAdd", (member) => {
// Access the guild that they joined
const { guild } = member
// Get the channel named "welcome"
const channel = guild.channels.cache.find(
(channel) => channel.name === "welcome"
)
// Ensure this channel exists
if (!channel) {
return
}
// Send the welcome message
channel.send(`Welcome ${member} to the server!`)
})
}
// Configuration for this feature
module.exports.config = {
// The display name that server owners will see.
// This can be changed at any time.
displayName: 'Welcome Message',
// The name the database will use to set if it is enabled or not.
// This should NEVER be changed once set, and users cannot see it.
dbName: 'WELCOME MESSAGE'
}
welcome-message.ts
import { Client, TextChannel } from 'discord.js'
import WOKCommands from 'wokcommands'
// Basic welcome message feature
export default (client: Client, instance: WOKCommands) => {
// Listen for new members joining a guild
client.on('guildMemberAdd', (member) => {
// Access the guild that they joined
const { guild } = member
// Get the channel named "welcome"
const channel = guild.channels.cache.find(
(channel) => channel.name === 'welcome'
) as TextChannel
// Ensure this channel exists
if (!channel) {
return
}
// Send the welcome message
channel.send({
content: `Welcome ${member} to the server!`,
})
})
}
// Configuration for this feature
const config = {
// The display name that server owners will see.
// This can be changed at any time.
displayName: 'Welcome Message',
// The name the database will use to set if it is enabled or not.
// This should NEVER be changed once set, and users cannot see it.
dbName: 'WELCOME MESSAGE'
}
export { config }
It is encouraged to export a similar configuration object in all of your existing features to ensure you are ready when the enabling/disabling functionality is released.
Copy link