$discord->application->commands->save($cmd);
}
+ public static function presetByName($name) {
+ if (isset(static::$presets[$name])) {
+ return static::$presets[$name];
+ }
+ foreach (static::$presets as $presetName => $preset) {
+ if (strcasecmp($name, $presetName) === 0) {
+ return $preset;
+ }
+ }
+ return null;
+ }
+
public static function listen(Discord $discord) {
$discord->listenCommand(['aosr', 'preset'], function(Interaction $interaction) use ($discord) {
$interaction
$presetName = $validatedData['preset'];
$race = $validatedData['race'] ?? false;
- if (!isset(AosrPresetCommand::$presets[$presetName])) {
+ $preset = AosrPresetCommand::presetByName($presetName);
+ if (!$preset) {
abort(404);
}
- $preset = AosrPresetCommand::$presets[$presetName];
$seed = AosSeed::generateSurge($presetName, $preset['settings'], $race);
Artisan::call('aos:generate '.intval($seed->id));