mirror of
https://github.com/PHIDIAS0303/ClusterChatSync.git
synced 2026-11-25 08:13:12 +09:00
Update controller.ts
This commit is contained in:
1 parent
d1999a9156
commit
72f6780465
1 file changed
+15
-2
+15
-2
@@ -130,8 +130,21 @@ export default async function(context: ControllerPluginContext) {
|
|||||||
? text.slice(0, -verb.length).trim()
|
? text.slice(0, -verb.length).trim()
|
||||||
: text;
|
: text;
|
||||||
|
|
||||||
const pc = await controller.instances.get(instanceName).sendRcon(`/_rcon return #game.connected_players`, false, instanceName);
|
const id = [...controller.instances.instances.values()].find(i => i.name === instanceName)?.id;
|
||||||
await sendMessage(instanceName, `**\`${name}\`** ${verb} (${pc})`);
|
const connection = await controller.instances.get(id);
|
||||||
|
|
||||||
|
if (!connection) {
|
||||||
|
await sendMessage(instanceName, `**\`${name}\`** ${verb}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let pc = '';
|
||||||
|
try {
|
||||||
|
pc = String(await connection.sendRcon('/_rcon return #game.connected_players', false, instanceName)).trim();
|
||||||
|
} catch {
|
||||||
|
}
|
||||||
|
|
||||||
|
await sendMessage(instanceName, `**\`${name}\`** ${verb}${pc ? ` (${pc})` : ''}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
controller.config.on('fieldChanged', (field) => {
|
controller.config.on('fieldChanged', (field) => {
|
||||||
|
|||||||
Reference in new issue
Block a user