mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-23 09:35:02 +00:00
added use_inline_reply option to the reply action
This commit is contained in:
parent
7f2731262d
commit
4c4f5854c1
1 changed files with 22 additions and 9 deletions
|
@ -1,4 +1,4 @@
|
||||||
import { MessageOptions, Permissions, Snowflake, TextChannel, ThreadChannel, User } from "discord.js";
|
import { Message, MessageOptions, Permissions, Snowflake, TextChannel, ThreadChannel, User } from "discord.js";
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
|
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
|
||||||
import { LogType } from "../../../data/LogType";
|
import { LogType } from "../../../data/LogType";
|
||||||
|
@ -25,6 +25,7 @@ export const ReplyAction = automodAction({
|
||||||
t.type({
|
t.type({
|
||||||
text: tMessageContent,
|
text: tMessageContent,
|
||||||
auto_delete: tNullable(t.union([tDelayString, t.number])),
|
auto_delete: tNullable(t.union([tDelayString, t.number])),
|
||||||
|
use_inline_reply: t.boolean,
|
||||||
}),
|
}),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ export const ReplyAction = automodAction({
|
||||||
const users = unique(Array.from(new Set(_contexts.map(c => c.user).filter(Boolean)))) as User[];
|
const users = unique(Array.from(new Set(_contexts.map(c => c.user).filter(Boolean)))) as User[];
|
||||||
const user = users[0];
|
const user = users[0];
|
||||||
|
|
||||||
const renderReplyText = async str =>
|
const renderReplyText = async (str: string) =>
|
||||||
renderTemplate(
|
renderTemplate(
|
||||||
str,
|
str,
|
||||||
new TemplateSafeValueContainer({
|
new TemplateSafeValueContainer({
|
||||||
|
@ -94,16 +95,28 @@ export const ReplyAction = automodAction({
|
||||||
}
|
}
|
||||||
|
|
||||||
const messageContent = validateAndParseMessageContent(formatted);
|
const messageContent = validateAndParseMessageContent(formatted);
|
||||||
const replyMsg = await channel.send({
|
let replyMsg: Message;
|
||||||
|
|
||||||
|
if (typeof actionConfig !== "string" && actionConfig.use_inline_reply) {
|
||||||
|
const originalMsg = await channel.messages.fetch(_contexts[0].message!.id);
|
||||||
|
replyMsg = await originalMsg.reply({
|
||||||
...messageContent,
|
...messageContent,
|
||||||
allowedMentions: {
|
allowedMentions: {
|
||||||
users: [user.id],
|
users: [user.id],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
replyMsg = await channel.send({
|
||||||
|
...messageContent,
|
||||||
|
allowedMentions: {
|
||||||
|
users: [user.id],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof actionConfig === "object" && actionConfig.auto_delete) {
|
if (typeof actionConfig === "object" && actionConfig.auto_delete) {
|
||||||
const delay = convertDelayStringToMS(String(actionConfig.auto_delete))!;
|
const delay = convertDelayStringToMS(String(actionConfig.auto_delete))!;
|
||||||
setTimeout(() => replyMsg.delete().catch(noop), delay);
|
setTimeout(() => !replyMsg.deleted && replyMsg.delete().catch(noop), delay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue