Broid Integrations is an open source project providing a suite of Activity Streams 2 libraries for unified communications among a vast number of communication platforms.
Connect your App to Multiple Messaging Channels with One OpenSource Language.
| Simple | Image | Video | Buttons | Location | Phone number |
|---|---|---|---|---|---|
| ✅ | ✅ | ✅ |
Buttons, Location, Phone number are platform limitations.
- Instructions to create bot, can be found here.
npm install --save @broid/discordconst BroidDiscord = require('@broid/discord');
const discord = new BroidDiscord({ token: "xoxp-xxxxxx" });
discord.connect()
.subscribe({
next: data => console.log(data),
error: err => console.error(`Something went wrong: ${err.message}`),
complete: () => console.log('complete'),
});Options available
| name | Type | default | Description |
|---|---|---|---|
| serviceID | string | random | Arbitrary identifier of the running instance |
| logLevel | string | info |
Can be : fatal, error, warn, info, debug, trace |
| token | string | Your bot access token |
discord.listen()
.subscribe({
next: data => console.log(`Received message: ${data}`),
error: err => console.error(`Something went wrong: ${err.message}`),
complete: () => console.log('complete'),
})To send a message, the format should use the broid-schemas.
const formatted_message = {
"@context": "https://www.w3.org/ns/activitystreams",
"type": "Create",
"generator": {
"id": "f6e92eb6-f69e-4eae-8158-06613461cf3a",
"type": "Service",
"name": "discord"
},
"object": {
"type": "Note",
"content": "hello world"
},
"to": {
"type": "Person",
"id": "152486124831181614"
}
};
discord.send(formatted_message)
.then(() => console.log("ok"))
.catch(err => console.error(err))- A direct message received from Sally
{
"@context": "https://www.w3.org/ns/activitystreams",
"published": 1483491501,
"type": "Create",
"generator": {
"id": "af869e0f-f4e5-424d-a288-1657d843f438",
"type": "Service",
"name": "discord"
},
"object": {
"type": "Note",
"id": "1483491501",
"content": "hello world on private"
},
"target": {
"type": "Person",
"id": "152483118161461248"
},
"actor": {
"id": "152486124831181614",
"type": "Person",
"name": "sally"
}
}- A message received from Sally on Channel/Group
{
"@context": "https://www.w3.org/ns/activitystreams",
"published": 1483491501,
"type": "Create",
"generator": {
"id": "af869e0f-f4e5-424d-a288-1657d843f438",
"type": "Service",
"name": "discord"
},
"object": {
"type": "Note",
"id": "1483491501",
"content": "hello world on private"
},
"target": {
"type": "Group",
"id": "152483118161461248",
"name": "channelname"
},
"actor": {
"id": "152486124831181614",
"type": "Person",
"name": "sally"
}
}- Send a simple message
{
"@context": "https://www.w3.org/ns/activitystreams",
"type": "Create",
"generator": {
"id": "f6e92eb6-f69e-4eae-8158-06613461cf3a",
"type": "Service",
"name": "discord"
},
"object": {
"type": "Note",
"content": "hello world"
},
"to": {
"type": "Person",
"id": "152486124831181614"
}
}- Edit a message
{
"@context": "https://www.w3.org/ns/activitystreams",
"type": "Update",
"generator": {
"id": "f6e92eb6-f69e-4eae-8158-06613461cf3a",
"type": "Service",
"name": "discord"
},
"object": {
"type": "Note",
"content": "hello world edited",
"id": "1483406119",
},
"to": {
"type": "Person",
"id": "152486124831181614"
}
}- Delete a message
{
"@context": "https://www.w3.org/ns/activitystreams",
"type": "Delete",
"generator": {
"id": "f6e92eb6-f69e-4eae-8158-06613461cf3a",
"type": "Service",
"name": "discord"
},
"object": {
"type": "Note",
"content": "",
"id": "1483406119",
},
"to": {
"type": "Person",
"id": "152486124831181614"
}
}- Send a image or a video
{
"@context": "https://www.w3.org/ns/activitystreams",
"type": "Create",
"generator": {
"id": "f6e92eb6-f69e-4eae-8158-06613461cf3a",
"type": "Service",
"name": "discord"
},
"object": {
"content": "image.jpg",
"type": "Image",
"url": "https://www.broid.ai/url_of_image.jpg",
},
"to": {
"type": "Person",
"id": "152486124831181614"
}
}Broid is an open source project. Broid wouldn't be where it is now without contributions by the community. Please consider forking Broid to improve, enhance or fix issues. If you feel like the community will benefit from your fork, please open a pull request.
And because we want to do the better for you. Help us improving Broid by sharing your feedback on our Integrations GitHub Repo and let's build Broid together!
Make sure that you're read and understand the Code of Conduct.
Copyright (c) 2016-2017 Broid.ai
This project is licensed under the AGPL 3, which can be found here.