mirror of
https://github.com/spacebarchat/server.git
synced 2026-05-23 12:35:14 +00:00
🐛 fix findOneAndUpdate
This commit is contained in:
@@ -151,7 +151,8 @@ export async function addRole(user_id: string, guild_id: string, role_id: string
|
||||
id: user_id,
|
||||
guild_id: guild_id
|
||||
},
|
||||
{ $push: { roles: role_id } }
|
||||
{ $push: { roles: role_id } },
|
||||
{ new: true }
|
||||
).exec();
|
||||
|
||||
if (!memberObj) throw new HTTPError("Member not found", 404);
|
||||
@@ -178,7 +179,8 @@ export async function removeRole(user_id: string, guild_id: string, role_id: str
|
||||
id: user_id,
|
||||
guild_id: guild_id
|
||||
},
|
||||
{ $pull: { roles: role_id } }
|
||||
{ $pull: { roles: role_id } },
|
||||
{ new: true }
|
||||
).exec();
|
||||
|
||||
if (!memberObj) throw new HTTPError("Member not found", 404);
|
||||
@@ -197,13 +199,13 @@ export async function removeRole(user_id: string, guild_id: string, role_id: str
|
||||
export async function changeNickname(user_id: string, guild_id: string, nickname: string) {
|
||||
const user = await getPublicUser(user_id);
|
||||
|
||||
|
||||
var memberObj = await MemberModel.findOneAndUpdate(
|
||||
{
|
||||
id: user_id,
|
||||
guild_id: guild_id
|
||||
},
|
||||
{ nick: nickname }
|
||||
{ nick: nickname },
|
||||
{ new: true }
|
||||
).exec();
|
||||
|
||||
if (!memberObj) throw new HTTPError("Member not found", 404);
|
||||
|
||||
@@ -157,7 +157,6 @@ export async function postHandleMessage(message: Message) {
|
||||
await Promise.all([
|
||||
emitEvent({
|
||||
event: "MESSAGE_UPDATE",
|
||||
guild_id: message.guild_id,
|
||||
channel_id: message.channel_id,
|
||||
data
|
||||
} as MessageUpdateEvent),
|
||||
@@ -172,7 +171,7 @@ export async function sendMessage(opts: Partial<Message>) {
|
||||
await new MessageModel(message).populate({ path: "member", select: PublicMemberProjection }).populate("referenced_message").save()
|
||||
);
|
||||
|
||||
await emitEvent({ event: "MESSAGE_CREATE", channel_id: opts.channel_id, data, guild_id: message.guild_id } as MessageCreateEvent);
|
||||
await emitEvent({ event: "MESSAGE_CREATE", channel_id: opts.channel_id, data } as MessageCreateEvent);
|
||||
|
||||
postHandleMessage(data).catch((e) => {}); // no await as it shouldnt block the message send function and silently catch error
|
||||
|
||||
|
||||
Reference in New Issue
Block a user