Structures - satom99/litcord GitHub Wiki
Note all structures include their original Discord object's attributes if not overwritten.
base(parent)
A base class for structures.
Methods
update(data)
loops overdata
and sets all keys and their respective values toself
.__updated()
used by inheritors to know when their data is updated.
Attributes
parent
a parent structure.
User(client)
Represents a Discord user.
Methods
sendMessage(...)
creates a DM channel if not present and calls itssendMessage
method.
Attributes
channel
aChannel
structure representing a DM channel with the user.
Server(client)
Represents a Discord guild.
Methods
edit({...})
requires an object with any parameter to modify.owner
either an int representing an user ID or anUser
structureor setOwner(owner)
.name
a string representing new guild's nameor setName(name)
.region
a string representing new guild's regionor setRegion(region)
.icon
a string representing new guild's iconor setIcon(icon)
.splash
a string representing new guild's splashor setSplash(splash)
.setAFKchannel(channel)
requires either a channel ID or aChannel
structure.setAFKtimeout(timeout)
requires an int in miliseconds.
delete()
permanently deletes the guild from Discord. Note this is not reversible.unban(user)
requires either an user ID or anUser
structure.getBans()
requests and returns aCache
object containing all banned users asUser
structures.getInvites()
requests and returns aCache
object containing all invites asInvite
structures.createRole()
creates a new guild role and returns aRole
structure.createChannel({...})
requires an object containing these parametters.createTextChannel(name)
creates a text channel.createVoiceChannel(name[, bitrate])
creates a voice channel.
Attributes
bans
aCache
object containing banned users asUser
structures.roles
aCache
object containingRole
structures.members
aCache
object containingMember
structures.channels
aCache
object containingChannel
structures.invites
aCache
object containingInvite
structures.owner
anUser
structure representing guild's owner.afk_channel
aChannel
structure representing guild's AFK channel, if set.embed_channel
aChannel
structure representing guild's embed channel, if set.
Role(server)
Represents a guild role.
Methods
edit({...})
requires an object containing attributes to change.name
a string representing desired new nameor setName(name)
.position
an int representing desired new display positionor setPosition(position)
.color
an int representing desired rgb coloror setColor(color)
.hoist
a bool representing whether should the role be displayed separately in the sidebaror setHoist(hoist)
.
delete()
deletes the role.
Attributes
permissions
aBitwise
object.
Member(server)
Represents a guild member.
Methods
edit({...})
requires an object containing attributes to change.nick
a string representing member's nickname to setor setNickName(nick)
.mute
a bool representing whether the member is mutedor setMuted(mute)
.deaf
a bool representing whether the member is deafenedor setDeaf(deaf)
.move(channel)
with either an id or aChannel
structure, representing a voice channel to move the member to.roles
an array of roles the member is assigned to.
kick()
kicks the member.ban(days)
bans the member,days
represents the number of days to delete messages for.setRole(role)
assigns the member aRole
.revokeRole(role)
removes the member from aRole
.hasPermission(bit)
returns whether the member has given permissionbit
.
Attributes
user
anUser
object representing the member.roles
an array containingRole
structures.
Channel(parent)
Represents a Discord channel/DM. parent
can be an User
or a Server
.
Methods
edit({...})
requires an object containing attributes to change.name
a stringor setName(name)
.topic
a stringor setTopic(topic)
.bitrate
an intor setBitrate(bitrate)
.position
an intor setPosition(position)
.setSlots
an intor setSlots(slots)
.
getHistory(limit[, config])
fetches and returns all messages based on given values and configuration.sendMessage(thing)
returns aMessage
structure,thing
may be a string or an object with attributes.bulkDelete(array)
bulk-deletes all messages, as structures or IDs, in a given array.getInvites()
equivalent to server's but channel-level.createInvite([{...}])
returns anInvite
structure, optionally accepts an object with any valid parameter set.delete()
permanently deletes the channel.
Attributes
invites
aCache
object containing invites asInvite
structures.history
aCache
object of sent messages asMessage
structures.is_voice
a bool set to true in case it is a voice channel.is_private
a bool set to true in case it is a DM channel.overwrites
aCache
object containingOverwrite
objects.
Message(channel)
Represents a Discord message.
Methods
reply(thing)
calls message's parent channel'ssendMessage
method and returns aMessage
structure.edit(thing)
changes message's attributes, works the same way assendMessage
.react(emoji)
adds a reaction with givenemoji
and returns aReaction
structure.delete()
deletes the message.
Attributes
clean
a string with all mentions fixed, i.e. if an user is mentioned their name is shown instead.author
anUser
structure representing message's author.mentions
an array containing mentioned users asUser
structures.mentions.client
a bool representing whether the local client is mentioned.
Reaction(message)
Represents a reaction to a message. Inherits from Emoji
.
Methods
clear()
clears a reaction.remove([user])
removes a reaction from a givenuser
or local's if not set.
Attributes
users
aCache
object ofUser
structures.
Emoji()
Represents an emoji.
Attributes
url
a link to emoji's image.string
a string to be used in messages.
Overwrite(channel)
Represents a Discord channel permission overwrite.
Methods
delete()
deletes the overwrite.
Attributes
deny
aBitwise
object of denied permissions.allow
aBitwise
object of allowed permissions.
Invite(channel)
Represents a Discord channel invite.
Methods
accept()
accepts the invite. Refer to client'sacceptInvite
method for direct acceptance.delete()
deletes the invite.
Attributes
url
a string repesenting a direct link for the invite.
Bitwise(parent)
A management class for permissions. parent
should always be an Overwrite
or a Role
object.
Methods
has(name)
returns a bool representing whether input permission is added.add(name)
adds a permission from valid permissions. Also accepts abit
instead.remove(name)
removes a permission from valid permissions.