Skip to content

Commit

Permalink
Feat: Add @here & Server Name (#344)
Browse files Browse the repository at this point in the history
* Feat: Add @here & Server Name

* Update: config.json

* Update: discord-admin-request.js

Update to instead of using an option for ServerName, use the this.server.serverName

* Update README.md

* Yarn Lint
  • Loading branch information
IgnisAlienus authored Feb 5, 2024
1 parent 8bfeb4d commit 9de44f6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,11 @@ Grafana:
<pre><code>[
"500455137626554379"
]</code></pre>
<li><h4>pingHere</h4>
<h6>Description</h6>
<p>Ping @here. Great if Admin Requests are posted to a Squad Admin ONLY channel, allows pinging only Online Admins.</p>
<h6>Default</h6>
<pre><code>false</code></pre></li>
<li><h4>pingDelay</h4>
<h6>Description</h6>
<p>Cooldown for pings in milliseconds.</p>
Expand Down
1 change: 1 addition & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
"ignorePhrases": [],
"command": "admin",
"pingGroups": [],
"pingHere": false,
"pingDelay": 60000,
"color": 16761867,
"warnInGameAdmins": false,
Expand Down
20 changes: 19 additions & 1 deletion squad-server/plugins/discord-admin-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ export default class DiscordAdminRequest extends DiscordBasePlugin {
default: [],
example: ['500455137626554379']
},
pingHere: {
required: false,
description:
'Ping @here. Great if Admin Requests are posted to a Squad Admin ONLY channel, allows pinging only Online Admins.',
default: false
},
pingDelay: {
required: false,
description: 'Cooldown for pings in milliseconds.',
Expand Down Expand Up @@ -141,7 +147,19 @@ export default class DiscordAdminRequest extends DiscordBasePlugin {
};

if (this.options.pingGroups.length > 0 && Date.now() - this.options.pingDelay > this.lastPing) {
message.content = this.options.pingGroups.map((groupID) => `<@&${groupID}>`).join(' ');
if (this.options.pingHere === true && this.options.pingGroups.length === 0) {
message.content = `@here - Admin Requested in ${this.server.serverName}`;
} else if (this.options.pingHere === true && this.options.pingGroups.length > 0) {
message.content = `@here - Admin Requested in ${
this.server.serverName
} - ${this.options.pingGroups.map((groupID) => `<@&${groupID}>`).join(' ')}`;
} else if (this.options.pingHere === false && this.options.pingGroups.length === 0) {
message.content = `Admin Requested in ${this.server.serverName}`;
} else if (this.options.pingHere === false && this.options.pingGroups.length > 0) {
message.content = `Admin Requested in ${this.server.serverName} - ${this.options.pingGroups
.map((groupID) => `<@&${groupID}>`)
.join(' ')}`;
}
this.lastPing = Date.now();
}

Expand Down

0 comments on commit 9de44f6

Please sign in to comment.