Skip to content

Commit

Permalink
Rename attachment methods
Browse files Browse the repository at this point in the history
  • Loading branch information
exoRift committed Jun 5, 2020
1 parent e641cce commit 0a6fed1
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 11 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
1.3.2
-
### **Important notes**
- `Agent.addAttachment` has been changed to `Agent.attach`
- `Agent.removeAttachment` has been changed to `Agent.detach`

### **Bug fixes**
- Fixed bug that prevented await timeouts from working properly

1.3.1
-
### **New handling features**
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const agent = new Agent({
}
})

agent.addAttachment('db', knex)
agent.attach('db', knex)

agent.connect()
```
Expand Down
4 changes: 2 additions & 2 deletions lib/agent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class Agent {
* @param {*} value The value of the attachment
* @returns {Object} All added attachments
*/
addAttachment (name, value) {
attach (name, value) {
if (this.attachments[name]) throw Error('An attachment with that name is already added')

this.attachments[name] = value
Expand Down Expand Up @@ -486,7 +486,7 @@ class Agent {
* @param {String} name The name of the attachment to remove
* @returns {*} The value of the removed attachment
*/
removeAttachment (name) {
detach (name) {
const attachment = this.attachments[name]

delete this.attachments[name]
Expand Down
12 changes: 6 additions & 6 deletions lib/agent/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ test('buildHelp', async (t) => {
}]

t.deepEqual(embed, helpContent, `${checkNames[s]}: ${section} page`)
t.deepEqual(pages, Object.entries(checks).reduce((a, [key, content]) => Object.keys(supplies[s]).includes(key) ? a.concat([content]) : a, []), `${checkNames[s]}: pages match`)
t.deepEqual(pages, Object.entries(checks).reduce((a, [key, content]) => Object.keys(supplies[s]).includes(key) ? a.concat(content) : a, []), `${checkNames[s]}: pages match`)

i++
}
Expand Down Expand Up @@ -616,7 +616,7 @@ test('attachmentSystem', (t) => {
})

return t.context.agent._onReady().then(async () => {
t.context.agent.addAttachment('attachment', 'hello')
t.context.agent.attach('attachment', 'hello')

t.is((await t.context.agent.commandHandler.handle(await t.context.channels.dChannel.createMessage('!testattachment'))).results[0].responses[0].content, 'hello', 'Command handler')

Expand All @@ -629,21 +629,21 @@ test('attachmentSystem', (t) => {
test('removingAttachments', (t) => {
t.context.init()

t.context.agent.addAttachment('attachment', 'hello')
t.context.agent.attach('attachment', 'hello')

t.is(t.context.agent.attachments.attachment, 'hello', 'Attachment added')

t.context.agent.removeAttachment('attachment')
t.context.agent.detach('attachment')

t.is(t.context.agent.attachments.attachment, undefined, 'Attachment removed')
})

test('attachExistingAttachment', (t) => {
t.context.init()

t.context.agent.addAttachment('existing', 'hello')
t.context.agent.attach('existing', 'hello')

t.throws(() => t.context.agent.addAttachment('existing', 'goodbye'), 'An attachment with that name is already added')
t.throws(() => t.context.agent.attach('existing', 'goodbye'), 'An attachment with that name is already added')
})

test('permissionsSystem', (t) => {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cyclone-engine",
"version": "1.3.1",
"version": "1.3.2",
"description": "A stable Discord bot engine/framework centered around granting features and automation without hindering developer freedom",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 0a6fed1

Please sign in to comment.