Initial commit, basic proxying working

This commit is contained in:
Ske
2020-12-22 13:15:26 +01:00
parent c3f6becea4
commit a6fbd869be
109 changed files with 3539 additions and 359 deletions

22
Myriad/Types/Activity.cs Normal file
View File

@@ -0,0 +1,22 @@
namespace Myriad.Types
{
public record Activity: ActivityPartial
{
}
public record ActivityPartial
{
public string Name { get; init; }
public ActivityType Type { get; init; }
public string? Url { get; init; }
}
public enum ActivityType
{
Game = 0,
Streaming = 1,
Listening = 2,
Custom = 4,
Competing = 5
}
}

View File

@@ -0,0 +1,27 @@
using System.Collections.Generic;
namespace Myriad.Types
{
public record Application: ApplicationPartial
{
public string Name { get; init; }
public string? Icon { get; init; }
public string Description { get; init; }
public string[]? RpcOrigins { get; init; }
public bool BotPublic { get; init; }
public bool BotRequireCodeGrant { get; init; }
public User Owner { get; init; } // TODO: docs specify this is "partial", what does that mean
public string Summary { get; init; }
public string VerifyKey { get; init; }
public ulong? GuildId { get; init; }
public ulong? PrimarySkuId { get; init; }
public string? Slug { get; init; }
public string? CoverImage { get; init; }
}
public record ApplicationPartial
{
public ulong Id { get; init; }
public int Flags { get; init; }
}
}

View File

@@ -0,0 +1,13 @@
using System.Collections.Generic;
namespace Myriad.Types
{
public record ApplicationCommand
{
public ulong Id { get; init; }
public ulong ApplicationId { get; init; }
public string Name { get; init; }
public string Description { get; init; }
public ApplicationCommandOption[]? Options { get; init; }
}
}

View File

@@ -0,0 +1,9 @@
namespace Myriad.Types
{
public record ApplicationCommandInteractionData
{
public ulong Id { get; init; }
public string Name { get; init; }
public ApplicationCommandInteractionDataOption[] Options { get; init; }
}
}

View File

@@ -0,0 +1,9 @@
namespace Myriad.Types
{
public record ApplicationCommandInteractionDataOption
{
public string Name { get; init; }
public object? Value { get; init; }
public ApplicationCommandInteractionDataOption[]? Options { get; init; }
}
}

View File

@@ -0,0 +1,24 @@
namespace Myriad.Types
{
public record ApplicationCommandOption(ApplicationCommandOption.OptionType Type, string Name, string Description)
{
public enum OptionType
{
Subcommand = 1,
SubcommandGroup = 2,
String = 3,
Integer = 4,
Boolean = 5,
User = 6,
Channel = 7,
Role = 8
}
public bool Default { get; init; }
public bool Required { get; init; }
public Choice[]? Choices { get; init; }
public ApplicationCommandOption[]? Options { get; init; }
public record Choice(string Name, object Value);
}
}

View File

@@ -0,0 +1,19 @@
namespace Myriad.Types
{
public record Interaction
{
public enum InteractionType
{
Ping = 1,
ApplicationCommand = 2
}
public ulong Id { get; init; }
public InteractionType Type { get; init; }
public ApplicationCommandInteractionData? Data { get; init; }
public ulong GuildId { get; init; }
public ulong ChannelId { get; init; }
public GuildMember Member { get; init; }
public string Token { get; init; }
}
}

View File

@@ -0,0 +1,15 @@
using System.Collections.Generic;
using Myriad.Rest.Types;
namespace Myriad.Types
{
public record InteractionApplicationCommandCallbackData
{
public bool? Tts { get; init; }
public string Content { get; init; }
public Embed[]? Embeds { get; init; }
public AllowedMentions? AllowedMentions { get; init; }
public Message.MessageFlags Flags { get; init; }
}
}

View File

@@ -0,0 +1,17 @@
namespace Myriad.Types
{
public record InteractionResponse
{
public enum ResponseType
{
Pong = 1,
Acknowledge = 2,
ChannelMessage = 3,
ChannelMessageWithSource = 4,
AckWithSource = 5
}
public ResponseType Type { get; init; }
public InteractionApplicationCommandCallbackData? Data { get; init; }
}
}

40
Myriad/Types/Channel.cs Normal file
View File

@@ -0,0 +1,40 @@
namespace Myriad.Types
{
public record Channel
{
public enum ChannelType
{
GuildText = 0,
Dm = 1,
GuildVoice = 2,
GroupDm = 3,
GuildCategory = 4,
GuildNews = 5,
GuildStore = 6
}
public ulong Id { get; init; }
public ChannelType Type { get; init; }
public ulong? GuildId { get; init; }
public int? Position { get; init; }
public string? Name { get; init; }
public string? Topic { get; init; }
public bool? Nsfw { get; init; }
public long? ParentId { get; init; }
public Overwrite[]? PermissionOverwrites { get; init; }
public record Overwrite
{
public ulong Id { get; init; }
public OverwriteType Type { get; init; }
public PermissionSet Allow { get; init; }
public PermissionSet Deny { get; init; }
}
public enum OverwriteType
{
Role = 0,
Member = 1
}
}
}

