-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
explicitly declare classes, fix warnings
- Loading branch information
Showing
4 changed files
with
61 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 10 additions & 16 deletions
26
src/Artemis.Plugins.Modules.Discord/DiscordPackets/DiscordResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,22 @@ | ||
using Artemis.Plugins.Modules.Discord.DiscordPackets.CommandData; | ||
using Artemis.Plugins.Modules.Discord.Enums; | ||
using JsonSubTypes; | ||
using Newtonsoft.Json; | ||
using System; | ||
using static JsonSubTypes.JsonSubtypes; | ||
using System; | ||
using Artemis.Plugins.Modules.Discord.DiscordPackets.CommandData; | ||
|
||
namespace Artemis.Plugins.Modules.Discord.DiscordPackets; | ||
|
||
public class DiscordResponse : IDiscordMessage | ||
{ | ||
[JsonProperty("cmd")] | ||
public DiscordRpcCommand Command { get; set; } | ||
|
||
public Guid Nonce { get; set; } | ||
} | ||
|
||
[JsonConverter(typeof(JsonSubtypes), "cmd")] | ||
[KnownSubType(typeof(DiscordResponse<Authorize>), DiscordRpcCommand.AUTHORIZE)] | ||
[KnownSubType(typeof(DiscordResponse<Authenticate>), DiscordRpcCommand.AUTHENTICATE)] | ||
[KnownSubType(typeof(DiscordResponse<VoiceSettings>), DiscordRpcCommand.GET_VOICE_SETTINGS)] | ||
[KnownSubType(typeof(DiscordResponse<Subscription>), DiscordRpcCommand.SUBSCRIBE)] | ||
[KnownSubType(typeof(DiscordResponse<SelectedVoiceChannel>), DiscordRpcCommand.GET_SELECTED_VOICE_CHANNEL)] | ||
public class DiscordResponse<T> : DiscordResponse | ||
public abstract class DiscordResponse<T> : DiscordResponse | ||
{ | ||
#pragma warning disable CS8618 | ||
public T Data { get; init; } | ||
#pragma warning restore CS8618 | ||
} | ||
|
||
public sealed class DiscordAuthorizeResponse : DiscordResponse<Authorize> { } | ||
public sealed class DiscordAuthenticateResponse : DiscordResponse<Authenticate> { } | ||
public sealed class DiscordGetVoiceSettingsResponse : DiscordResponse<VoiceSettings> { } | ||
public sealed class DiscordSubscribeResponse : DiscordResponse<Subscription> { } | ||
public sealed class DiscordGetSelectedVoiceChannelResponse : DiscordResponse<SelectedVoiceChannel> { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters