vince
vince
Explore posts from servers
KPCKevin Powell - Community
Created by StarPlatinumSan on 6/30/2024 in #front-end
is there any way to make my sass files less messy?
Look up the 7-1 pattern
25 replies
KPCKevin Powell - Community
Created by Abdur Rahman on 6/27/2024 in #front-end
I can't write javascript or do programming all together
That way instead of having a list of 6 things to do you have a list of 3 for example with easy, manageable parts
143 replies
KPCKevin Powell - Community
Created by Abdur Rahman on 6/27/2024 in #front-end
I can't write javascript or do programming all together
Might help to pair it with your code too, eg:
const string = '123456';

// 1 - check if string exists
if (string == null) { // 1a - if string is null
return null;
} else { // 1b - if string isn't null
...
}
const string = '123456';

// 1 - check if string exists
if (string == null) { // 1a - if string is null
return null;
} else { // 1b - if string isn't null
...
}
143 replies
KPCKevin Powell - Community
Created by Abdur Rahman on 6/27/2024 in #front-end
I can't write javascript or do programming all together
Great job with the steps, really like that Epic. My input to this too -- and it might just be a me thing -- is it might be easier to separate them out into sublists, eg:
1. check if string exists
1a. if string is null, return null
1b. if string isn't null, parse string
2. ...
1. check if string exists
1a. if string is null, return null
1b. if string isn't null, parse string
2. ...
143 replies
KPCKevin Powell - Community
Created by vince on 6/25/2024 in #back-end
Does this make sense to be a subclass?
i dont think it has to be a perfect solution im gonna make a lot of mistakes at this stage anyway i just want something thats not total shite and does what i need it to do
65 replies
KPCKevin Powell - Community
Created by vince on 6/25/2024 in #back-end
Does this make sense to be a subclass?
great i was hoping so 😂 i kept thinking about how to set it up and finally landed on this. i was thinking about it in bed last night too lol
65 replies
KPCKevin Powell - Community
Created by vince on 6/25/2024 in #back-end
Does this make sense to be a subclass?
It's not a subclass but it's own thing -- I didn't want to override the parent props / methods
65 replies
KPCKevin Powell - Community
Created by vince on 6/25/2024 in #back-end
Does this make sense to be a subclass?
Basically just a wrapper class that instantiates the Discord class and has some utility functions to it
65 replies
KPCKevin Powell - Community
Created by vince on 6/25/2024 in #back-end
Does this make sense to be a subclass?
I still called it something specific Umpire rather than Bot
65 replies
KPCKevin Powell - Community
Created by vince on 6/25/2024 in #back-end
Does this make sense to be a subclass?
I ended up rewriting it to just be a regular class like Epic showed
65 replies
KPCKevin Powell - Community
Created by vince on 6/25/2024 in #back-end
Does this make sense to be a subclass?
Looks / functions better?
65 replies
KPCKevin Powell - Community
Created by vince on 6/25/2024 in #back-end
Does this make sense to be a subclass?
Okay, I think I got it. Here's what I have:
// UmpireSingleton.php

<?php

namespace Umpire;

use Dotenv\Dotenv;
use Discord\Discord;
use Discord\Parts\Channel\Message;

class UmpireSingleton extends Discord
{
private static UmpireSingleton $instance;

private function __construct()
{
$dotenv = Dotenv::createImmutable(dirname(__DIR__, 1));
$dotenv->load();
$dotenv->required(['UMPIRE_TOKEN'])->notEmpty();

parent::__construct([
'token' => $_ENV['UMPIRE_TOKEN'],
]);
}

public static function getInstance(): UmpireSingleton
{
if (!isset(self::$instance)) {
self::$instance = new self();
}

return self::$instance;
}

public static function startTopicThread(Message $message, array $topic): void
{
...
}
}
// UmpireSingleton.php

<?php

namespace Umpire;

use Dotenv\Dotenv;
use Discord\Discord;
use Discord\Parts\Channel\Message;

class UmpireSingleton extends Discord
{
private static UmpireSingleton $instance;

private function __construct()
{
$dotenv = Dotenv::createImmutable(dirname(__DIR__, 1));
$dotenv->load();
$dotenv->required(['UMPIRE_TOKEN'])->notEmpty();

parent::__construct([
'token' => $_ENV['UMPIRE_TOKEN'],
]);
}

public static function getInstance(): UmpireSingleton
{
if (!isset(self::$instance)) {
self::$instance = new self();
}

return self::$instance;
}

public static function startTopicThread(Message $message, array $topic): void
{
...
}
}
And then:
// main.php

<?php

include __DIR__ . '/vendor/autoload.php';

use Umpire\UmpireSingleton;

$umpire = UmpireSingleton::getInstance();

...
// main.php

<?php

include __DIR__ . '/vendor/autoload.php';

use Umpire\UmpireSingleton;

$umpire = UmpireSingleton::getInstance();

...
65 replies
KPCKevin Powell - Community
Created by vince on 6/25/2024 in #back-end
Does this make sense to be a subclass?
Because the Discord class uses a constructor, so I can't get the instance of the Discord class on the static Umpire class
65 replies
KPCKevin Powell - Community
Created by vince on 6/25/2024 in #back-end
Does this make sense to be a subclass?
I think I definitely need a singleton now that I'm writing it out and thinking about it more
65 replies
KPCKevin Powell - Community
Created by vince on 6/25/2024 in #back-end
Does this make sense to be a subclass?
Or can I 🤔
65 replies
KPCKevin Powell - Community
Created by vince on 6/25/2024 in #back-end
Does this make sense to be a subclass?
I was writing this whole thing out but realized that yea, definitely can't make this static
65 replies
KPCKevin Powell - Community
Created by vince on 6/25/2024 in #back-end
Does this make sense to be a subclass?
oh okay I understand this now but yea not sure if this is what im looking for could be wrong tho
65 replies
KPCKevin Powell - Community
Created by vince on 6/25/2024 in #back-end
Does this make sense to be a subclass?
See I was thinking that I don't even need it to be initialized in an object -- I'd be happy if I was just calling it from the class whch is why I wanted it to be static but I was getting errors trying to do that
65 replies
KPCKevin Powell - Community
Created by vince on 6/25/2024 in #back-end
Does this make sense to be a subclass?
I was thinking that too but I felt that might be a bit overkill but idk anything
65 replies
KPCKevin Powell - Community
Created by vince on 6/25/2024 in #back-end
Does this make sense to be a subclass?
That's how little I know about oop lol
65 replies