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,14 +580,16 @@ 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 = ["remove_friend", "block_user"]; actions = [
!user.bot && "remove_friend",
"block_user",
];
break; break;
case "Incoming": case "Incoming":
actions = [ actions = [
@ -597,7 +599,10 @@ export default function ContextMenus() {
]; ];
break; break;
case "Outgoing": case "Outgoing":
actions = ["cancel_friend", "block_user"]; actions = [
!user.bot && "cancel_friend",
"block_user",
];
break; break;
case "Blocked": case "Blocked":
actions = ["unblock_user"]; actions = ["unblock_user"];
@ -607,13 +612,13 @@ export default function ContextMenus() {
break; break;
case "None": case "None":
default: default:
if ( if ((user.flags && 2) || (user.flags && 4)) {
(user.flags && 2) ||
(user.flags && 4)
) {
actions = ["block_user"]; actions = ["block_user"];
} else { } else {
actions = ["add_friend", "block_user"]; actions = [
!user.bot && "add_friend",
"block_user",
];
} }
} }
@ -635,9 +640,10 @@ export default function ContextMenus() {
} }
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);
} }