use Discord\Parts\Channel\Channel;
use Discord\Parts\Guild\Guild;
use Discord\Parts\User\Member;
+use Discord\Parts\User\User as DiscordUser;
use Illuminate\Support\Facades\App;
abstract class BaseCommand {
return new PresenceCommand($discord, $cmd);
case 'result':
return new ResultCommand($discord, $cmd);
+ case 'sync-user':
+ return new SyncUserCommand($discord, $cmd);
default:
throw new Exception('unrecognized command');
}
protected function __construct(Discord $discord, DiscordBotCommand $cmd) {
$this->discord = $discord;
$this->command = $cmd;
+ if ($cmd->tournament && $cmd->tournament->locale) {
+ App::setLocale($cmd->tournament->locale);
+ }
}
protected function fetchGuild() {
->fetch($this->command->tournament->discord)
->then(function (Guild $guild) {
$this->guild = $guild;
- if ($guild->preferred_locale) {
+ if ($guild->preferred_locale && !($this->command->tournament && $this->command->tournament->locale)) {
App::setLocale($guild->preferred_locale);
}
return $guild;
});
}
+ protected function fetchUser() {
+ if (isset($this->user)) {
+ return \React\Promise\resolve($this->user);
+ }
+ return $this->discord->users
+ ->fetch($this->getParameter('user'))
+ ->then(function (DiscordUser $user) {
+ $this->user = $user;
+ return $user;
+ });
+ }
+
protected function getParameter($name) {
return $this->command->parameters[$name];
protected $guild = null;
protected $member = null;
protected $roundChannel = null;
+ protected $user = null;
}