mirror of
https://github.com/AsgardEternal/SquadJS.git
synced 2024-09-28 16:24:25 -05:00
Add color gradient to Discord server status embed
This commit is contained in:
parent
7229ba3fb9
commit
df2784247a
@ -24,6 +24,7 @@ await discordServerStatus(
|
||||
discordClient,
|
||||
{ // options - the options included below display the defaults and can be removed for simplicity.
|
||||
color: 16761867, // color of embed
|
||||
colorGradient: true, // gradient color based on player count
|
||||
command: '!server', // command used to send message
|
||||
disableStatus: false // disable bot status as server status
|
||||
}
|
||||
|
@ -1,7 +1,14 @@
|
||||
import { COPYRIGHT_MESSAGE } from 'core/config';
|
||||
import tinygradient from 'tinygradient';
|
||||
|
||||
import { COPYRIGHT_MESSAGE } from 'core/config';
|
||||
import { SERVER_A2S_UPDATED } from 'squad-server/events/server';
|
||||
|
||||
const gradient = tinygradient([
|
||||
{ color: '#ff0000', pos: 0 },
|
||||
{ color: '#ffff00', pos: 0.5 },
|
||||
{ color: '#00ff00', pos: 1 }
|
||||
]);
|
||||
|
||||
function makeEmbed(server, options) {
|
||||
let players = `${server.playerCount}`;
|
||||
if (server.publicQueue + server.reserveQueue > 0)
|
||||
@ -12,7 +19,7 @@ function makeEmbed(server, options) {
|
||||
return {
|
||||
embed: {
|
||||
title: server.serverName,
|
||||
color: options.color,
|
||||
color: options.colorGradient ? parseInt(gradient.rgbAt(server.playerCount / server.publicSlots).toHex(), 16) : options.color,
|
||||
fields: [
|
||||
{
|
||||
name: 'Players',
|
||||
@ -48,6 +55,7 @@ export default async function(server, discordClient, options = {}) {
|
||||
|
||||
options = {
|
||||
color: 16761867,
|
||||
colorGradient: true,
|
||||
command: '!server',
|
||||
disableStatus: false,
|
||||
...options
|
||||
|
@ -9,6 +9,7 @@
|
||||
"connectors": "1.0.0",
|
||||
"didyoumean": "^1.2.1",
|
||||
"influx": "^5.5.1",
|
||||
"squad-server": "1.0.0"
|
||||
"squad-server": "1.0.0",
|
||||
"tinygradient": "^1.1.2"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user