-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from Thomas-Smyth/beta
SquadJS v1.2.0 Release
- Loading branch information
Showing
14 changed files
with
141 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<div align="center"> | ||
|
||
<img src="../../assets/squadjs-logo.png" alt="Logo" width="500"/> | ||
|
||
#### SquadJS - Discord Admin Broadcast Plugin | ||
</div> | ||
|
||
## About | ||
The Discord Admin Broadcast plugin streams admin broadcasts logs to Discord. | ||
|
||
## Installation | ||
```js | ||
// Place the following two lines at the top of your index.js file. | ||
import Discord from 'discord.js'; | ||
import { discordAdminBroadcast } from 'plugins'; | ||
|
||
// Place the following two lines in your index.js file before using an Discord plugins. | ||
const discordClient = new Discord.Client(); | ||
await discordClient.login('Discord Login Token'); // insert your Discord bot's login token here. | ||
|
||
// Place the following lines after all of the above. | ||
await discordAdminBroadcast( | ||
server, | ||
discordClient, | ||
'discordChannelID', | ||
{ // options - the options included below display the defaults and can be removed for simplicity. | ||
color: 16761867 // color of embed | ||
} | ||
); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { COPYRIGHT_MESSAGE } from 'core/config'; | ||
import { LOG_PARSER_ADMIN_BROADCAST } from 'squad-server/events/log-parser'; | ||
|
||
export default async function(server, discordClient, channelID, options = {}) { | ||
if (!server) throw new Error('DiscordChat must be provided with a reference to the server.'); | ||
|
||
if (!discordClient) throw new Error('DiscordChat must be provided with a Discord.js client.'); | ||
|
||
if (!channelID) throw new Error('DiscordChat must be provided with a channel ID.'); | ||
|
||
options = { | ||
color: 16761867, | ||
...options | ||
}; | ||
|
||
const channel = await discordClient.channels.fetch(channelID); | ||
|
||
server.on(LOG_PARSER_ADMIN_BROADCAST, async info => { | ||
channel.send({ | ||
embed: { | ||
title: 'Admin Broadcast', | ||
color: options.color, | ||
fields: [ | ||
{ | ||
name: 'Message', | ||
value: `${info.message}` | ||
} | ||
], | ||
timestamp: info.time.toISOString(), | ||
footer: { | ||
text: COPYRIGHT_MESSAGE | ||
} | ||
} | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { LOG_PARSER_ADMIN_BROADCAST } from '../../events/log-parser.js'; | ||
|
||
export default { | ||
regex: /^\[([0-9.:-]+)]\[([ 0-9]*)]LogSquad: ADMIN COMMAND: Message broadcasted <(.+)> from (.+)/, | ||
onMatch: (args, logParser) => { | ||
const data = { | ||
raw: args[0], | ||
time: args[1], | ||
chainID: args[2], | ||
message: args[3], | ||
from: args[4] | ||
}; | ||
|
||
logParser.server.emit(LOG_PARSER_ADMIN_BROADCAST, data); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters