Package Exports
- avdiscordutils
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (avdiscordutils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
avdiscordutils
Provides FindOrCreate options for discord roles and channels and is open for future development and functions to be added
Installation
Use the package manager npm to install avdiscordutils.
npm install avdiscordutils --save
Usage
const {Structures} = require('discord.js')
require('avdiscordutils')(Structures);
Examples
Channel Functions
//findOrCreate channel
DiscordUtils(message.guild).findOrCreateChannel('exampleChannel')
.then(channel => console.log(`Channel ${channel.name} has been created`))
.catch(console.error)
//findOrCreate category channel
DiscordUtils(message.guild).findOrCreateChannel('exampleChannel' , {type : 'category'})
.then(channel => console.log(`Channel ${channel.name} has been created`))
.catch(console.error)
//findOrCreate channel with options
DiscordUtils(message.guild).findOrCreateChannel('exampleChannel' , {
type: 'voice',
permissionOverwrites: [
{
id: message.author.id,
deny: ['VIEW_CHANNEL'],
},
],
})
.then(channel => console.log(`Channel ${channel.name} has been created`))
.catch(console.error)
Roles Functions
//findOrCreate role
DiscordUtils(message.guild).findOrCreateRole('exampleRole')
.then(role => console.log(`Role ${role.name} has been created`))
.catch(console.error)
//findOrCreate role with options
DiscordUtils(message.guild).findOrCreateRole('exampleRole' , {
data: {
name: 'Super Cool People',
color: 'BLUE',
},
reason: 'we needed a role for Super Cool People',
})
.then(role => console.log(`Role ${role.name} has been created`))
.catch(console.error)
the options object can be found on the official discord documentation.
findOrCreateChannel options object
findOrCreateRole options object
avdiscordutils uses Promises extensively. This means that, if your Node version supports it, you can use ES2017 async/await syntax for all asynchronous calls made with avdiscordutils.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.