Discord API
By creating a Discord object and calling login() on it, the game server can establish a connection to Discord and exchange information in both way. Purposes can be logging player activities or provided slack commands. See Discord Examples for examples.
- new Discord(botname: string) - object, creates and resturns an object used to communicate with Discord; botname must be a configured bot which has access to your Discord server.
- Discord.get(botname: string) - object, returns a previously created Discord client
- this.on(event: string, (params) => { ... }) - installs event handlers, events can be "ready", "messageCreate" and more; the parameters to the callback depend on the event
- this.login() - connects to the Discord server
- this.destroy() - disconnects from Discord
- this.sendtochannel(channelid: string, message: string or object) - sends a message or object to a specific Discord channel; get the channel id by right-click on the channel name; the message can be text, a URL or an object with attributes content and/or embeds.
- this.createChannel(guildId: string, options: object) - creates a new channel in the specified guild; options should include name and type properties. Returns the created channel object.
- this.editChannel(channelId: string, options: object) - edits an existing channel; options can include name and other channel properties. Returns the updated channel object.
- this.deleteChannel(channelId: string) - deletes the specified channel
- this.addRolePermission(channelId: string, roleId: string, permissions: object) - adds role permissions to a channel; permissions object contains permission flags
- this.sendEmbed(channelId: string, embedOptions: object) - sends an embed message to the specified channel using EmbedBuilder; embedOptions can contain title, description, color, and other embed properties. Returns the sent message object.
- this.debug() - outputs debug information about the Discord connection including bot name, Discord.js version, guilds, and channel manager methods. Returns debug info object.