Skip to content

Commit

Permalink
initial "more information" about updating (#596)
Browse files Browse the repository at this point in the history
Still some work to be done.
  • Loading branch information
eslachance authored and amishshah committed Sep 4, 2016
1 parent ab6c99f commit 4022c81
Showing 1 changed file with 37 additions and 6 deletions.
43 changes: 37 additions & 6 deletions docs/custom/documents/updating.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,42 @@
# About the Rewrite
The rewrite takes a much more OOP approach than previous versions, which allows code to be much more manageable.
# About Version 9.0
The 9.0 rewrite takes a much more OOP approach than previous versions, which allows code to be much more manageable.
It's been rebuilt from the ground up and should be much more stable, fixing caching issues that affected
older versions and it also has support for new Discord Features, such as emojis.

## Upgrading your code
The rewrite has a _lot_ of breaking changes. Major methods, e.g. `client.sendMessage(channel, message)` have been moved
from the Client class towards their respective classes - `textChannel.sendMessage(message)`. You can find out the full
extent of these changes by looking at the classes in the documentation.
Version 9, while containing a number of breaking changes, does not require a lot of changes in the code logic.
It does, however, require changes in some of the method changes. This is because most of the methods have been
moved away from the <Client> class into other classes where they belong.

Additionally, some event names and parameters have changed - you should revisit these.
Here are a few examples of methods that has changed:

* `Client.sendMessage(channel, message)` ==> `TextChannel.sendMessage(message)`
* `Client.sendMessage(user, message)` ==> `User.sendMessage(message)`
* `Client.updateMessage(message, "New content") ==> `Message.edit("New Content")`
* `Client.getChannelLogs(channel, limit)` ==> `TextChannel.fetchMessages({options})`
* `Server.detailsOfUser(User)` ==> `Server.members.get(User).properties` (retrieving a member gives a GuildMember object)
* `Client.joinVoiceChannel(voicechannel)` => `VoiceChannel.join()`

A couple more important details:

* `Client.loginWithToken("token")` ==> `client.login("token")`
* `Client.servers.length` ==> `client.guilds.size` (all instances of `server` are now `guild`)

## Callbacks

Version 9.0 eschews callbacks in favour of Promises. This means all code relying on callbacks must be changed.

For example, the following code:

```js
bot.getChannelLogs(channel, 100, function(messages) {
console.log(messages.length + " messages found);
});
```
```js
msg.channel.getMessages({limit: 100})
.then(messages => {
console.log(messages.length + " messages found);
});
```

0 comments on commit 4022c81

Please sign in to comment.