Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Discord API v9 issues with GuildScheduledEvent #174

Merged
merged 2 commits into from
Jan 7, 2022

Conversation

LeigerGaming
Copy link

This fixes the ability to use these models from the client, as they were broken due to the hyphens:

  • AuditLog (replace $client->audit-log with $client->auditLog)
  • GuildScheduledEvent (replace $client->guild-scheduled-event with $client->guildScheduledEvent)
  • GuildTemplate (replace $client->guild-template with $client->guildTemplate)
  • StageInstance (replace $client->stage-instance with $client->stageInstance)

Additionally, it fixes the parameter types for GuildScheduledEvent. For example, 'scheduled_start_time' was listed as type 'ISO8601 timestamp' because that's what the Discord API says. But it's actually a PHP string, in the format of an ISO8601-compatible date/time.

With these parameter type fixes in place, it means that it's actually possible to create an event now, using code like this:

$client->guildScheduledEvent->createGuildScheduledEvent([
    'guild.id' => $guildId,
    'name' => 'Event Name',
    'description' => 'Event Description',
    'scheduled_start_time' => '2022-01-16T07:30:00+00:00',
    'scheduled_end_time' => '2022-01-16T09:30:00+00:00',
    'privacy_level' => 2, // GUILD_ONLY
    'entity_type' => 3, // EXTERNAL
    'entity_metadata' => [
        'location' => 'https://example.com',
    ],
]);

See the relevant documentation here: https://discord.com/developers/docs/resources/guild-scheduled-event#create-guild-scheduled-event

I have successfully created events in my Discord server using this, so I can verify that it works for scheduled events.

There may be outstanding parameter type issues for AuditLog, GuildTemplate, and StageInstance. However I'll leave that to someone else to fix if there is in fact an issue.

@LeigerGaming
Copy link
Author

LeigerGaming commented Jan 7, 2022

Just doing some testing. I can confirm that AuditLog works as intended:

$client->auditLog->getGuildAuditLog([
    'guild.id' => $guildId,
    'limit' => 5,
]);

@cryptiklemur cryptiklemur merged commit 1c7a347 into restcord:v9 Jan 7, 2022
@BriqueAuBob
Copy link

We can access it with the following syntax:
$client->{"guild-scheduled-event"}->createGuildScheduledEvent()
for example, but that looks nicer with your solution

@LeigerGaming
Copy link
Author

Oh! Wasn't aware of that workaround. Good to know. It occurred to me that a string might work, but I never actually tested it because I assumed I'd run into the same problem. I agree that it's nicer being able to do it without the string.

Thanks for merging it aequasi :)

Sama34 pushed a commit to Sama34/restcord that referenced this pull request Jun 20, 2023
* Fixed: Cannot access 'audit-log', 'guild-scheduled-event', 'guild-template' and 'stage-instance' due to the hyphen

* Fixed: Cannot create a GuildScheduledEvent due to validation errors on the parameters
Sama34 added a commit to Sama34/restcord that referenced this pull request Jun 20, 2023
Fix Discord API v9 issues with GuildScheduledEvent (restcord#174)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants