Prettier
This commit is contained in:
@@ -17,7 +17,7 @@ import {
|
||||
RegisterConfiguration,
|
||||
SecurityConfiguration,
|
||||
SentryConfiguration,
|
||||
TemplateConfiguration
|
||||
TemplateConfiguration,
|
||||
} from "../config";
|
||||
|
||||
export class ConfigValue {
|
||||
@@ -40,4 +40,4 @@ export class ConfigValue {
|
||||
sentry: SentryConfiguration = new SentryConfiguration();
|
||||
defaults: DefaultsConfiguration = new DefaultsConfiguration();
|
||||
external: ExternalTokensConfiguration = new ExternalTokensConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,4 +2,4 @@ export class ApiConfiguration {
|
||||
defaultVersion: string = "9";
|
||||
activeVersions: string[] = ["6", "7", "8", "9"];
|
||||
useFosscordEnhancements: boolean = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,4 @@ export class CdnConfiguration extends EndpointConfiguration {
|
||||
|
||||
endpointPublic: string | null = "http://localhost:3001";
|
||||
endpointPrivate: string | null = "http://localhost:3001";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ClientReleaseConfiguration } from ".";
|
||||
|
||||
export class ClientConfiguration {
|
||||
releases: ClientReleaseConfiguration = new ClientReleaseConfiguration();
|
||||
useTestClient: boolean = false;
|
||||
}
|
||||
releases: ClientReleaseConfiguration = new ClientReleaseConfiguration();
|
||||
useTestClient: boolean = false;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { GuildDefaults, UserDefaults } from ".";
|
||||
|
||||
export class DefaultsConfiguration {
|
||||
guild: GuildDefaults = new GuildDefaults();
|
||||
user: UserDefaults = new UserDefaults();
|
||||
}
|
||||
guild: GuildDefaults = new GuildDefaults();
|
||||
user: UserDefaults = new UserDefaults();
|
||||
}
|
||||
|
||||
@@ -2,4 +2,4 @@ export class EndpointConfiguration {
|
||||
endpointClient: string | null = null;
|
||||
endpointPrivate: string | null = null;
|
||||
endpointPublic: string | null = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export class ExternalTokensConfiguration {
|
||||
twitter: string | null = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,12 @@ import { Snowflake } from "@fosscord/util";
|
||||
|
||||
export class GeneralConfiguration {
|
||||
instanceName: string = "Fosscord Instance";
|
||||
instanceDescription: string | null = "This is a Fosscord instance made in the pre-release days";
|
||||
instanceDescription: string | null =
|
||||
"This is a Fosscord instance made in the pre-release days";
|
||||
frontPage: string | null = null;
|
||||
tosPage: string | null = null;
|
||||
correspondenceEmail: string | null = null;
|
||||
correspondenceUserID: string | null = null;
|
||||
image: string | null = null;
|
||||
instanceId: string = Snowflake.generate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export class GifConfiguration {
|
||||
enabled: boolean = true;
|
||||
provider: "tenor" = "tenor"; // more coming soon
|
||||
apiKey?: string = "LIVDSRZULELA";
|
||||
}
|
||||
enabled: boolean = true;
|
||||
provider: "tenor" = "tenor"; // more coming soon
|
||||
apiKey?: string = "LIVDSRZULELA";
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { DiscoveryConfiguration, AutoJoinConfiguration } from ".";
|
||||
|
||||
export class GuildConfiguration {
|
||||
discovery: DiscoveryConfiguration = new DiscoveryConfiguration();
|
||||
autoJoin: AutoJoinConfiguration = new AutoJoinConfiguration();
|
||||
discovery: DiscoveryConfiguration = new DiscoveryConfiguration();
|
||||
autoJoin: AutoJoinConfiguration = new AutoJoinConfiguration();
|
||||
defaultFeatures: string[] = [];
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { KafkaBroker } from ".";
|
||||
|
||||
export class KafkaConfiguration {
|
||||
brokers: KafkaBroker[] | null = null;
|
||||
}
|
||||
brokers: KafkaBroker[] | null = null;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
import { ChannelLimits, GlobalRateLimits, GuildLimits, MessageLimits, RateLimits, UserLimits } from ".";
|
||||
import {
|
||||
ChannelLimits,
|
||||
GlobalRateLimits,
|
||||
GuildLimits,
|
||||
MessageLimits,
|
||||
RateLimits,
|
||||
UserLimits,
|
||||
} from ".";
|
||||
|
||||
export class LimitsConfiguration {
|
||||
user: UserLimits = new UserLimits();
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export class LoginConfiguration {
|
||||
requireCaptcha: boolean = false;
|
||||
}
|
||||
requireCaptcha: boolean = false;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export class MetricsConfiguration {
|
||||
timeout: number = 30000;
|
||||
}
|
||||
timeout: number = 30000;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export class RabbitMQConfiguration {
|
||||
host: string | null = null;
|
||||
}
|
||||
host: string | null = null;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { Region } from ".";
|
||||
|
||||
export class RegionConfiguration {
|
||||
default: string = "fosscord";
|
||||
useDefaultAsOptimal: boolean = true;
|
||||
available: Region[] = [
|
||||
{
|
||||
id: "fosscord",
|
||||
name: "Fosscord",
|
||||
endpoint: "127.0.0.1:3004",
|
||||
vip: false,
|
||||
custom: false,
|
||||
deprecated: false,
|
||||
},
|
||||
];
|
||||
}
|
||||
default: string = "fosscord";
|
||||
useDefaultAsOptimal: boolean = true;
|
||||
available: Region[] = [
|
||||
{
|
||||
id: "fosscord",
|
||||
name: "Fosscord",
|
||||
endpoint: "127.0.0.1:3004",
|
||||
vip: false,
|
||||
custom: false,
|
||||
deprecated: false,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
import { DateOfBirthConfiguration, EmailConfiguration, PasswordConfiguration } from ".";
|
||||
import {
|
||||
DateOfBirthConfiguration,
|
||||
EmailConfiguration,
|
||||
PasswordConfiguration,
|
||||
} from ".";
|
||||
|
||||
export class RegisterConfiguration {
|
||||
email: EmailConfiguration = new EmailConfiguration();
|
||||
dateOfBirth: DateOfBirthConfiguration = new DateOfBirthConfiguration();
|
||||
password: PasswordConfiguration = new PasswordConfiguration();
|
||||
disabled: boolean = false;
|
||||
requireCaptcha: boolean = true;
|
||||
requireInvite: boolean = false;
|
||||
guestsRequireInvite: boolean = true;
|
||||
allowNewRegistration: boolean = true;
|
||||
allowMultipleAccounts: boolean = true;
|
||||
blockProxies: boolean = true;
|
||||
incrementingDiscriminators: boolean = false; // random otherwise
|
||||
defaultRights: string = "30644591655940"; // See `npm run generate:rights`
|
||||
email: EmailConfiguration = new EmailConfiguration();
|
||||
dateOfBirth: DateOfBirthConfiguration = new DateOfBirthConfiguration();
|
||||
password: PasswordConfiguration = new PasswordConfiguration();
|
||||
disabled: boolean = false;
|
||||
requireCaptcha: boolean = true;
|
||||
requireInvite: boolean = false;
|
||||
guestsRequireInvite: boolean = true;
|
||||
allowNewRegistration: boolean = true;
|
||||
allowMultipleAccounts: boolean = true;
|
||||
blockProxies: boolean = true;
|
||||
incrementingDiscriminators: boolean = false; // random otherwise
|
||||
defaultRights: string = "30644591655940"; // See `npm run generate:rights`
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ export class SecurityConfiguration {
|
||||
// X-Forwarded-For for nginx/reverse proxies
|
||||
// CF-Connecting-IP for cloudflare
|
||||
forwadedFor: string | null = null;
|
||||
ipdataApiKey: string | null = "eca677b284b3bac29eb72f5e496aa9047f26543605efe99ff2ce35c9";
|
||||
ipdataApiKey: string | null =
|
||||
"eca677b284b3bac29eb72f5e496aa9047f26543605efe99ff2ce35c9";
|
||||
mfaBackupCodeCount: number = 10;
|
||||
statsWorldReadable: boolean = true;
|
||||
defaultRegistrationTokenExpiration: number = 1000 * 60 * 60 * 24 * 7; //1 week
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { hostname } from "os";
|
||||
|
||||
export class SentryConfiguration {
|
||||
enabled: boolean = false;
|
||||
endpoint: string = "https://05e8e3d005f34b7d97e920ae5870a5e5@sentry.thearcanebrony.net/6";
|
||||
traceSampleRate: number = 1.0;
|
||||
environment: string = hostname();
|
||||
}
|
||||
enabled: boolean = false;
|
||||
endpoint: string =
|
||||
"https://05e8e3d005f34b7d97e920ae5870a5e5@sentry.thearcanebrony.net/6";
|
||||
traceSampleRate: number = 1.0;
|
||||
environment: string = hostname();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export class TemplateConfiguration {
|
||||
enabled: boolean = true;
|
||||
allowTemplateCreation: boolean = true;
|
||||
allowDiscordTemplates: boolean = true;
|
||||
allowRaws: boolean = true;
|
||||
}
|
||||
enabled: boolean = true;
|
||||
allowTemplateCreation: boolean = true;
|
||||
allowDiscordTemplates: boolean = true;
|
||||
allowRaws: boolean = true;
|
||||
}
|
||||
|
||||
@@ -17,4 +17,4 @@ export * from "./RegisterConfiguration";
|
||||
export * from "./SecurityConfiguration";
|
||||
export * from "./SentryConfiguration";
|
||||
export * from "./TemplateConfiguration";
|
||||
export * from "./subconfigurations";
|
||||
export * from "./subconfigurations";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export class ClientReleaseConfiguration {
|
||||
useLocalRelease: boolean = true; //TODO
|
||||
upstreamVersion: string = "0.0.264";
|
||||
}
|
||||
useLocalRelease: boolean = true; //TODO
|
||||
upstreamVersion: string = "0.0.264";
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export class GuildDefaults {
|
||||
maxPresences: number = 250000;
|
||||
maxVideoChannelUsers: number = 200;
|
||||
afkTimeout: number = 300;
|
||||
defaultMessageNotifications: number = 1;
|
||||
explicitContentFilter: number = 0;
|
||||
}
|
||||
maxPresences: number = 250000;
|
||||
maxVideoChannelUsers: number = 200;
|
||||
afkTimeout: number = 300;
|
||||
defaultMessageNotifications: number = 1;
|
||||
explicitContentFilter: number = 0;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export class UserDefaults {
|
||||
premium: boolean = true;
|
||||
premiumType: number = 2;
|
||||
verified: boolean = true;
|
||||
}
|
||||
premium: boolean = true;
|
||||
premiumType: number = 2;
|
||||
verified: boolean = true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export class AutoJoinConfiguration {
|
||||
enabled: boolean = true;
|
||||
guilds: string[] = [];
|
||||
canLeave: boolean = true;
|
||||
}
|
||||
enabled: boolean = true;
|
||||
guilds: string[] = [];
|
||||
canLeave: boolean = true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export class DiscoveryConfiguration {
|
||||
showAllGuilds: boolean = false;
|
||||
useRecommendation: boolean = false; // TODO: Recommendation, privacy concern?
|
||||
offset: number = 0;
|
||||
limit: number = 24;
|
||||
}
|
||||
showAllGuilds: boolean = false;
|
||||
useRecommendation: boolean = false; // TODO: Recommendation, privacy concern?
|
||||
offset: number = 0;
|
||||
limit: number = 24;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export interface KafkaBroker {
|
||||
ip: string;
|
||||
port: number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export class ChannelLimits {
|
||||
maxPins: number = 500;
|
||||
maxTopic: number = 1024;
|
||||
maxWebhooks: number = 100;
|
||||
}
|
||||
maxPins: number = 500;
|
||||
maxTopic: number = 1024;
|
||||
maxWebhooks: number = 100;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
export class GlobalRateLimits {
|
||||
register: GlobalRateLimit = { limit: 25, window: 60 * 60 * 1000, enabled: true };
|
||||
sendMessage: GlobalRateLimit = { limit: 200, window: 60 * 1000, enabled: true };
|
||||
register: GlobalRateLimit = {
|
||||
limit: 25,
|
||||
window: 60 * 60 * 1000,
|
||||
enabled: true,
|
||||
};
|
||||
sendMessage: GlobalRateLimit = {
|
||||
limit: 200,
|
||||
window: 60 * 1000,
|
||||
enabled: true,
|
||||
};
|
||||
}
|
||||
|
||||
export class GlobalRateLimit {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export class GuildLimits {
|
||||
maxRoles: number = 1000;
|
||||
maxEmojis: number = 2000;
|
||||
maxMembers: number = 25000000;
|
||||
maxChannels: number = 65535;
|
||||
maxChannelsInCategory: number = 65535;
|
||||
}
|
||||
maxRoles: number = 1000;
|
||||
maxEmojis: number = 2000;
|
||||
maxMembers: number = 25000000;
|
||||
maxChannels: number = 65535;
|
||||
maxChannelsInCategory: number = 65535;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
export class MessageLimits {
|
||||
maxCharacters: number = 1048576;
|
||||
maxTTSCharacters: number = 160;
|
||||
maxReactions: number = 2048;
|
||||
maxAttachmentSize: number = 1024 * 1024 * 1024;
|
||||
maxBulkDelete: number = 1000;
|
||||
maxEmbedDownloadSize: number = 1024 * 1024 * 5;
|
||||
}
|
||||
maxCharacters: number = 1048576;
|
||||
maxTTSCharacters: number = 160;
|
||||
maxReactions: number = 2048;
|
||||
maxAttachmentSize: number = 1024 * 1024 * 1024;
|
||||
maxBulkDelete: number = 1000;
|
||||
maxEmbedDownloadSize: number = 1024 * 1024 * 5;
|
||||
}
|
||||
|
||||
@@ -4,15 +4,15 @@ export class RateLimits {
|
||||
enabled: boolean = false;
|
||||
ip: Omit<RateLimitOptions, "bot_count"> = {
|
||||
count: 500,
|
||||
window: 5
|
||||
window: 5,
|
||||
};
|
||||
global: RateLimitOptions = {
|
||||
count: 250,
|
||||
window: 5
|
||||
window: 5,
|
||||
};
|
||||
error: RateLimitOptions = {
|
||||
count: 10,
|
||||
window: 5
|
||||
window: 5,
|
||||
};
|
||||
routes: RouteRateLimit = new RouteRateLimit();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export class UserLimits {
|
||||
maxGuilds: number = 1048576;
|
||||
maxUsername: number = 127;
|
||||
maxFriends: number = 5000;
|
||||
}
|
||||
maxGuilds: number = 1048576;
|
||||
maxUsername: number = 127;
|
||||
maxFriends: number = 5000;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { RateLimitOptions } from "./RateLimitOptions";
|
||||
|
||||
export class AuthRateLimit {
|
||||
login: RateLimitOptions = {
|
||||
count: 5,
|
||||
window: 60
|
||||
};
|
||||
register: RateLimitOptions = {
|
||||
count: 2,
|
||||
window: 60 * 60 * 12
|
||||
};
|
||||
}
|
||||
login: RateLimitOptions = {
|
||||
count: 5,
|
||||
window: 60,
|
||||
};
|
||||
register: RateLimitOptions = {
|
||||
count: 2,
|
||||
window: 60 * 60 * 12,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@ export interface RateLimitOptions {
|
||||
count: number;
|
||||
window: number;
|
||||
onyIp?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,15 +4,15 @@ import { RateLimitOptions } from "./RateLimitOptions";
|
||||
export class RouteRateLimit {
|
||||
guild: RateLimitOptions = {
|
||||
count: 5,
|
||||
window: 5
|
||||
window: 5,
|
||||
};
|
||||
webhook: RateLimitOptions = {
|
||||
count: 10,
|
||||
window: 5
|
||||
window: 5,
|
||||
};
|
||||
channel: RateLimitOptions = {
|
||||
count: 10,
|
||||
window: 5
|
||||
window: 5,
|
||||
};
|
||||
auth: AuthRateLimit = new AuthRateLimit();
|
||||
// TODO: rate limit configuration for all routes
|
||||
|
||||
@@ -9,4 +9,4 @@ export interface Region {
|
||||
vip: boolean;
|
||||
custom: boolean;
|
||||
deprecated: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export class DateOfBirthConfiguration {
|
||||
required: boolean = true;
|
||||
minimum: number = 13; // in years
|
||||
}
|
||||
required: boolean = true;
|
||||
minimum: number = 13; // in years
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export class EmailConfiguration {
|
||||
required: boolean = false;
|
||||
allowlist: boolean = false;
|
||||
blocklist: boolean = true;
|
||||
domains: string[] = [];// TODO: efficiently save domain blocklist in database
|
||||
// domains: fs.readFileSync(__dirname + "/blockedEmailDomains.txt", { encoding: "utf8" }).split("\n"),
|
||||
}
|
||||
required: boolean = false;
|
||||
allowlist: boolean = false;
|
||||
blocklist: boolean = true;
|
||||
domains: string[] = []; // TODO: efficiently save domain blocklist in database
|
||||
// domains: fs.readFileSync(__dirname + "/blockedEmailDomains.txt", { encoding: "utf8" }).split("\n"),
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export class PasswordConfiguration {
|
||||
required: boolean = false;
|
||||
minLength: number = 8;
|
||||
minNumbers: number = 2;
|
||||
minUpperCase: number =2;
|
||||
minSymbols: number = 0;
|
||||
}
|
||||
required: boolean = false;
|
||||
minLength: number = 8;
|
||||
minNumbers: number = 2;
|
||||
minUpperCase: number = 2;
|
||||
minSymbols: number = 0;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export class CaptchaConfiguration {
|
||||
enabled: boolean = false;
|
||||
service: "recaptcha" | "hcaptcha" | null = null; // TODO: hcaptcha, custom
|
||||
sitekey: string | null = null;
|
||||
secret: string | null = null;
|
||||
}
|
||||
enabled: boolean = false;
|
||||
service: "recaptcha" | "hcaptcha" | null = null; // TODO: hcaptcha, custom
|
||||
sitekey: string | null = null;
|
||||
secret: string | null = null;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export class TwoFactorConfiguration {
|
||||
generateBackupCodes: boolean = true;
|
||||
}
|
||||
generateBackupCodes: boolean = true;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
import { Column, Entity, JoinColumn, ManyToOne, OneToOne, RelationId } from "typeorm";
|
||||
import {
|
||||
Column,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
OneToOne,
|
||||
RelationId,
|
||||
} from "typeorm";
|
||||
import { BaseClass } from "./BaseClass";
|
||||
import { Guild } from "./Guild";
|
||||
import { Team } from "./Team";
|
||||
@@ -8,78 +15,78 @@ import { User } from "./User";
|
||||
export class Application extends BaseClass {
|
||||
@Column()
|
||||
name: string;
|
||||
|
||||
|
||||
@Column({ nullable: true })
|
||||
icon?: string;
|
||||
|
||||
|
||||
@Column({ nullable: true })
|
||||
description: string;
|
||||
|
||||
|
||||
@Column({ nullable: true })
|
||||
summary: string = "";
|
||||
|
||||
|
||||
@Column({ type: "simple-json", nullable: true })
|
||||
type?: any;
|
||||
|
||||
|
||||
@Column()
|
||||
hook: boolean = true;
|
||||
|
||||
|
||||
@Column()
|
||||
bot_public?: boolean = true;
|
||||
|
||||
|
||||
@Column()
|
||||
bot_require_code_grant?: boolean = false;
|
||||
|
||||
|
||||
@Column()
|
||||
verify_key: string;
|
||||
|
||||
|
||||
@JoinColumn({ name: "owner_id" })
|
||||
@ManyToOne(() => User)
|
||||
owner: User;
|
||||
|
||||
|
||||
// TODO: enum this? https://discord.com/developers/docs/resources/application#application-object-application-flags
|
||||
@Column()
|
||||
flags: number = 0;
|
||||
|
||||
|
||||
@Column({ type: "simple-array", nullable: true })
|
||||
redirect_uris: string[] = [];
|
||||
|
||||
|
||||
@Column({ nullable: true })
|
||||
rpc_application_state: number = 0;
|
||||
|
||||
|
||||
@Column({ nullable: true })
|
||||
store_application_state: number = 1;
|
||||
|
||||
|
||||
@Column({ nullable: true })
|
||||
verification_state: number = 1;
|
||||
|
||||
|
||||
@Column({ nullable: true })
|
||||
interactions_endpoint_url?: string;
|
||||
|
||||
|
||||
@Column({ nullable: true })
|
||||
integration_public: boolean = true;
|
||||
|
||||
|
||||
@Column({ nullable: true })
|
||||
integration_require_code_grant: boolean = false;
|
||||
|
||||
|
||||
@Column({ nullable: true })
|
||||
discoverability_state: number = 1;
|
||||
|
||||
|
||||
@Column({ nullable: true })
|
||||
discovery_eligibility_flags: number = 2240;
|
||||
|
||||
|
||||
@JoinColumn({ name: "bot_user_id" })
|
||||
@OneToOne(() => User)
|
||||
bot?: User;
|
||||
|
||||
|
||||
@Column({ type: "simple-array", nullable: true })
|
||||
tags?: string[];
|
||||
|
||||
|
||||
@Column({ nullable: true })
|
||||
cover_image?: string; // the application's default rich presence invite cover image hash
|
||||
|
||||
|
||||
@Column({ type: "simple-json", nullable: true })
|
||||
install_params?: {scopes: string[], permissions: string};
|
||||
install_params?: { scopes: string[]; permissions: string };
|
||||
|
||||
@Column({ nullable: true })
|
||||
terms_of_service_url?: string;
|
||||
@@ -91,7 +98,7 @@ export class Application extends BaseClass {
|
||||
|
||||
//@Column({ type: "simple-array", nullable: true })
|
||||
//rpc_origins?: string[];
|
||||
|
||||
|
||||
//@JoinColumn({ name: "guild_id" })
|
||||
//@ManyToOne(() => Guild)
|
||||
//guild?: Guild; // if this application is a game sold, this field will be the guild to which it has been linked
|
||||
@@ -105,11 +112,10 @@ export class Application extends BaseClass {
|
||||
@JoinColumn({ name: "team_id" })
|
||||
@ManyToOne(() => Team, {
|
||||
onDelete: "CASCADE",
|
||||
nullable: true
|
||||
nullable: true,
|
||||
})
|
||||
team?: Team;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export interface ApplicationCommand {
|
||||
id: string;
|
||||
|
||||
@@ -209,7 +209,10 @@ export class Channel extends BaseClass {
|
||||
);
|
||||
|
||||
// Categories skip these checks on discord.com
|
||||
if (channel.type !== ChannelType.GUILD_CATEGORY || guild.features.includes("IRC_LIKE_CATEGORY_NAMES")) {
|
||||
if (
|
||||
channel.type !== ChannelType.GUILD_CATEGORY ||
|
||||
guild.features.includes("IRC_LIKE_CATEGORY_NAMES")
|
||||
) {
|
||||
if (channel.name.includes(" "))
|
||||
throw new HTTPError(
|
||||
"Channel name cannot include invalid characters",
|
||||
@@ -286,10 +289,10 @@ export class Channel extends BaseClass {
|
||||
Channel.create(channel).save(),
|
||||
!opts?.skipEventEmit
|
||||
? emitEvent({
|
||||
event: "CHANNEL_CREATE",
|
||||
data: channel,
|
||||
guild_id: channel.guild_id,
|
||||
} as ChannelCreateEvent)
|
||||
event: "CHANNEL_CREATE",
|
||||
data: channel,
|
||||
guild_id: channel.guild_id,
|
||||
} as ChannelCreateEvent)
|
||||
: Promise.resolve(),
|
||||
]);
|
||||
|
||||
|
||||
@@ -9,4 +9,4 @@ export class EmbedCache extends BaseClass {
|
||||
|
||||
@Column({ type: "simple-json" })
|
||||
embed: Embed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,8 @@ export class Guild extends BaseClass {
|
||||
banner?: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
default_message_notifications?: number = Config.get().defaults.guild.defaultMessageNotifications;
|
||||
default_message_notifications?: number =
|
||||
Config.get().defaults.guild.defaultMessageNotifications;
|
||||
|
||||
@Column({ nullable: true })
|
||||
description?: string;
|
||||
@@ -88,7 +89,8 @@ export class Guild extends BaseClass {
|
||||
discovery_splash?: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
explicit_content_filter?: number = Config.get().defaults.guild.explicitContentFilter;
|
||||
explicit_content_filter?: number =
|
||||
Config.get().defaults.guild.explicitContentFilter;
|
||||
|
||||
@Column({ type: "simple-array" })
|
||||
features: string[] = Config.get().guild.defaultFeatures || []; //TODO use enum
|
||||
@@ -110,7 +112,8 @@ export class Guild extends BaseClass {
|
||||
max_presences?: number = Config.get().defaults.guild.maxPresences;
|
||||
|
||||
@Column({ nullable: true })
|
||||
max_video_channel_users?: number = Config.get().defaults.guild.maxVideoChannelUsers;
|
||||
max_video_channel_users?: number =
|
||||
Config.get().defaults.guild.maxVideoChannelUsers;
|
||||
|
||||
@Column({ nullable: true })
|
||||
member_count?: number;
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
import {
|
||||
Column,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
RelationId,
|
||||
} from "typeorm";
|
||||
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
||||
import { Member } from "./Member";
|
||||
import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass";
|
||||
import { Channel } from "./Channel";
|
||||
@@ -62,7 +56,7 @@ export class Invite extends BaseClassWithoutId {
|
||||
|
||||
@JoinColumn({ name: "inviter_id" })
|
||||
@ManyToOne(() => User, {
|
||||
onDelete: "CASCADE"
|
||||
onDelete: "CASCADE",
|
||||
})
|
||||
inviter: User;
|
||||
|
||||
|
||||
@@ -125,9 +125,9 @@ export class Member extends BaseClassWithoutId {
|
||||
|
||||
@Column()
|
||||
bio: string;
|
||||
|
||||
|
||||
@Column({ nullable: true, type: "simple-array" })
|
||||
theme_colors?: number[]; // TODO: Separate `User` and `UserProfile` models
|
||||
theme_colors?: number[]; // TODO: Separate `User` and `UserProfile` models
|
||||
|
||||
@Column({ nullable: true })
|
||||
pronouns?: string;
|
||||
@@ -309,9 +309,9 @@ export class Member extends BaseClassWithoutId {
|
||||
guild_id,
|
||||
user: {
|
||||
sessions: {
|
||||
status: Not("invisible" as "invisible") // lol typescript?
|
||||
}
|
||||
}
|
||||
status: Not("invisible" as "invisible"), // lol typescript?
|
||||
},
|
||||
},
|
||||
},
|
||||
take: 10,
|
||||
});
|
||||
@@ -380,7 +380,7 @@ export class Member extends BaseClassWithoutId {
|
||||
stage_instances: [],
|
||||
threads: [],
|
||||
embedded_activities: [],
|
||||
voice_states: guild.voice_states
|
||||
voice_states: guild.voice_states,
|
||||
},
|
||||
user_id,
|
||||
} as GuildCreateEvent),
|
||||
|
||||
+12
-19
@@ -15,13 +15,7 @@ import { ConnectedAccount } from "./ConnectedAccount";
|
||||
import { Member } from "./Member";
|
||||
import { UserSettings } from "./UserSettings";
|
||||
import { Session } from "./Session";
|
||||
import {
|
||||
Config,
|
||||
FieldErrors,
|
||||
Snowflake,
|
||||
trimSpecial,
|
||||
adjustEmail,
|
||||
} from "..";
|
||||
import { Config, FieldErrors, Snowflake, trimSpecial, adjustEmail } from "..";
|
||||
|
||||
export enum PublicUserEnum {
|
||||
username,
|
||||
@@ -68,7 +62,7 @@ export const PrivateUserProjection = [
|
||||
// Private user data that should never get sent to the client
|
||||
export type PublicUser = Pick<User, PublicUserKeys>;
|
||||
|
||||
export interface UserPublic extends Pick<User, PublicUserKeys> { }
|
||||
export interface UserPublic extends Pick<User, PublicUserKeys> {}
|
||||
|
||||
export interface UserPrivate extends Pick<User, PrivateUserKeys> {
|
||||
locale: string;
|
||||
@@ -92,7 +86,7 @@ export class User extends BaseClass {
|
||||
banner?: string; // hash of the user banner
|
||||
|
||||
@Column({ nullable: true, type: "simple-array" })
|
||||
theme_colors?: number[]; // TODO: Separate `User` and `UserProfile` models
|
||||
theme_colors?: number[]; // TODO: Separate `User` and `UserProfile` models
|
||||
|
||||
@Column({ nullable: true })
|
||||
pronouns?: string;
|
||||
@@ -140,7 +134,7 @@ export class User extends BaseClass {
|
||||
premium_since: Date = new Date(); // premium date
|
||||
|
||||
@Column({ select: false })
|
||||
verified: boolean = true; // email is verified
|
||||
verified: boolean = true; // email is verified
|
||||
|
||||
@Column()
|
||||
disabled: boolean = false; // if the account is disabled
|
||||
@@ -203,7 +197,7 @@ export class User extends BaseClass {
|
||||
@OneToOne(() => UserSettings, {
|
||||
cascade: true,
|
||||
orphanedRowAction: "delete",
|
||||
eager: false
|
||||
eager: false,
|
||||
})
|
||||
@JoinColumn()
|
||||
settings: UserSettings;
|
||||
@@ -270,7 +264,9 @@ export class User extends BaseClass {
|
||||
});
|
||||
}
|
||||
|
||||
public static async generateDiscriminator(username: string): Promise<string | undefined> {
|
||||
public static async generateDiscriminator(
|
||||
username: string,
|
||||
): Promise<string | undefined> {
|
||||
if (Config.get().register.incrementingDiscriminators) {
|
||||
// discriminator will be incrementally generated
|
||||
|
||||
@@ -322,7 +318,7 @@ export class User extends BaseClass {
|
||||
password?: string;
|
||||
email?: string;
|
||||
date_of_birth?: Date; // "2000-04-03"
|
||||
id?: string,
|
||||
id?: string;
|
||||
req?: any;
|
||||
}) {
|
||||
// trim special uf8 control characters -> Backspace, Newline, ...
|
||||
@@ -347,7 +343,7 @@ export class User extends BaseClass {
|
||||
|
||||
const settings = UserSettings.create({
|
||||
locale: language,
|
||||
})
|
||||
});
|
||||
|
||||
const user = User.create({
|
||||
username: username,
|
||||
@@ -367,15 +363,12 @@ export class User extends BaseClass {
|
||||
});
|
||||
|
||||
user.validate();
|
||||
await Promise.all([
|
||||
user.save(),
|
||||
settings.save(),
|
||||
])
|
||||
await Promise.all([user.save(), settings.save()]);
|
||||
|
||||
setImmediate(async () => {
|
||||
if (Config.get().guild.autoJoin.enabled) {
|
||||
for (const guild of Config.get().guild.autoJoin.guilds || []) {
|
||||
await Member.addToGuild(user.id, guild).catch((e) => { });
|
||||
await Member.addToGuild(user.id, guild).catch((e) => {});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+101
-101
@@ -3,117 +3,117 @@ import { BaseClassWithoutId } from "./BaseClass";
|
||||
|
||||
@Entity("user_settings")
|
||||
export class UserSettings extends BaseClassWithoutId {
|
||||
@PrimaryGeneratedColumn()
|
||||
@PrimaryGeneratedColumn()
|
||||
index: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
afk_timeout: number = 3600;
|
||||
afk_timeout: number = 3600;
|
||||
|
||||
@Column({ nullable: true })
|
||||
allow_accessibility_detection: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
animate_emoji: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
animate_stickers: number = 0;
|
||||
|
||||
@Column({ nullable: true })
|
||||
contact_sync_enabled: boolean = false;
|
||||
|
||||
@Column({ nullable: true })
|
||||
convert_emoticons: boolean = false;
|
||||
|
||||
@Column({ nullable: true, type: "simple-json" })
|
||||
custom_status: CustomStatus | null = null;
|
||||
|
||||
@Column({ nullable: true })
|
||||
default_guilds_restricted: boolean = false;
|
||||
|
||||
@Column({ nullable: true })
|
||||
detect_platform_accounts: boolean = false;
|
||||
|
||||
@Column({ nullable: true })
|
||||
developer_mode: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
disable_games_tab: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
enable_tts_command: boolean = false;
|
||||
|
||||
@Column({ nullable: true })
|
||||
explicit_content_filter: number = 0;
|
||||
|
||||
@Column({ nullable: true, type: "simple-json" })
|
||||
friend_source_flags: FriendSourceFlags = { all: true };
|
||||
|
||||
@Column({ nullable: true })
|
||||
gateway_connected: boolean = false;
|
||||
|
||||
@Column({ nullable: true })
|
||||
gif_auto_play: boolean = false;
|
||||
|
||||
@Column({ nullable: true, type: "simple-json" })
|
||||
guild_folders: GuildFolder[] = []; // every top guild is displayed as a "folder"
|
||||
|
||||
@Column({ nullable: true, type: "simple-json" })
|
||||
guild_positions: string[] = []; // guild ids ordered by position
|
||||
|
||||
@Column({ nullable: true })
|
||||
inline_attachment_media: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
inline_embed_media: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
locale: string = "en-US"; // en_US
|
||||
|
||||
@Column({ nullable: true })
|
||||
message_display_compact: boolean = false;
|
||||
|
||||
@Column({ nullable: true })
|
||||
native_phone_integration_enabled: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
render_embeds: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
render_reactions: boolean = true;
|
||||
|
||||
@Column({ nullable: true, type: "simple-json" })
|
||||
restricted_guilds: string[] = [];
|
||||
|
||||
@Column({ nullable: true })
|
||||
show_current_game: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
status: "online" | "offline" | "dnd" | "idle" | "invisible" = "online";
|
||||
|
||||
@Column({ nullable: true })
|
||||
stream_notifications_enabled: boolean = false;
|
||||
|
||||
@Column({ nullable: true })
|
||||
theme: "dark" | "light" = "dark"; // dark
|
||||
|
||||
@Column({ nullable: true })
|
||||
timezone_offset: number = 0; // e.g -60
|
||||
allow_accessibility_detection: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
animate_emoji: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
animate_stickers: number = 0;
|
||||
|
||||
@Column({ nullable: true })
|
||||
contact_sync_enabled: boolean = false;
|
||||
|
||||
@Column({ nullable: true })
|
||||
convert_emoticons: boolean = false;
|
||||
|
||||
@Column({ nullable: true, type: "simple-json" })
|
||||
custom_status: CustomStatus | null = null;
|
||||
|
||||
@Column({ nullable: true })
|
||||
default_guilds_restricted: boolean = false;
|
||||
|
||||
@Column({ nullable: true })
|
||||
detect_platform_accounts: boolean = false;
|
||||
|
||||
@Column({ nullable: true })
|
||||
developer_mode: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
disable_games_tab: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
enable_tts_command: boolean = false;
|
||||
|
||||
@Column({ nullable: true })
|
||||
explicit_content_filter: number = 0;
|
||||
|
||||
@Column({ nullable: true, type: "simple-json" })
|
||||
friend_source_flags: FriendSourceFlags = { all: true };
|
||||
|
||||
@Column({ nullable: true })
|
||||
gateway_connected: boolean = false;
|
||||
|
||||
@Column({ nullable: true })
|
||||
gif_auto_play: boolean = false;
|
||||
|
||||
@Column({ nullable: true, type: "simple-json" })
|
||||
guild_folders: GuildFolder[] = []; // every top guild is displayed as a "folder"
|
||||
|
||||
@Column({ nullable: true, type: "simple-json" })
|
||||
guild_positions: string[] = []; // guild ids ordered by position
|
||||
|
||||
@Column({ nullable: true })
|
||||
inline_attachment_media: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
inline_embed_media: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
locale: string = "en-US"; // en_US
|
||||
|
||||
@Column({ nullable: true })
|
||||
message_display_compact: boolean = false;
|
||||
|
||||
@Column({ nullable: true })
|
||||
native_phone_integration_enabled: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
render_embeds: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
render_reactions: boolean = true;
|
||||
|
||||
@Column({ nullable: true, type: "simple-json" })
|
||||
restricted_guilds: string[] = [];
|
||||
|
||||
@Column({ nullable: true })
|
||||
show_current_game: boolean = true;
|
||||
|
||||
@Column({ nullable: true })
|
||||
status: "online" | "offline" | "dnd" | "idle" | "invisible" = "online";
|
||||
|
||||
@Column({ nullable: true })
|
||||
stream_notifications_enabled: boolean = false;
|
||||
|
||||
@Column({ nullable: true })
|
||||
theme: "dark" | "light" = "dark"; // dark
|
||||
|
||||
@Column({ nullable: true })
|
||||
timezone_offset: number = 0; // e.g -60
|
||||
}
|
||||
|
||||
interface CustomStatus {
|
||||
emoji_id?: string;
|
||||
emoji_name?: string;
|
||||
expires_at?: number;
|
||||
text?: string;
|
||||
emoji_id?: string;
|
||||
emoji_name?: string;
|
||||
expires_at?: number;
|
||||
text?: string;
|
||||
}
|
||||
|
||||
interface GuildFolder {
|
||||
color: number;
|
||||
guild_ids: string[];
|
||||
id: number;
|
||||
name: string;
|
||||
color: number;
|
||||
guild_ids: string[];
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface FriendSourceFlags {
|
||||
all: boolean
|
||||
}
|
||||
interface FriendSourceFlags {
|
||||
all: boolean;
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ import { BaseEntity, Column, Entity, PrimaryColumn } from "typeorm";
|
||||
export class ValidRegistrationToken extends BaseEntity {
|
||||
@PrimaryColumn()
|
||||
token: string;
|
||||
|
||||
|
||||
@Column()
|
||||
created_at: Date = new Date();
|
||||
|
||||
@Column()
|
||||
expires_at: Date;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,4 +33,4 @@ export * from "./User";
|
||||
export * from "./UserSettings";
|
||||
export * from "./ValidRegistrationTokens";
|
||||
export * from "./VoiceState";
|
||||
export * from "./Webhook";
|
||||
export * from "./Webhook";
|
||||
|
||||
+1
-1
@@ -6,4 +6,4 @@ export * from "./entities/index";
|
||||
export * from "./dtos/index";
|
||||
export * from "./schemas";
|
||||
export * from "./imports";
|
||||
export * from "./config"
|
||||
export * from "./config";
|
||||
|
||||
@@ -81,9 +81,9 @@ export interface ReadyEventData {
|
||||
number,
|
||||
null,
|
||||
number,
|
||||
[[number, { e: number; s: number; }[]]],
|
||||
[[number, { e: number; s: number }[]]],
|
||||
[number, [[number, [number, number]]]],
|
||||
{ b: number; k: bigint[]; }[],
|
||||
{ b: number; k: bigint[] }[],
|
||||
][];
|
||||
guild_join_requests?: any[]; // ? what is this? this is new
|
||||
shard?: [number, number];
|
||||
@@ -481,7 +481,7 @@ export interface SessionsReplace extends Event {
|
||||
export interface GuildMemberListUpdate extends Event {
|
||||
event: "GUILD_MEMBER_LIST_UPDATE";
|
||||
data: {
|
||||
groups: { id: string; count: number; }[];
|
||||
groups: { id: string; count: number }[];
|
||||
guild_id: string;
|
||||
id: string;
|
||||
member_count: number;
|
||||
@@ -489,8 +489,8 @@ export interface GuildMemberListUpdate extends Event {
|
||||
ops: {
|
||||
index: number;
|
||||
item: {
|
||||
member?: PublicMember & { presence: Presence; };
|
||||
group?: { id: string; count: number; }[];
|
||||
member?: PublicMember & { presence: Presence };
|
||||
group?: { id: string; count: number }[];
|
||||
};
|
||||
}[];
|
||||
};
|
||||
|
||||
@@ -3,5 +3,5 @@ export interface ApplicationAuthorizeSchema {
|
||||
guild_id: string;
|
||||
permissions: string;
|
||||
captcha_key?: string;
|
||||
code?: string; // 2fa code
|
||||
}
|
||||
code?: string; // 2fa code
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export interface ApplicationCreateSchema {
|
||||
name: string;
|
||||
team_id?: string | number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,4 +11,4 @@ export interface ApplicationModifySchema {
|
||||
bot_public?: boolean;
|
||||
bot_require_code_grant?: boolean;
|
||||
flags?: number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export interface BotModifySchema {
|
||||
avatar?: string;
|
||||
username?: string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ChannelPermissionOverwrite } from "@fosscord/util";
|
||||
|
||||
export interface ChannelPermissionOverwriteSchema
|
||||
extends ChannelPermissionOverwrite {}
|
||||
extends ChannelPermissionOverwrite {}
|
||||
|
||||
@@ -3,4 +3,4 @@ export type ChannelReorderSchema = {
|
||||
position?: number;
|
||||
lock_permissions?: boolean;
|
||||
parent_id?: string;
|
||||
}[];
|
||||
}[];
|
||||
|
||||
@@ -5,4 +5,4 @@ export const PayloadSchema = {
|
||||
$d: new Tuple(Object, Number), // or number for heartbeat sequence
|
||||
$s: Number,
|
||||
$t: String,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { GuildCreateSchema } from "@fosscord/util";
|
||||
|
||||
export interface GuildUpdateSchema extends Omit<GuildCreateSchema, "channels" | "name"> {
|
||||
export interface GuildUpdateSchema
|
||||
extends Omit<GuildCreateSchema, "channels" | "name"> {
|
||||
name?: string;
|
||||
banner?: string | null;
|
||||
splash?: string | null;
|
||||
|
||||
@@ -5,7 +5,7 @@ export interface MemberChangeProfileSchema {
|
||||
pronouns?: string;
|
||||
|
||||
/*
|
||||
* @items.type integer
|
||||
*/
|
||||
* @items.type integer
|
||||
*/
|
||||
theme_colors?: [number, number];
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export type RolePositionUpdateSchema = {
|
||||
id: string;
|
||||
position: number;
|
||||
}[];
|
||||
}[];
|
||||
|
||||
@@ -6,4 +6,4 @@ export interface UserGuildSettingsSchema
|
||||
channel_overrides?: {
|
||||
[channel_id: string]: Partial<ChannelOverride>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ export interface UserProfileModifySchema {
|
||||
pronouns?: string;
|
||||
|
||||
/*
|
||||
* @items.type integer
|
||||
*/
|
||||
theme_colors?: [number, number]
|
||||
* @items.type integer
|
||||
*/
|
||||
theme_colors?: [number, number];
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import { UserSettings } from "@fosscord/util";
|
||||
|
||||
export interface UserSettingsSchema extends Partial<UserSettings> {}
|
||||
export interface UserSettingsSchema extends Partial<UserSettings> {}
|
||||
|
||||
@@ -59,4 +59,4 @@ export * from "./UserSettingsSchema";
|
||||
export * from "./BotModifySchema";
|
||||
export * from "./ApplicationModifySchema";
|
||||
export * from "./ApplicationCreateSchema";
|
||||
export * from "./ApplicationAuthorizeSchema";
|
||||
export * from "./ApplicationAuthorizeSchema";
|
||||
|
||||
@@ -138,10 +138,8 @@ export class BitField {
|
||||
const FLAGS = this.FLAGS || this.constructor?.FLAGS;
|
||||
|
||||
if (typeof bit === "string") {
|
||||
if (typeof FLAGS[bit] !== "undefined")
|
||||
return FLAGS[bit];
|
||||
else
|
||||
bit = BigInt(bit);
|
||||
if (typeof FLAGS[bit] !== "undefined") return FLAGS[bit];
|
||||
else bit = BigInt(bit);
|
||||
}
|
||||
|
||||
if (
|
||||
|
||||
@@ -14,7 +14,7 @@ var pairs: ConfigEntity[];
|
||||
export const Config = {
|
||||
init: async function init() {
|
||||
if (config) return config;
|
||||
console.log('[Config] Loading configuration...');
|
||||
console.log("[Config] Loading configuration...");
|
||||
pairs = await ConfigEntity.find();
|
||||
config = pairsToConfig(pairs);
|
||||
// TODO: this overwrites existing config values with defaults.
|
||||
@@ -26,16 +26,19 @@ export const Config = {
|
||||
if (Object.keys(config).length == 0) config = new ConfigValue();
|
||||
|
||||
if (process.env.CONFIG_PATH) {
|
||||
console.log(`[Config] Using config path from environment rather than database.`);
|
||||
console.log(
|
||||
`[Config] Using config path from environment rather than database.`,
|
||||
);
|
||||
try {
|
||||
const overrideConfig = JSON.parse(fs.readFileSync(overridePath, { encoding: "utf8" }));
|
||||
const overrideConfig = JSON.parse(
|
||||
fs.readFileSync(overridePath, { encoding: "utf8" }),
|
||||
);
|
||||
config = overrideConfig.merge(config);
|
||||
} catch (error) {
|
||||
fs.writeFileSync(overridePath, JSON.stringify(config, null, 4));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return this.set(config);
|
||||
},
|
||||
get: function get() {
|
||||
|
||||
@@ -1043,7 +1043,7 @@ export const FosscordApiErrors = {
|
||||
45006,
|
||||
501,
|
||||
),
|
||||
FEATURE_IS_IMMUTABLE : new ApiError(
|
||||
FEATURE_IS_IMMUTABLE: new ApiError(
|
||||
"The feature ({}) cannot be edited.",
|
||||
45007,
|
||||
403,
|
||||
|
||||
@@ -37,7 +37,6 @@ const DataSourceOptions = new DataSource({
|
||||
migrations: [path.join(__dirname, "..", "migration", DatabaseType, "*.js")],
|
||||
});
|
||||
|
||||
|
||||
// Gets the existing database connection
|
||||
export function getDatabase(): DataSource | null {
|
||||
// if (!dbConnection) throw new Error("Tried to get database before it was initialised");
|
||||
@@ -60,8 +59,13 @@ export async function initDatabase(): Promise<DataSource> {
|
||||
if (!process.env.DB_SYNC) {
|
||||
const supported = ["mysql", "mariadb", "postgres", "sqlite"];
|
||||
if (!supported.includes(DatabaseType)) {
|
||||
console.log("[Database]" + red(` We don't have migrations for DB type '${DatabaseType}'` +
|
||||
` To ignore, set DB_SYNC=true in your env. https://docs.fosscord.com/setup/server/configuration/env/`));
|
||||
console.log(
|
||||
"[Database]" +
|
||||
red(
|
||||
` We don't have migrations for DB type '${DatabaseType}'` +
|
||||
` To ignore, set DB_SYNC=true in your env. https://docs.fosscord.com/setup/server/configuration/env/`,
|
||||
),
|
||||
);
|
||||
process.exit();
|
||||
}
|
||||
}
|
||||
@@ -71,12 +75,20 @@ export async function initDatabase(): Promise<DataSource> {
|
||||
dbConnection = await DataSourceOptions.initialize();
|
||||
|
||||
// Crude way of detecting if the migrations table exists.
|
||||
const dbExists = async () => { try { await ConfigEntity.count(); return true; } catch (e) { return false; } };
|
||||
if (!await dbExists()) {
|
||||
console.log("[Database] This appears to be a fresh database. Synchronising.");
|
||||
const dbExists = async () => {
|
||||
try {
|
||||
await ConfigEntity.count();
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
if (!(await dbExists())) {
|
||||
console.log(
|
||||
"[Database] This appears to be a fresh database. Synchronising.",
|
||||
);
|
||||
await dbConnection.synchronize();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
await dbConnection.runMigrations();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// List from https://invisible-characters.com/
|
||||
export const InvisibleCharacters = [
|
||||
"\u{9}", //Tab
|
||||
'\u{c}', //Form feed
|
||||
"\u{c}", //Form feed
|
||||
//'\u{20}', //Space //categories can have spaces in them
|
||||
"\u{ad}", //Soft hyphen
|
||||
//"\u{34f}", //Combining grapheme joiner
|
||||
|
||||
@@ -32,7 +32,7 @@ export class Rights extends BitField {
|
||||
static FLAGS = {
|
||||
OPERATOR: BitFlag(0), // has all rights
|
||||
MANAGE_APPLICATIONS: BitFlag(1),
|
||||
MANAGE_GUILDS: BitFlag(2), // Manage all guilds instance-wide
|
||||
MANAGE_GUILDS: BitFlag(2), // Manage all guilds instance-wide
|
||||
MANAGE_MESSAGES: BitFlag(3), // Can't see other messages but delete/edit them in channels that they can see
|
||||
MANAGE_RATE_LIMITS: BitFlag(4),
|
||||
MANAGE_ROUTING: BitFlag(5), // can create custom message routes to any channel/guild
|
||||
@@ -81,7 +81,7 @@ export class Rights extends BitField {
|
||||
SELF_EDIT_FLAGS: BitFlag(45), // can modify own flags
|
||||
EDIT_FLAGS: BitFlag(46), // can set others' flags
|
||||
MANAGE_GROUPS: BitFlag(47), // can manage others' groups
|
||||
VIEW_SERVER_STATS: BitFlag(48) // added per @chrischrome's request — can view server stats)
|
||||
VIEW_SERVER_STATS: BitFlag(48), // added per @chrischrome's request — can view server stats)
|
||||
};
|
||||
|
||||
any(permission: RightResolvable, checkOperator = true) {
|
||||
|
||||
@@ -19,4 +19,4 @@ export * from "./Snowflake";
|
||||
export * from "./String";
|
||||
export * from "./Array";
|
||||
export * from "./TraverseDirectory";
|
||||
export * from "./InvisibleCharacters";
|
||||
export * from "./InvisibleCharacters";
|
||||
|
||||
Reference in New Issue
Block a user