Skip to main content
Module

x/coward/mod.ts>Client

🐔 Coward is a Deno module for easy interaction with the Discord API.
Latest
class Client
import { Client } from "https://deno.land/x/coward@v0.3.2/mod.ts";

Class representing the main client

Constructors

new
Client(token: string, options?: Options.clientConstructor)

Create a Client

Properties

private
requestHandler: RequestHandler
channelGuildIDs: Map<string, string>
dmChannels: Map<string, DMChannel>
dmChannelUsers: Map<string, string>
evt
gateway: Gateway
guilds: Map<string, Guild>
users: Map<string, User>

Methods

Connect to the Discord API

createChannel(guildID: string, options: Options.createChannel): Promise<Channel>

Post a channel in a guild. Requires the MANAGE_CHANNELS permission.

createMessage(channelID: string, content: string | Options.createMessage): Promise<Message>

Post a message in a channel. Requires the SEND_MESSAGES permission.

createRole(guildID: string, options: Options.createRole): Promise<Role>

Create a role in a guild. Requires MANAGE_ROLES permission.

deleteAllEmojiReactions(
channelID: string,
messageID: string,
emoji: string,
): Promise<void>

Delete all reactions with a given emoji on a message. Requires MANAGE_MESSAGES permission.

deleteAllReactions(channelID: string, messageID: string): Promise<void>

Delete all reactions from a message. Requires the MANAGE_MESSAGES permission.

deleteBan(guildID: string, userID: string): Promise<void>

Delete a ban from a guild. Requires BAN_MEMBERS permission.

deleteChannel(channelID: string): Promise<void>

Delete a channel. Requires the MANAGE_CHANNELS permission in the guild.

deleteGuild(guildID: string): Promise<void>

Delete a guild permanently. Must be the owner.

deleteMessage(channelID: string, messageID: string): Promise<void>

Delete a message in a channel. Requires the MANAGE_MESSAGES permission.

deletePin(channelID: string, messageID: string): Promise<void>

Delete a pinned channel message. Requires the MANAGE_MESSAGES permission.

deleteReaction(
channelID: string,
messageID: string,
emoji: string,
userID?: string,
): Promise<void>

Delete a reaction on a message. If deleting a reaction from another user, requires the MANAGE_MESSAGES permission.

deleteRole(guildID: string, roleID: string): Promise<void>

Delete a role in a guild. Requires MANAGE_ROLES permission.

getChannelInvites(channelID: string): Promise<Array<Invite>>

Get invites in a guild channel. Returns an array of Invite objects. Requires MANAGE_CHANNELS permission.

getDMChannel(userID: string): Promise<DMChannel>

Get a DM channel of a user - if there is none, create one.

modifyChannel(channelID: string, options: Options.modifyChannel): Promise<Channel>

Modify a channel. Requires the MANAGE_CHANNELS permission in the guild.

modifyGuild(guildID: string, options: Options.modifyGuild): Promise<Guild>

Modify a guild. Requires the MANAGE_GUILD permission.

modifyMember(
guildID: string,
userID: string,
): Promise<GuildMember>

Modify the attributes of a guild member.

modifyMessage(
channelID: string,
messageID: string,
content: string | Options.modifyMessage,
): Promise<Message>

Modify a message. Must be authored by you.

modifyPresence(options?: Options.modifyPresence): Promise<void>
modifyRole(
guildID: string,
roleID: string,
): Promise<Role>

Modify a role in a guild. Requires MANAGE_ROLES permission.

postTypingIndicator(channelID: string): Promise<void>

Post a typing indicator for a specified channel. Bots should usually not use this, however if a bot is responding to a command and expects the computation to take a few seconds, this may be used to let the user know that the bot is processing their message.

putBan(
guildID: string,
userID: string,
options: Options.putBan,
): Promise<void>

Put a ban in a guild. Requires BAN_MEMBERS permission.

putPin(channelID: string, messageID: string): Promise<void>

Pin a message in a channel. Requires the MANAGE_MESSAGES permission.

putReaction(
channelID: string,
messageID: string,
emoji: string,
): Promise<void>

Put a reaction on a message. Requires the READ_MESSAGE_HISTORY permission. Additionally, if nobody has reacted to the message with the emoji, requires the ADD_REACTIONS permission.

putRole(
guildID: string,
userID: string,
roleID: string,
): Promise<void>

Put a role on a member in a guild. Requires MANAGE_ROLES permission.

removeMember(guildID: string, userID: string): Promise<void>

Remove a member from a guild. Requires KICK_MEMBERS permission.

removeRole(
guildID: string,
userID: string,
roleID: string,
): Promise<void>

Remove a role from a member in a guild. Requires MANAGE_ROLES permission.