]> git.localhorst.tv Git - alttp.git/commitdiff
discord discriminator stuff round 2
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 14 Jun 2023 09:26:59 +0000 (11:26 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 14 Jun 2023 09:26:59 +0000 (11:26 +0200)
app/Http/Controllers/DiscordController.php
app/Models/User.php
database/migrations/2023_06_14_091826_add_user_discord_nickname.php [new file with mode: 0644]
resources/js/components/common/Footer.js
resources/js/components/common/Header.js
resources/js/components/users/Box.js
resources/js/helpers/User.js
resources/js/i18n/de.js
resources/js/i18n/en.js

index 6f9c03d5ea7494a2c3c4450e7ce5aa181e9ec1fc..1625e32a9186aff635271593817b8f91c012cd7f 100644 (file)
@@ -146,6 +146,7 @@ class DiscordController extends \Jakyeru\Larascord\Http\Controllers\DiscordContr
                        ],
                        [
                                'username' => $user->username,
+                               'discord_nickname' => isset($user->global_name) ? $user->global_name : NULL,
                                'discriminator' => $user->discriminator,
                                'email' => isset($user->email) ? $user->email : NULL,
                                'avatar' => $user->avatar ?: NULL,
index ad5215f064acc5407b2d1bc48664c549c3e41fbb..72286a4891e48a5d789d2ba682eb4eff53fb79a1 100644 (file)
@@ -190,6 +190,7 @@ class User extends Authenticatable
        protected $fillable = [
                'id',
                'username',
+               'discord_nickname',
                'discriminator',
                'email',
                'avatar',
diff --git a/database/migrations/2023_06_14_091826_add_user_discord_nickname.php b/database/migrations/2023_06_14_091826_add_user_discord_nickname.php
new file mode 100644 (file)
index 0000000..a8e9a35
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+       /**
+        * Run the migrations.
+        *
+        * @return void
+        */
+       public function up()
+       {
+               Schema::table('users', function(Blueprint $table) {
+                       $table->string('discord_nickname')->nullable()->default(null);
+               });
+       }
+
+       /**
+        * Reverse the migrations.
+        *
+        * @return void
+        */
+       public function down()
+       {
+               Schema::table('users', function(Blueprint $table) {
+                       $table->dropColumn('discord_nickname');
+               });
+       }
+};
index 361c1f711cb82bc494af8eb9d2811c27f440594c..71d8998c5f14dcfb98e7e5a429fe6b00e68ed007 100644 (file)
@@ -57,6 +57,15 @@ const Footer = () => {
                                                        </Nav.Link>
                                                </LinkContainer>
                                        </Nav.Item>
+                                       <Nav.Item as="li">
+                                               <Nav.Link
+                                                       className="p-0 text-muted"
+                                                       href="https://glitchmaps.mfns.dev/"
+                                                       target="_blank"
+                                               >
+                                                       {t('footer.muffins')}
+                                               </Nav.Link>
+                                       </Nav.Item>
                                        <Nav.Item as="li">
                                                <Nav.Link
                                                        className="p-0 text-muted"
index 53119bc13fde6844d8dfa809afa44dee7221668d..21c6a67ed7d7224c0237c12f3a5eb280ff5a3fad 100644 (file)
@@ -55,7 +55,9 @@ const Header = ({ doLogout, user }) => {
                                                        <Nav.Link>
                                                                <img alt="" src={getAvatarUrl(user)} />
                                                                {user.username}
-                                                               <span className="text-muted">#{user.discriminator}</span>
+                                                               {user.discriminator && user.discriminator !== '0' ?
+                                                                       <span className="text-muted">#{user.discriminator}</span>
+                                                               : null}
                                                        </Nav.Link>
                                                </LinkContainer>
                                                <Button
index fd5814f6216896baa4dcdda3d7ee784c394b917d..c0d011bc106d4060dcbfd222865b62ed3d1e2fad 100644 (file)
@@ -4,7 +4,7 @@ import { Button } from 'react-bootstrap';
 import { withTranslation } from 'react-i18next';
 import { useNavigate } from 'react-router-dom';
 
-import { getAvatarUrl } from '../../helpers/User';
+import { getAvatarUrl, getUserName } from '../../helpers/User';
 import i18n from '../../i18n';
 
 const Box = ({ discriminator, noLink, user }) => {
@@ -16,8 +16,8 @@ const Box = ({ discriminator, noLink, user }) => {
 
        const content = <>
                <img alt="" src={getAvatarUrl(user)} />
-               <span>{discriminator || !user.nickname ? user.username : user.nickname}</span>
-               {discriminator && user.discriminator ?
+               <span>{discriminator ? user.username : getUserName(user)}</span>
+               {discriminator && user.discriminator && user.discriminator !== '0' ?
                        <span className="text-muted">
                                {'#'}
                                {user.discriminator}
index 9a554449cdfb0dd437c10c13ab6e344273c3d70e..0705bed2d35013f25bcd14154a2361a861d8f56f 100644 (file)
@@ -1,5 +1,3 @@
-import moment from 'moment';
-
 export const compareFinished = round => (a, b) => {
        const a_result = findResult(a, round);
        const b_result = findResult(b, round);
@@ -58,7 +56,8 @@ export const getAvatarUrl = user => {
        return '/default-avatar.png';
 };
 
-export const getUserName = user => (user && (user.nickname || user.username)) || '';
+export const getUserName = user => (user &&
+       (user.nickname || user.discord_nickname || user.username)) || '';
 
 export const hasFinishedRound = (user, round) => {
        const result = findResult(user, round);
index d8cf86134cadbdcf336c46b57883ea1c545e87b4..b91fee4b5cbaecdd299ee48486f9fc6b43d3b292 100644 (file)
@@ -322,9 +322,10 @@ export default {
                        alttpwiki: 'ALttP Speedrunning Wiki',
                        competitions: 'Wettbewerbe',
                        connect: 'Connect Spedruns Discord',
-                       contact: 'Wenn du gerne ein Turnier auf dieser Seite organisieren möchtest, wende dich bitte an HolySmoke#5229 im Discord.',
+                       contact: 'Wenn du gerne ein Turnier auf dieser Seite organisieren möchtest, wende dich bitte an holysmoke86 im Discord.',
                        info: 'Infos',
                        map: 'ALttP Karte',
+                       muffins: 'Muffins\' Glitch Map (EN)',
                        privacy: 'Datenschutz',
                        resources: 'Ressourcen',
                        smd: 'Deutscher Super Metroid Discord',
index d143eb0afbdc2f589ab26e0aad0f6b10b140cbf9..fed1d5b612bec5b44453a8092a38a4178b1231ee 100644 (file)
@@ -322,9 +322,10 @@ export default {
                        alttpwiki: 'ALttP Speedrunning Wiki',
                        competitions: 'Competitions',
                        connect: 'Connect Spedruns Discord',
-                       contact: 'If you would like to organize a Tournament on this site, please contact HolySmoke#5229 on Discord.',
+                       contact: 'If you would like to organize a Tournament on this site, please contact holysmoke86 on Discord.',
                        info: 'Infos',
                        map: 'ALttP Map',
+                       muffins: 'Muffins\' Glitch Map',
                        privacy: 'Privacy',
                        resources: 'Resources',
                        smd: 'German Super Metroid Discord',