feat: add message / block for bots

This commit is contained in:
Paul Makles 2022-05-07 15:24:00 +01:00
parent 08e1db6d35
commit 4c08483848

View file

@ -580,64 +580,70 @@ export default function ContextMenus() {
} }
if (user) { if (user) {
if (!user.bot) { let actions: (Action["action"] | boolean)[];
let actions: Action["action"][]; switch (user.relationship) {
switch (user.relationship) { case "User":
case "User": actions = [];
actions = []; break;
break; case "Friend":
case "Friend": actions = [
actions = ["remove_friend", "block_user"]; !user.bot && "remove_friend",
break; "block_user",
case "Incoming": ];
break;
case "Incoming":
actions = [
"add_friend",
"cancel_friend",
"block_user",
];
break;
case "Outgoing":
actions = [
!user.bot && "cancel_friend",
"block_user",
];
break;
case "Blocked":
actions = ["unblock_user"];
break;
case "BlockedOther":
actions = ["block_user"];
break;
case "None":
default:
if ((user.flags && 2) || (user.flags && 4)) {
actions = ["block_user"];
} else {
actions = [ actions = [
"add_friend", !user.bot && "add_friend",
"cancel_friend",
"block_user", "block_user",
]; ];
break; }
case "Outgoing": }
actions = ["cancel_friend", "block_user"];
break;
case "Blocked":
actions = ["unblock_user"];
break;
case "BlockedOther":
actions = ["block_user"];
break;
case "None":
default:
if (
(user.flags && 2) ||
(user.flags && 4)
) {
actions = ["block_user"];
} else {
actions = ["add_friend", "block_user"];
}
}
if (userPermissions & UserPermission.ViewProfile) { if (userPermissions & UserPermission.ViewProfile) {
generateAction({ generateAction({
action: "view_profile", action: "view_profile",
user, user,
}); });
} }
if ( if (
user._id !== userId && user._id !== userId &&
userPermissions & UserPermission.SendMessage userPermissions & UserPermission.SendMessage
) { ) {
generateAction({ generateAction({
action: "message_user", action: "message_user",
user, user,
}); });
} }
for (let i = 0; i < actions.length; i++) { for (let i = 0; i < actions.length; i++) {
// Typescript can't determine that user the actions are linked together correctly let action = actions[i];
if (action) {
generateAction({ generateAction({
action: actions[i], action,
user, user,
} as unknown as Action); } as unknown as Action);
} }