64
Myriad/Types/Embed.cs Normal file
View File

@@ -0,0 +1,64 @@
using System.Collections.Generic;
namespace Myriad.Types
{
public record Embed
{
public string? Title { get; init; }
public string? Type { get; init; }
public string? Description { get; init; }
public string? Url { get; init; }
public string? Timestamp { get; init; }
public uint? Color { get; init; }
public EmbedFooter? Footer { get; init; }
public EmbedImage? Image { get; init; }
public EmbedThumbnail? Thumbnail { get; init; }
public EmbedVideo? Video { get; init; }
public EmbedProvider? Provider { get; init; }
public EmbedAuthor? Author { get; init; }
public Field[]? Fields { get; init; }
public record EmbedFooter (
string Text,
string? IconUrl = null,
string? ProxyIconUrl = null
);
public record EmbedImage (
string? Url,
uint? Width = null,
uint? Height = null
);
public record EmbedThumbnail (
string? Url,
string? ProxyUrl = null,
uint? Width = null,
uint? Height = null
);
public record EmbedVideo (
string? Url,
uint? Width = null,
uint? Height = null
);
public record EmbedProvider (
string? Name,
string? Url
);
public record EmbedAuthor (
string? Name = null,
string? Url = null,
string? IconUrl = null,
string? ProxyIconUrl = null
);
public record Field (
string Name,
string Value,
bool Inline = false
);
}
}

9
Myriad/Types/Emoji.cs Normal file
View File

@@ -0,0 +1,9 @@
namespace Myriad.Types
{
public record Emoji
{
public ulong? Id { get; init; }
public string? Name { get; init; }
public bool? Animated { get; init; }
}
}

View File

@@ -0,0 +1,13 @@
namespace Myriad.Types
{
public record GatewayInfo
{
public string Url { get; init; }
public record Bot: GatewayInfo
{
public int Shards { get; init; }
public SessionStartLimit SessionStartLimit { get; init; }
}
}
}

View File

@@ -0,0 +1,9 @@
namespace Myriad.Types
{
public record SessionStartLimit
{
public int Total { get; init; }
public int Remaining { get; init; }
public int ResetAfter { get; init; }
}
}

24
Myriad/Types/Guild.cs Normal file
View File

@@ -0,0 +1,24 @@
using System.Collections.Generic;
namespace Myriad.Types
{
public record Guild
{
public ulong Id { get; init; }
public string Name { get; init; }
public string? Icon { get; init; }
public string? Splash { get; init; }
public string? DiscoverySplash { get; init; }
public bool? Owner { get; init; }
public ulong OwnerId { get; init; }
public string Region { get; init; }
public ulong? AfkChannelId { get; init; }
public int AfkTimeout { get; init; }
public bool? WidgetEnabled { get; init; }
public bool? WidgetChannelId { get; init; }
public int VerificationLevel { get; init; }
public Role[] Roles { get; init; }
public string[] Features { get; init; }
}
}

View File

@@ -0,0 +1,14 @@
namespace Myriad.Types
{
public record GuildMember: GuildMemberPartial
{
public User User { get; init; }
}
public record GuildMemberPartial
{
public string Nick { get; init; }
public ulong[] Roles { get; init; }
public string JoinedAt { get; init; }
}
}

85
Myriad/Types/Message.cs Normal file
View File

@@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.Net.Mail;
namespace Myriad.Types
{
public record Message
{
[Flags]
public enum MessageFlags
{
Crossposted = 1 << 0,
IsCrosspost = 1 << 1,
SuppressEmbeds = 1 << 2,
SourceMessageDeleted = 1 << 3,
Urgent = 1 << 4,
Ephemeral = 1 << 6
}
public enum MessageType
{
Default = 0,
RecipientAdd = 1,
RecipientRemove = 2,
Call = 3,
ChannelNameChange = 4,
ChannelIconChange = 5,
ChannelPinnedMessage = 6,
GuildMemberJoin = 7,
UserPremiumGuildSubscription = 8,
UserPremiumGuildSubscriptionTier1 = 9,
UserPremiumGuildSubscriptionTier2 = 10,
UserPremiumGuildSubscriptionTier3 = 11,
ChannelFollowAdd = 12,
GuildDiscoveryDisqualified = 14,
GuildDiscoveryRequalified = 15,
Reply = 19,
ApplicationCommand = 20
}
public ulong Id { get; init; }
public ulong ChannelId { get; init; }
public ulong? GuildId { get; init; }
public User Author { get; init; }
public string? Content { get; init; }
public string? Timestamp { get; init; }
public string? EditedTimestamp { get; init; }
public bool Tts { get; init; }
public bool MentionEveryone { get; init; }
public User.Extra[] Mentions { get; init; }
public ulong[] MentionRoles { get; init; }
public Attachment[] Attachments { get; init; }
public Embed[] Embeds { get; init; }
public Reaction[] Reactions { get; init; }
public bool Pinned { get; init; }
public ulong? WebhookId { get; init; }
public MessageType Type { get; init; }
public Reference? MessageReference { get; set; }
public MessageFlags Flags { get; init; }
// todo: null vs. absence
public Message? ReferencedMessage { get; init; }
public record Reference(ulong? GuildId, ulong? ChannelId, ulong? MessageId);
public record Attachment
{
public ulong Id { get; init; }
public string Filename { get; init; }
public int Size { get; init; }
public string Url { get; init; }
public string ProxyUrl { get; init; }
public int? Width { get; init; }
public int? Height { get; init; }
}
public record Reaction
{
public int Count { get; init; }
public bool Me { get; init; }
public Emoji Emoji { get; init; }
}
}
}

