mirror of
https://github.com/PHIDIAS0303/ClusterChatSync.git
synced 2026-11-22 00:03:12 +09:00
1.0.6 RC4
This commit is contained in:
1 parent
6a51d36d14
commit
969a770663
1 file changed
+24
-1
+24
-1
@@ -90,6 +90,15 @@ interface Bucket {
|
|||||||
warned: boolean;
|
warned: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Config is keyed by instance name; sendTo wants the controller's numeric ID. */
|
||||||
|
const findInstanceId = (instanceName: string): number | null => {
|
||||||
|
for (const [id, instance] of controller.instances) {
|
||||||
|
if (instance.name === instanceName) return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
export default async function(context: ControllerPluginContext) {
|
export default async function(context: ControllerPluginContext) {
|
||||||
const {controller, logger, plugin} = context;
|
const {controller, logger, plugin} = context;
|
||||||
|
|
||||||
@@ -271,8 +280,22 @@ export default async function(context: ControllerPluginContext) {
|
|||||||
const authorName = message.member?.displayName ?? message.author.username;
|
const authorName = message.member?.displayName ?? message.author.username;
|
||||||
|
|
||||||
for (const instanceName of instanceNames) {
|
for (const instanceName of instanceNames) {
|
||||||
|
const instanceId = findInstanceId(instanceName);
|
||||||
|
|
||||||
|
if (instanceId === null) {
|
||||||
|
if (!warnedNoInstance.has(instanceName)) {
|
||||||
|
warnedNoInstance.add(instanceName);
|
||||||
|
logger.warn(
|
||||||
|
`[Chat Relay] Instance ${instanceName} is mapped for chat but does not exist;`
|
||||||
|
+ ' dropping Discord messages for it.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await controller.sendTo(instanceName, new ChatFromDiscordEvent(
|
await controller.sendTo({instanceId: instanceId}, new ChatFromDiscordEvent(
|
||||||
authorName,
|
authorName,
|
||||||
message.channelId,
|
message.channelId,
|
||||||
datetime,
|
datetime,
|
||||||
|
|||||||
Reference in new issue
Block a user