mirror of
https://github.com/janderedev/automod.git
synced 2024-12-22 10:45:27 +00:00
bridge: fetch message author if unknown
This commit is contained in:
parent
bf76b407e1
commit
a5b8ba6478
|
@ -90,6 +90,8 @@ client.on("messageUpdate", async (message) => {
|
||||||
try {
|
try {
|
||||||
logger.debug(`[E] Revolt: ${message.content}`);
|
logger.debug(`[E] Revolt: ${message.content}`);
|
||||||
|
|
||||||
|
if (!message.author) await client.users.fetch(message.authorId!);
|
||||||
|
|
||||||
const [bridgeCfg, bridgedMsg] = await Promise.all([
|
const [bridgeCfg, bridgedMsg] = await Promise.all([
|
||||||
BRIDGE_CONFIG.findOne({ revolt: message.channelId }),
|
BRIDGE_CONFIG.findOne({ revolt: message.channelId }),
|
||||||
BRIDGED_MESSAGES.findOne({ "revolt.nonce": message.nonce }),
|
BRIDGED_MESSAGES.findOne({ "revolt.nonce": message.nonce }),
|
||||||
|
@ -111,15 +113,15 @@ client.on("messageUpdate", async (message) => {
|
||||||
if (!targetMsg)
|
if (!targetMsg)
|
||||||
return logger.debug(`Revolt: Could not fetch message from Discord`);
|
return logger.debug(`Revolt: Could not fetch message from Discord`);
|
||||||
|
|
||||||
const client = new WebhookClient({
|
const webhookClient = new WebhookClient({
|
||||||
id: bridgeCfg.discordWebhook.id,
|
id: bridgeCfg.discordWebhook.id,
|
||||||
token: bridgeCfg.discordWebhook.token,
|
token: bridgeCfg.discordWebhook.token,
|
||||||
});
|
});
|
||||||
await client.editMessage(targetMsg, {
|
await webhookClient.editMessage(targetMsg, {
|
||||||
content: await renderMessageBody(message.content),
|
content: await renderMessageBody(message.content),
|
||||||
allowedMentions: { parse: [] },
|
allowedMentions: { parse: [] },
|
||||||
});
|
});
|
||||||
client.destroy();
|
webhookClient.destroy();
|
||||||
|
|
||||||
metrics.messages.inc({ source: "revolt", type: "edit" });
|
metrics.messages.inc({ source: "revolt", type: "edit" });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -131,6 +133,8 @@ client.on("messageCreate", async (message) => {
|
||||||
try {
|
try {
|
||||||
logger.debug(`[M] Revolt: ${message.id} ${message.content}`);
|
logger.debug(`[M] Revolt: ${message.id} ${message.content}`);
|
||||||
|
|
||||||
|
if (!message.author) await client.users.fetch(message.authorId!);
|
||||||
|
|
||||||
const [bridgeCfg, bridgedMsg, ...repliedMessages] = await Promise.all([
|
const [bridgeCfg, bridgedMsg, ...repliedMessages] = await Promise.all([
|
||||||
BRIDGE_CONFIG.findOne({ revolt: message.channelId }),
|
BRIDGE_CONFIG.findOne({ revolt: message.channelId }),
|
||||||
BRIDGED_MESSAGES.findOne(
|
BRIDGED_MESSAGES.findOne(
|
||||||
|
@ -229,7 +233,7 @@ client.on("messageCreate", async (message) => {
|
||||||
const channel = (await discordClient.channels.fetch(
|
const channel = (await discordClient.channels.fetch(
|
||||||
bridgeCfg.discord
|
bridgeCfg.discord
|
||||||
)) as TextChannel;
|
)) as TextChannel;
|
||||||
const client = new WebhookClient({
|
const webhookClient = new WebhookClient({
|
||||||
id: bridgeCfg.discordWebhook!.id,
|
id: bridgeCfg.discordWebhook!.id,
|
||||||
token: bridgeCfg.discordWebhook!.token,
|
token: bridgeCfg.discordWebhook!.token,
|
||||||
});
|
});
|
||||||
|
@ -373,7 +377,7 @@ client.on("messageCreate", async (message) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
client
|
webhookClient
|
||||||
.send(payload)
|
.send(payload)
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
await BRIDGED_MESSAGES.update(
|
await BRIDGED_MESSAGES.update(
|
||||||
|
|
Loading…
Reference in a new issue