mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
Change -allow-mentions to enable all mentions in !post
Previously -allow-mentions toggled mentioned roles mentionable and then back after the message was posted. This was somewhat unintuitive.
This commit is contained in:
parent
b541d5d087
commit
b8c436731c
1 changed files with 8 additions and 25 deletions
|
@ -1,7 +1,7 @@
|
|||
import { GuildPluginData } from "knub";
|
||||
import { PostPluginType } from "../types";
|
||||
import { TextChannel, MessageContent, Attachment, Message, Role } from "eris";
|
||||
import { downloadFile, getRoleMentions } from "../../../utils";
|
||||
import { Attachment, Message, MessageContent, TextChannel } from "eris";
|
||||
import { downloadFile } from "../../../utils";
|
||||
import fs from "fs";
|
||||
import { formatContent } from "./formatContent";
|
||||
|
||||
|
@ -32,34 +32,17 @@ export async function postMessage(
|
|||
};
|
||||
}
|
||||
|
||||
const rolesMadeMentionable: Role[] = [];
|
||||
if (enableMentions && content.content) {
|
||||
const mentionedRoleIds = getRoleMentions(content.content);
|
||||
if (mentionedRoleIds != null) {
|
||||
for (const roleId of mentionedRoleIds) {
|
||||
const role = pluginData.guild.roles.get(roleId);
|
||||
if (role && !role.mentionable) {
|
||||
await role.edit({
|
||||
mentionable: true,
|
||||
});
|
||||
rolesMadeMentionable.push(role);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
content.allowedMentions = content.allowedMentions || {};
|
||||
content.allowedMentions.everyone = false;
|
||||
if (enableMentions) {
|
||||
content.allowedMentions = {
|
||||
everyone: true,
|
||||
users: true,
|
||||
roles: true,
|
||||
};
|
||||
}
|
||||
|
||||
const createdMsg = await channel.createMessage(content, file);
|
||||
pluginData.state.savedMessages.setPermanent(createdMsg.id);
|
||||
|
||||
for (const role of rolesMadeMentionable) {
|
||||
role.edit({
|
||||
mentionable: false,
|
||||
});
|
||||
}
|
||||
|
||||
if (downloadedAttachment) {
|
||||
downloadedAttachment.deleteFn();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue