diff --git a/locales/hr/auth.json b/locales/hr/auth.json
new file mode 100644
index 00000000..3e330168
--- /dev/null
+++ b/locales/hr/auth.json
@@ -0,0 +1,15 @@
+{
+ "login": {
+ "INVALID_LOGIN": "Email ili broj mobitela nije pronađen",
+ "INVALID_PASSWORD": "Pogrešna lozinka"
+ },
+ "register": {
+ "REGISTRATION_DISABLED": "Registracija novog korisnika je onemogućena",
+ "INVITE_ONLY": "Morate biti pozvani da se registrirate",
+ "EMAIL_INVALID": "Nevažeći email",
+ "EMAIL_ALREADY_REGISTERED": "Email je već registriran",
+ "DATE_OF_BIRTH_UNDERAGE": "Morate imati {{years}} godina ili više",
+ "CONSENT_REQUIRED": "Morate se složiti s uvjetima pružanja usluge i pravila o privatnosti.",
+ "USERNAME_TOO_MANY_USERS": "Previše korisnika ima ovo korisničko ime, molimo vas da pokušate sa drugim"
+ }
+}
diff --git a/locales/hr/common.json b/locales/hr/common.json
new file mode 100644
index 00000000..2126f375
--- /dev/null
+++ b/locales/hr/common.json
@@ -0,0 +1,18 @@
+{
+ "field": {
+ "BASE_TYPE_REQUIRED": "Ovo polje je obavezno",
+ "BASE_TYPE_STRING": "Ovo polje mora biti niz",
+ "BASE_TYPE_NUMBER": "Ovo polje mora biti broj",
+ "BASE_TYPE_BIGINT": "Ovo polje mora biti bigint",
+ "BASE_TYPE_BOOLEAN": "Ovo polje mora biti boolean",
+ "BASE_TYPE_CHOICES": "Ovo polje mora biti jedno od ({{types}})",
+ "BASE_TYPE_CLASS": "Ovo polje mora biti primjer od {{type}}",
+ "BASE_TYPE_OBJECT": "Ovo polje mora biti objekt",
+ "BASE_TYPE_ARRAY": "Ovo polje mora biti niz",
+ "UNKOWN_FIELD": "Nepoznati ključ: {{key}}",
+ "BASE_TYPE_CONSTANT": "Ovo polje mora biti {{value}}",
+ "EMAIL_TYPE_INVALID_EMAIL": "Nije dobro oblikovana Email adresa",
+ "DATE_TYPE_PARSE": "Nije moguće raščlaniti {{date}}. Treba biti ISO8601",
+ "BASE_TYPE_BAD_LENGTH": "Mora biti između {{length}} u duljini"
+ }
+}
\ No newline at end of file
diff --git a/src/util/Channel.ts b/src/util/Channel.ts
index 8dfc03bc..4d322812 100644
--- a/src/util/Channel.ts
+++ b/src/util/Channel.ts
@@ -13,11 +13,21 @@ import { emitEvent } from "./Event";
// TODO: DM channel
export async function createChannel(channel: Partial<TextChannel | VoiceChannel>, user_id: string = "0") {
- if (!channel.permission_overwrites) channel.permission_overwrites = [];
+
+ // Always check if user has permission first
+ const permissions = await getPermission(user_id, channel.guild_id);
+ permissions.hasThrow("MANAGE_CHANNELS");
switch (channel.type) {
case ChannelType.GUILD_TEXT:
case ChannelType.GUILD_VOICE:
+ if (channel.parent_id) {
+ const exists = await ChannelModel.findOne({ id: channel.parent_id }, { guild_id: true }).exec();
+ if (!exists) throw new HTTPError("Parent id channel doesn't exist", 400);
+ if (exists.guild_id !== channel.guild_id) throw new HTTPError("The category channel needs to be in the guild");
+ }
+ break;
+ case ChannelType.GUILD_CATEGORY:
break;
case ChannelType.DM:
case ChannelType.GROUP_DM:
@@ -29,15 +39,7 @@ export async function createChannel(channel: Partial<TextChannel | VoiceChannel>
throw new HTTPError("Not yet supported");
}
- const permissions = await getPermission(user_id, channel.guild_id);
- permissions.hasThrow("MANAGE_CHANNELS");
-
- if (channel.parent_id) {
- const exists = await ChannelModel.findOne({ id: channel.parent_id }, { guild_id: true }).exec();
- if (!exists) throw new HTTPError("Parent id channel doesn't exist", 400);
- if (exists.guild_id !== channel.guild_id) throw new HTTPError("The category channel needs to be in the guild");
- }
-
+ if (!channel.permission_overwrites) channel.permission_overwrites = [];
// TODO: auto generate position
channel = await new ChannelModel({
|