'Fix' distinct alias typeorm issue
This commit is contained in:
parent
f44f5d7ac2
commit
c3591a8233
19
.vscode/launch.json
vendored
Normal file
19
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Launch Program",
|
||||||
|
"skipFiles": [
|
||||||
|
"<node_internals>/**"
|
||||||
|
],
|
||||||
|
"program": "${workspaceFolder}/src/bundle/start.ts",
|
||||||
|
"outFiles": [ "${workspaceFolder}/dist/**/*.js" ],
|
||||||
|
"preLaunchTask": "tsc: build - tsconfig.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -245,11 +245,10 @@ export class Channel extends BaseClass {
|
|||||||
|
|
||||||
static async createDMChannel(recipients: string[], creator_user_id: string, name?: string) {
|
static async createDMChannel(recipients: string[], creator_user_id: string, name?: string) {
|
||||||
recipients = recipients.unique().filter((x) => x !== creator_user_id);
|
recipients = recipients.unique().filter((x) => x !== creator_user_id);
|
||||||
//@ts-ignore some typeorm typescript issue
|
|
||||||
const otherRecipientsUsers = await User.find({ where: recipients.map((x) => ({ id: x })) });
|
|
||||||
|
|
||||||
// TODO: check config for max number of recipients
|
// TODO: check config for max number of recipients
|
||||||
/** if you want to disallow note to self channels, uncomment the conditional below
|
/** if you want to disallow note to self channels, uncomment the conditional below
|
||||||
|
|
||||||
|
const otherRecipientsUsers = await User.find({ where: recipients.map((x) => ({ id: x })) });
|
||||||
if (otherRecipientsUsers.length !== recipients.length) {
|
if (otherRecipientsUsers.length !== recipients.length) {
|
||||||
throw new HTTPError("Recipient/s not found");
|
throw new HTTPError("Recipient/s not found");
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,6 @@ export class Member extends BaseClassWithoutId {
|
|||||||
|
|
||||||
static async addRole(user_id: string, guild_id: string, role_id: string) {
|
static async addRole(user_id: string, guild_id: string, role_id: string) {
|
||||||
const [member, role] = await Promise.all([
|
const [member, role] = await Promise.all([
|
||||||
// @ts-ignore
|
|
||||||
Member.findOneOrFail({
|
Member.findOneOrFail({
|
||||||
where: { id: user_id, guild_id },
|
where: { id: user_id, guild_id },
|
||||||
relations: ["user", "roles"], // we don't want to load the role objects just the ids
|
relations: ["user", "roles"], // we don't want to load the role objects just the ids
|
||||||
@ -192,7 +191,6 @@ export class Member extends BaseClassWithoutId {
|
|||||||
|
|
||||||
static async removeRole(user_id: string, guild_id: string, role_id: string) {
|
static async removeRole(user_id: string, guild_id: string, role_id: string) {
|
||||||
const [member] = await Promise.all([
|
const [member] = await Promise.all([
|
||||||
// @ts-ignore
|
|
||||||
Member.findOneOrFail({
|
Member.findOneOrFail({
|
||||||
where: { id: user_id, guild_id },
|
where: { id: user_id, guild_id },
|
||||||
relations: ["user", "roles"], // we don't want to load the role objects just the ids
|
relations: ["user", "roles"], // we don't want to load the role objects just the ids
|
||||||
|
@ -244,12 +244,12 @@ export async function getPermission(
|
|||||||
member = await Member.findOneOrFail({
|
member = await Member.findOneOrFail({
|
||||||
where: { guild_id, id: user_id },
|
where: { guild_id, id: user_id },
|
||||||
relations: ["roles", ...(opts.member_relations || [])],
|
relations: ["roles", ...(opts.member_relations || [])],
|
||||||
select: [
|
// select: [
|
||||||
"id",
|
// "id", // TODO: Bug in typeorm? adding these selects breaks the query.
|
||||||
"roles",
|
// "roles",
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
...(opts.member_select || []),
|
// ...(opts.member_select || []),
|
||||||
],
|
// ],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user