JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q5552F
  • License ISC

Provides extra functions for guild channels and roles like findOrCreate

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 extra functions for discord channels and roles and it open for future development current functions provided: findOne, findAll, findOrCreate, findAndDelete

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

//find one channel
guild.channels.findOne('exampleChannel')
    .then(channel => console.log(`Channel ${channel.name} has been created`))
    .catch(console.error)

//find all text channels with the letter a in it
guild.channels.findAll('a' , {type : 'text'} , {includes : true})
    .then(channels => channels.forEach(channel => console.log(channel.name)))
    .catch(console.error)

//find or create channel
guild.channels.findOrCreate('exampleChannel')
    .then(channel => console.log(`Channel ${channel.name} has been created`))
    .catch(console.error)

//find or create category channel
guild.channels.findOrCreate('exampleChannel' , {type : 'category'})
    .then(channel => console.log(`Channel ${channel.name} has been created`))
    .catch(console.error)

//findOrCreate channel with options
guild.channels.findOrCreate('exampleChannel' , {
  type: 'voice',
  permissionOverwrites: [
     {
       id: message.author.id,
       deny: ['VIEW_CHANNEL'],
    },
  ],
})
    .then(channel => console.log(`Channel ${channel.name} has been created`))
    .catch(console.error)

//find and delete category channel
guild.channels.findAndDelete('exampleChannel' , {type : 'category'})
    .then(result => console.log(result))
    .catch(console.error)

Roles Functions

//find one role
guild.roles.findOne('exampleRole')
    .then(role => console.log(`Role ${role.name} has been created`))
    .catch(console.error)

//find all roles with the letter a in it
guild.roles.findAll('a' , {} , {includes : true})
    .then(roles => roles.forEach(role => console.log(role.name)))
    .catch(console.error)

//find or create role
guild.roles.findOrCreate('exampleRole')
    .then(role => console.log(`Role ${role.name} has been created`))
    .catch(console.error)

//findOrCreate role with options
guild.roles.findOrCreate('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)

//find or create role
guild.roles.findAndDelete('exampleRole')
    .then(result => console.log(result))
    .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.

GitHub

License

MIT