View File

@@ -0,0 +1,47 @@
using System;
namespace Myriad.Types
{
[Flags]
public enum PermissionSet: ulong
{
CreateInvite = 0x1,
KickMembers = 0x2,
BanMembers = 0x4,
Administrator = 0x8,
ManageChannels = 0x10,
ManageGuild = 0x20,
AddReactions = 0x40,
ViewAuditLog = 0x80,
PrioritySpeaker = 0x100,
Stream = 0x200,
ViewChannel = 0x400,
SendMessages = 0x800,
SendTtsMessages = 0x1000,
ManageMessages = 0x2000,
EmbedLinks = 0x4000,
AttachFiles = 0x8000,
ReadMessageHistory = 0x10000,
MentionEveryone = 0x20000,
UseExternalEmojis = 0x40000,
ViewGuildInsights = 0x80000,
Connect = 0x100000,
Speak = 0x200000,
MuteMembers = 0x400000,
DeafenMembers = 0x800000,
MoveMembers = 0x1000000,
UseVad = 0x2000000,
ChangeNickname = 0x4000000,
ManageNicknames = 0x8000000,
ManageRoles = 0x10000000,
ManageWebhooks = 0x20000000,
ManageEmojis = 0x40000000,
// Special:
None = 0,
All = 0x7FFFFFFF,
Dm = ViewChannel | SendMessages | ReadMessageHistory | AddReactions | AttachFiles | EmbedLinks |
UseExternalEmojis | Connect | Speak | UseVad
}
}

View File

@@ -0,0 +1,6 @@
namespace Myriad.Types
{
public static class Permissions
{
}
}

14
Myriad/Types/Role.cs Normal file
View File

@@ -0,0 +1,14 @@
namespace Myriad.Types
{
public record Role
{
public ulong Id { get; init; }
public string Name { get; init; }
public uint Color { get; init; }
public bool Hoist { get; init; }
public int Position { get; init; }
public PermissionSet Permissions { get; init; }
public bool Managed { get; init; }
public bool Mentionable { get; init; }
}
}

38
Myriad/Types/User.cs Normal file
View File

@@ -0,0 +1,38 @@
using System;
namespace Myriad.Types
{
public record User
{
[Flags]
public enum Flags
{
DiscordEmployee = 1 << 0,
PartneredServerOwner = 1 << 1,
HypeSquadEvents = 1 << 2,
BugHunterLevel1 = 1 << 3,
HouseBravery = 1 << 6,
HouseBrilliance = 1 << 7,
HouseBalance = 1 << 8,
EarlySupporter = 1 << 9,
TeamUser = 1 << 10,
System = 1 << 12,
BugHunterLevel2 = 1 << 14,
VerifiedBot = 1 << 16,
EarlyVerifiedBotDeveloper = 1 << 17
}
public ulong Id { get; init; }
public string Username { get; init; }
public string Discriminator { get; init; }
public string? Avatar { get; init; }
public bool Bot { get; init; }
public bool? System { get; init; }
public Flags PublicFlags { get; init; }
public record Extra: User
{
public GuildMemberPartial? Member { get; init; }
}
}
}

21
Myriad/Types/Webhook.cs Normal file
View File

@@ -0,0 +1,21 @@
namespace Myriad.Types
{
public record Webhook
{
public ulong Id { get; init; }
public WebhookType Type { get; init; }
public ulong? GuildId { get; init; }
public ulong ChannelId { get; init; }
public User? User { get; init; }
public string? Name { get; init; }
public string? Avatar { get; init; }
public string? Token { get; init; }
public ulong? ApplicationId { get; init; }
}
public enum WebhookType
{
Incoming = 1,
ChannelFollower = 2
}
}