Skip to content

Commit

Permalink
Merge pull request #291 from P3D-Legacy/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
dsbilling authored Aug 7, 2023
2 parents 1db5246 + 8c57b6c commit 9d3f296
Show file tree
Hide file tree
Showing 36 changed files with 502 additions and 296 deletions.
31 changes: 21 additions & 10 deletions app/Helpers/DiscordHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,69 +6,80 @@

class DiscordHelper
{
private $discordClient;
private ?DiscordClient $discordClient;

private int $guildId;

public function __construct()
{
$this->discordClient =
config('services.discord.token') && config('services.discord.server_id')
? new DiscordClient(['token' => config('services.discord.token')])
: null;
$this->guildId = intval(config('services.discord.server_id'));
}

public function getServer()
public function getServer(): \RestCord\Model\Guild\Guild
{
return $this->discordClient->guild->getGuild([
'guild.id' => config('services.discord.server_id'),
'guild.id' => $this->guildId,
'with_counts' => true,
]);
}

public static function countMembers()
public static function countMembers(): ?int
{
$client = new self();
try {
return $client->getServer()->approximate_member_count;
} catch (\Exception $exception) {
logger()->error($exception->getMessage());

return 0;
}
}

public static function getServerRoles()
public static function getServerRoles(): \Exception|array
{
$client = new self();
try {
return $client->discordClient->guild->getGuildRoles([
'guild.id' => config('services.discord.server_id'),
'guild.id' => $client->guildId,
]);
} catch (\Exception $exception) {
logger()->error($exception->getMessage());

return $exception;
}
}

public static function getMemberRoles(int $user_id)
public static function getMemberRoles(int $user_id): \RestCord\Model\Guild\GuildMember|\Exception
{
$client = new self();
try {
return $client->discordClient->guild->getGuildMember([
'guild.id' => config('services.discord.server_id'),
'guild.id' => $client->guildId,
'user.id' => $user_id,
]);
} catch (\Exception $exception) {
logger()->error($exception->getMessage());

return $exception;
}
}

public static function setMemberRole(int $user_id, int $role_id)
public static function setMemberRole(int $user_id, int $role_id): array|string
{
$client = new self();
try {
return $client->discordClient->guild->addGuildMemberRole([
'guild.id' => config('services.discord.server_id'),
'guild.id' => $client->guildId,
'user.id' => $user_id,
'role.id' => $role_id,
]);
} catch (\Exception $exception) {
logger()->error($exception->getMessage());

return $exception->getMessage();
}
}
Expand Down
3 changes: 3 additions & 0 deletions app/Http/Livewire/Resource/RatingCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public function mount(int|Resource $resource)
{
$this->resource = $resource;
$this->user = auth()->user();
if ($this->user == $this->resource->user) {
$this->closeModal();
}
}

public function save()
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Livewire/Resource/ResourceForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ResourceForm extends ModalComponent

protected array $rules = [
'resource.name' => 'required|min:3|max:255',
'resource.description' => 'required|min:3|max:255',
'resource.description' => 'required|min:3|max:5120',
'resource.brief' => 'required|min:3|max:255',
'category' => 'required|exists:categories,id',
];
Expand Down
3 changes: 3 additions & 0 deletions app/Http/Livewire/Resource/ResourceLike.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public function mount(Resource $resource)

public function like()
{
if (! $this->user) {
return redirect()->route('login');
}
$this->user->toggleLike($this->resource);
$this->count = $this->resource->likers()->count();
$this->liked = $this->resource->isLikedBy($this->user);
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Livewire/Resource/UpdateCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class UpdateCreate extends ModalComponent
public $gameversions;

protected array $rules = [
'version' => ['required', 'string'],
'description' => ['required', 'string'],
'version' => ['required', 'string', 'max:255'],
'description' => ['required', 'string', 'max:5120'],
'file' => ['required', 'file', 'mimes:zip', 'max:100000'], //100mb
'gameversion' => ['required'],
];
Expand Down
9 changes: 7 additions & 2 deletions lang/cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"Confirm": "确认",
"Confirm Password": "确认密码",
"Consents": "同意申明",
"Contact": "Contact",
"Content": "目录",
"Contribute your language": "Contribute your language",
"Create": "创建",
Expand Down Expand Up @@ -116,6 +117,7 @@
"Go to Dashboard": "前往控制面板",
"Go to page :page": "前往第 :page 页",
"Good": "很棒",
"Hello!": "您好!",
"Here you can choose what to share on your public profile.": "在这里您可以选择在账号简介中所想要公开的内容。",
"History": "历史记录",
"Home": "主页",
Expand Down Expand Up @@ -145,14 +147,15 @@
"Legal": "合法",
"Like": "点赞",
"Liked": "已点赞",
"Likes": "点赞数",
"likes": "点赞数",
"Likes": "点赞数",
"Link your account with Game Jolt to be able to edit your skins for in-game use, and for more features to come.": "关联 Game Jolt 账号以编辑您在游戏中所使用的皮肤以及使用更多服务功能。",
"Link your account with your :account account.": "关联你的 :account 账号。",
"Location": "地址",
"Log in": "登录",
"Log Out": "登出",
"Log Out Other Browser Sessions": "注销其他浏览器的会话",
"Login": "登录",
"Maintenance": "Maintenance",
"Manage Account": "管理账户",
"Manage and log out your active sessions on other browsers and devices.": "管理和注销您在其他浏览器和设备上的活动会话。",
Expand Down Expand Up @@ -224,6 +227,7 @@
"Read more": "读取更多",
"Read more blog posts": "读取更多公告帖子",
"Recovery Code": "恢复代码",
"Regards": "致敬",
"Regenerate Recovery Codes": "重新生成恢复码",
"Register": "注册",
"Released": "已释出",
Expand Down Expand Up @@ -318,6 +322,7 @@
"Welcome to :game!": "欢迎来到 :game!",
"What's my token?": "请问您的令牌是?",
"When two factor authentication is enabled, you will be prompted for a secure, random token during authentication. You may retrieve this token from your phone's Authenticator application.": "当双重认证被启用, 你将被提示输入一个安全有效及在身份验证过程中随机生成的令牌。你可以从你的身份验证应用程序中获得此令牌。",
"Whoops!": "哎呀!",
"Whoops! Something went wrong.": "哎呀!出了点问题",
"winter": "冬天",
"Year To Date": "Year To Date",
Expand All @@ -335,4 +340,4 @@
"Your slots are full. You cannot import from the old site unless you delete one of the slots.": "您的储存格已经满位。您无法将其从旧网站中导入除非您删除一个储存格。",
"Your timezone": "Your timezone",
"Your user was created at": "Your user was created at"
}
}
9 changes: 7 additions & 2 deletions lang/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"Confirm": "Potvrdit",
"Confirm Password": "Kontrola hesla",
"Consents": "Consents",
"Contact": "Contact",
"Content": "Content",
"Contribute your language": "Contribute your language",
"Create": "Vytvořit",
Expand Down Expand Up @@ -116,6 +117,7 @@
"Go to Dashboard": "Go to Dashboard",
"Go to page :page": "Přejít na stranu :page",
"Good": "Good",
"Hello!": "Zdravíme!",
"Here you can choose what to share on your public profile.": "Here you can choose what to share on your public profile.",
"History": "History",
"Home": "Home",
Expand Down Expand Up @@ -145,14 +147,15 @@
"Legal": "Legal",
"Like": "Like",
"Liked": "Liked",
"Likes": "Likes",
"likes": "likes",
"Likes": "Likes",
"Link your account with Game Jolt to be able to edit your skins for in-game use, and for more features to come.": "Link your account with Game Jolt to be able to edit your skins for in-game use, and for more features to come.",
"Link your account with your :account account.": "Link your account with your :account account.",
"Location": "Location",
"Log in": "Přihlásit",
"Log Out": "Odhlásit",
"Log Out Other Browser Sessions": "Odhlásit další relace prohlížeče",
"Login": "Přihlášení",
"Maintenance": "Maintenance",
"Manage Account": "Správa účtu",
"Manage and log out your active sessions on other browsers and devices.": "Správa a odhlášení aktivních relací v jiných prohlížečích a zařízeních.",
Expand Down Expand Up @@ -224,6 +227,7 @@
"Read more": "Read more",
"Read more blog posts": "Read more blog posts",
"Recovery Code": "Kód pro obnovení",
"Regards": "S pozdravem",
"Regenerate Recovery Codes": "Regenerovat Kódy Obnovy",
"Register": "Registrace",
"Released": "Released",
Expand Down Expand Up @@ -318,6 +322,7 @@
"Welcome to :game!": "Welcome to :game!",
"What's my token?": "What's my token?",
"When two factor authentication is enabled, you will be prompted for a secure, random token during authentication. You may retrieve this token from your phone's Authenticator application.": "When two factor authentication is enabled, you will be prompted for a secure, random token during authentication. You may retrieve this token from your phone's Authenticator application.",
"Whoops!": "Jejda!",
"Whoops! Something went wrong.": "Jejda! Něco se pokazilo.",
"winter": "winter",
"Year To Date": "Year To Date",
Expand All @@ -335,4 +340,4 @@
"Your slots are full. You cannot import from the old site unless you delete one of the slots.": "Your slots are full. You cannot import from the old site unless you delete one of the slots.",
"Your timezone": "Your timezone",
"Your user was created at": "Your user was created at"
}
}
9 changes: 7 additions & 2 deletions lang/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"Confirm": "Επιβεβαίωση",
"Confirm Password": "Επιβεβαίωση Κωδικού",
"Consents": "συναινεί",
"Contact": "Contact",
"Content": "Περιεχόμενο",
"Contribute your language": "Contribute your language",
"Create": "Δημιουργήσετε",
Expand Down Expand Up @@ -116,6 +117,7 @@
"Go to Dashboard": "Μεταβείτε στον Πίνακα ελέγχου",
"Go to page :page": "Μετάβαση στη σελίδα :page",
"Good": "Καλός",
"Hello!": "Χαίρετε!",
"Here you can choose what to share on your public profile.": "Εδώ μπορείτε να επιλέξετε τι θα μοιραστείτε στο δημόσιο προφίλ σας.",
"History": "Ιστορικό",
"Home": "Αρχική",
Expand Down Expand Up @@ -145,14 +147,15 @@
"Legal": "Νομικά",
"Like": "Μου αρέσει",
"Liked": "Μου άρεσε",
"Likes": "Μου αρέσει",
"likes": "μου αρέσει",
"Likes": "Μου αρέσει",
"Link your account with Game Jolt to be able to edit your skins for in-game use, and for more features to come.": "Συνδέστε τον λογαριασμό σας με το Game Jolt για να μπορείτε να επεξεργάζεστε τις εμφανίσεις σας για χρήση εντός του παιχνιδιού και για περισσότερες λειτουργίες που θα ακολουθήσουν.",
"Link your account with your :account account.": "Συνδέστε τον λογαριασμό σας με :account λογαριασμό.",
"Location": "Τοποθεσία",
"Log in": "Συνδεθείτε",
"Log Out": "αποσυνδεθείτε",
"Log Out Other Browser Sessions": "Αποσυνδεθείτε Από Άλλες Συνεδρίες Του Προγράμματος Περιήγησης",
"Login": "Είσοδος",
"Maintenance": "Συντήρηση",
"Manage Account": "Διαχείριση Λογαριασμού",
"Manage and log out your active sessions on other browsers and devices.": "Διαχειριστείτε και αποσυνδεθείτε ενεργό συνεδρίες σας σε άλλα προγράμματα περιήγησης και συσκευές.",
Expand Down Expand Up @@ -224,6 +227,7 @@
"Read more": "Διαβάστε περισσότερα",
"Read more blog posts": "Διαβάστε περισσότερες αναρτήσεις ιστολογίου",
"Recovery Code": "Κωδικός Ανάκτησης",
"Regards": "Φιλικά",
"Regenerate Recovery Codes": "Αναγεννήστε Τους Κωδικούς Ανάκτησης",
"Register": "Εγγραφή",
"Released": "Δημοσιεύθηκε",
Expand Down Expand Up @@ -318,6 +322,7 @@
"Welcome to :game!": "Καλωσόρισατε στο :game!",
"What's my token?": "Ποιο είναι το διακριτικό μου;",
"When two factor authentication is enabled, you will be prompted for a secure, random token during authentication. You may retrieve this token from your phone's Authenticator application.": "Όταν είναι ενεργοποιημένος ο έλεγχος ταυτότητας δύο παραγόντων, θα σας ζητηθεί ένα ασφαλές, τυχαίο διακριτικό κατά τον έλεγχο ταυτότητας. Μπορείτε να ανακτήσετε αυτό το διακριτικό από την εφαρμογή Authenticator του τηλεφώνου σας.",
"Whoops!": "Ουπς!",
"Whoops! Something went wrong.": "Ουπς! Κάτι πήγε στραβά.",
"winter": "χειμώνας",
"Year To Date": "Year To Date",
Expand All @@ -335,4 +340,4 @@
"Your slots are full. You cannot import from the old site unless you delete one of the slots.": "Οι θέσεις σας είναι γεμάτες. Δεν μπορείτε να κάνετε εισαγωγή από τον παλιό ιστότοπο, εκτός εάν διαγράψετε μία από της υποδοχές.",
"Your timezone": "Your timezone",
"Your user was created at": "Your user was created at"
}
}
9 changes: 7 additions & 2 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"Confirm": "Confirm",
"Confirm Password": "Confirm Password",
"Consents": "Consents",
"Contact": "Contact",
"Content": "Content",
"Contribute your language": "Contribute your language",
"Create": "Create",
Expand Down Expand Up @@ -116,6 +117,7 @@
"Go to Dashboard": "Go to Dashboard",
"Go to page :page": "Go to page :page",
"Good": "Good",
"Hello!": "Hello!",
"Here you can choose what to share on your public profile.": "Here you can choose what to share on your public profile.",
"History": "History",
"Home": "Home",
Expand Down Expand Up @@ -145,14 +147,15 @@
"Legal": "Legal",
"Like": "Like",
"Liked": "Liked",
"Likes": "Likes",
"likes": "likes",
"Likes": "Likes",
"Link your account with Game Jolt to be able to edit your skins for in-game use, and for more features to come.": "Link your account with Game Jolt to be able to edit your skins for in-game use, and for more features to come.",
"Link your account with your :account account.": "Link your account with your :account account.",
"Location": "Location",
"Log in": "Log in",
"Log Out": "Log Out",
"Log Out Other Browser Sessions": "Log Out Other Browser Sessions",
"Login": "Login",
"Maintenance": "Maintenance",
"Manage Account": "Manage Account",
"Manage and log out your active sessions on other browsers and devices.": "Manage and log out your active sessions on other browsers and devices.",
Expand Down Expand Up @@ -224,6 +227,7 @@
"Read more": "Read more",
"Read more blog posts": "Read more blog posts",
"Recovery Code": "Recovery Code",
"Regards": "Regards",
"Regenerate Recovery Codes": "Regenerate Recovery Codes",
"Register": "Register",
"Released": "Released",
Expand Down Expand Up @@ -318,6 +322,7 @@
"Welcome to :game!": "Welcome to :game!",
"What's my token?": "What's my token?",
"When two factor authentication is enabled, you will be prompted for a secure, random token during authentication. You may retrieve this token from your phone's Authenticator application.": "When two factor authentication is enabled, you will be prompted for a secure, random token during authentication. You may retrieve this token from your phone's Authenticator application.",
"Whoops!": "Whoops!",
"Whoops! Something went wrong.": "Whoops! Something went wrong.",
"winter": "winter",
"Year To Date": "Year To Date",
Expand All @@ -335,4 +340,4 @@
"Your slots are full. You cannot import from the old site unless you delete one of the slots.": "Your slots are full. You cannot import from the old site unless you delete one of the slots.",
"Your timezone": "Your timezone",
"Your user was created at": "Your user was created at"
}
}
Loading

0 comments on commit 9d3f296

Please sign in to comment.