Browse Source

Fixed build errors and started an example project for development purposes and to be a starting-off point for newcomers to the slash command ecosystem,

pull/1733/head^2
Cosma George 4 years ago
parent
commit
16f6a4c482
10 changed files with 73 additions and 13 deletions
  1. +28
    -0
      Discord.Net.sln
  2. +17
    -0
      SlashCommandsExample/Program.cs
  3. +7
    -0
      SlashCommandsExample/Properties/launchSettings.json
  4. +8
    -0
      SlashCommandsExample/SlashCommandsExample.csproj
  5. +1
    -1
      src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommand.cs
  6. +2
    -2
      src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandOption.cs
  7. +2
    -2
      src/Discord.Net.Rest/Extensions/EntityExtensions.cs
  8. +6
    -6
      src/Discord.Net.WebSocket/Entities/Interaction/SocketApplicationCommandOption.cs
  9. +1
    -1
      src/Discord.Net.WebSocket/Entities/Interaction/SocketInteractionData.cs
  10. +1
    -1
      src/Discord.Net.WebSocket/Entities/Interaction/SocketInteractionDataOption.cs

+ 28
- 0
Discord.Net.sln View File

@@ -42,6 +42,21 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Discord.Net.Examples", "src
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "idn", "samples\idn\idn.csproj", "{4A03840B-9EBE-47E3-89AB-E0914DF21AFB}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "idn", "samples\idn\idn.csproj", "{4A03840B-9EBE-47E3-89AB-E0914DF21AFB}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SlashCommandsExample", "SlashCommandsExample\SlashCommandsExample.csproj", "{2CB2A016-CCEB-4A67-BC7B-098F114D7C27}"
ProjectSection(ProjectDependencies) = postProject
{6BDEEC08-417B-459F-9CA3-FF8BAB18CAC7} = {6BDEEC08-417B-459F-9CA3-FF8BAB18CAC7}
{9AFAB80E-D2D3-4EDB-B58C-BACA78D1EA30} = {9AFAB80E-D2D3-4EDB-B58C-BACA78D1EA30}
{BFC6DC28-0351-4573-926A-D4124244C04F} = {BFC6DC28-0351-4573-926A-D4124244C04F}
{E169E15A-E82C-45BF-8C24-C2CADB7093AA} = {E169E15A-E82C-45BF-8C24-C2CADB7093AA}
{47820065-3CFB-401C-ACEA-862BD564A404} = {47820065-3CFB-401C-ACEA-862BD564A404}
{DBF8B16E-5967-4480-8EDE-15D98A0DF0C4} = {DBF8B16E-5967-4480-8EDE-15D98A0DF0C4}
{FC67057C-E92F-4E1C-98BE-46F839C8AD71} = {FC67057C-E92F-4E1C-98BE-46F839C8AD71}
{91E9E7BD-75C9-4E98-84AA-2C271922E5C2} = {91E9E7BD-75C9-4E98-84AA-2C271922E5C2}
{688FD1D8-7F01-4539-B2E9-F473C5D699C7} = {688FD1D8-7F01-4539-B2E9-F473C5D699C7}
{078DD7E6-943D-4D09-AFC2-D2BA58B76C9C} = {078DD7E6-943D-4D09-AFC2-D2BA58B76C9C}
{BBA8E7FB-C834-40DC-822F-B112CB7F0140} = {BBA8E7FB-C834-40DC-822F-B112CB7F0140}
EndProjectSection
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -232,6 +247,18 @@ Global
{4A03840B-9EBE-47E3-89AB-E0914DF21AFB}.Release|x64.Build.0 = Release|Any CPU {4A03840B-9EBE-47E3-89AB-E0914DF21AFB}.Release|x64.Build.0 = Release|Any CPU
{4A03840B-9EBE-47E3-89AB-E0914DF21AFB}.Release|x86.ActiveCfg = Release|Any CPU {4A03840B-9EBE-47E3-89AB-E0914DF21AFB}.Release|x86.ActiveCfg = Release|Any CPU
{4A03840B-9EBE-47E3-89AB-E0914DF21AFB}.Release|x86.Build.0 = Release|Any CPU {4A03840B-9EBE-47E3-89AB-E0914DF21AFB}.Release|x86.Build.0 = Release|Any CPU
{2CB2A016-CCEB-4A67-BC7B-098F114D7C27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2CB2A016-CCEB-4A67-BC7B-098F114D7C27}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2CB2A016-CCEB-4A67-BC7B-098F114D7C27}.Debug|x64.ActiveCfg = Debug|Any CPU
{2CB2A016-CCEB-4A67-BC7B-098F114D7C27}.Debug|x64.Build.0 = Debug|Any CPU
{2CB2A016-CCEB-4A67-BC7B-098F114D7C27}.Debug|x86.ActiveCfg = Debug|Any CPU
{2CB2A016-CCEB-4A67-BC7B-098F114D7C27}.Debug|x86.Build.0 = Debug|Any CPU
{2CB2A016-CCEB-4A67-BC7B-098F114D7C27}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2CB2A016-CCEB-4A67-BC7B-098F114D7C27}.Release|Any CPU.Build.0 = Release|Any CPU
{2CB2A016-CCEB-4A67-BC7B-098F114D7C27}.Release|x64.ActiveCfg = Release|Any CPU
{2CB2A016-CCEB-4A67-BC7B-098F114D7C27}.Release|x64.Build.0 = Release|Any CPU
{2CB2A016-CCEB-4A67-BC7B-098F114D7C27}.Release|x86.ActiveCfg = Release|Any CPU
{2CB2A016-CCEB-4A67-BC7B-098F114D7C27}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@@ -251,6 +278,7 @@ Global
{FC67057C-E92F-4E1C-98BE-46F839C8AD71} = {C7CF5621-7D36-433B-B337-5A2E3C101A71} {FC67057C-E92F-4E1C-98BE-46F839C8AD71} = {C7CF5621-7D36-433B-B337-5A2E3C101A71}
{47820065-3CFB-401C-ACEA-862BD564A404} = {BB59D5B5-E7B0-4BF4-8F82-D14431B2799B} {47820065-3CFB-401C-ACEA-862BD564A404} = {BB59D5B5-E7B0-4BF4-8F82-D14431B2799B}
{4A03840B-9EBE-47E3-89AB-E0914DF21AFB} = {BB59D5B5-E7B0-4BF4-8F82-D14431B2799B} {4A03840B-9EBE-47E3-89AB-E0914DF21AFB} = {BB59D5B5-E7B0-4BF4-8F82-D14431B2799B}
{2CB2A016-CCEB-4A67-BC7B-098F114D7C27} = {BB59D5B5-E7B0-4BF4-8F82-D14431B2799B}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D2404771-EEC8-45F2-9D71-F3373F6C1495} SolutionGuid = {D2404771-EEC8-45F2-9D71-F3373F6C1495}


+ 17
- 0
SlashCommandsExample/Program.cs View File

@@ -0,0 +1,17 @@
/*
* This project, is at this moment used for testing and debugging the new and experimental Slash Commands.
* After all testing has been done, and the project is ready to be integrated into the main Discord.Net ecosystem
* this project should be re-made into one that could be used as an example usage of the new Slash Command Service.
*/
using System;

namespace SlashCommandsExample
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}

+ 7
- 0
SlashCommandsExample/Properties/launchSettings.json View File

@@ -0,0 +1,7 @@
{
"profiles": {
"SlashCommandsExample": {
"commandName": "Project"
}
}
}

+ 8
- 0
SlashCommandsExample/SlashCommandsExample.csproj View File

@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

</Project>

+ 1
- 1
src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommand.cs View File

@@ -60,7 +60,7 @@ namespace Discord.Rest
this.Description = model.Description; this.Description = model.Description;


this.Options = model.Options.IsSpecified this.Options = model.Options.IsSpecified
? model.Options.Value.Select(x => RestApplicationCommandOption.Create(x)).ToImmutableArray()
? model.Options.Value.Select(x => RestApplicationCommandOption.Create(x)).ToImmutableArray().ToReadOnlyCollection()
: null; : null;
} }




+ 2
- 2
src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandOption.cs View File

@@ -60,11 +60,11 @@ namespace Discord.Rest
this.Required = model.Required.Value; this.Required = model.Required.Value;


this.Options = model.Options.IsSpecified this.Options = model.Options.IsSpecified
? model.Options.Value.Select(x => Create(x)).ToImmutableArray()
? model.Options.Value.Select(x => Create(x)).ToImmutableArray().ToReadOnlyCollection()
: null; : null;


this.Choices = model.Choices.IsSpecified this.Choices = model.Choices.IsSpecified
? model.Choices.Value.Select(x => new RestApplicationCommandChoice(x)).ToImmutableArray()
? model.Choices.Value.Select(x => new RestApplicationCommandChoice(x)).ToImmutableArray().ToReadOnlyCollection()
: null; : null;
} }




+ 2
- 2
src/Discord.Net.Rest/Extensions/EntityExtensions.cs View File

@@ -37,8 +37,8 @@ namespace Discord.Rest
public static RoleTags ToEntity(this API.RoleTags model) public static RoleTags ToEntity(this API.RoleTags model)
{ {
return new RoleTags( return new RoleTags(
model.BotId.IsSpecified ? model.BotId.Value : null,
model.IntegrationId.IsSpecified ? model.IntegrationId.Value : null,
model.BotId.IsSpecified ? model.BotId.Value : (ulong?)null,
model.IntegrationId.IsSpecified ? model.IntegrationId.Value : (ulong?)null,
model.IsPremiumSubscriber.IsSpecified ? true : false); model.IsPremiumSubscriber.IsSpecified ? true : false);
} }
public static API.Embed ToModel(this Embed entity) public static API.Embed ToModel(this Embed entity)


+ 6
- 6
src/Discord.Net.WebSocket/Entities/Interaction/SocketApplicationCommandOption.cs View File

@@ -54,19 +54,19 @@ namespace Discord.WebSocket


this.Default = model.Default.IsSpecified this.Default = model.Default.IsSpecified
? model.Default.Value ? model.Default.Value
: null;
: (bool?)null;


this.Required = model.Required.IsSpecified this.Required = model.Required.IsSpecified
? model.Required.Value ? model.Required.Value
: null;
: (bool?)null;


this.Choices = model.Choices.IsSpecified this.Choices = model.Choices.IsSpecified
? model.Choices.Value.Select(x => SocketApplicationCommandChoice.Create(x)).ToImmutableArray()
: new ImmutableArray<SocketApplicationCommandChoice>();
? model.Choices.Value.Select(x => SocketApplicationCommandChoice.Create(x)).ToImmutableArray().ToReadOnlyCollection()
: null;


this.Options = model.Options.IsSpecified this.Options = model.Options.IsSpecified
? model.Options.Value.Select(x => SocketApplicationCommandOption.Create(x)).ToImmutableArray()
: new ImmutableArray<SocketApplicationCommandOption>();
? model.Options.Value.Select(x => SocketApplicationCommandOption.Create(x)).ToImmutableArray().ToReadOnlyCollection()
: null;
} }


IReadOnlyCollection<IApplicationCommandOptionChoice> IApplicationCommandOption.Choices => Choices; IReadOnlyCollection<IApplicationCommandOptionChoice> IApplicationCommandOption.Choices => Choices;


+ 1
- 1
src/Discord.Net.WebSocket/Entities/Interaction/SocketInteractionData.cs View File

@@ -38,7 +38,7 @@ namespace Discord.WebSocket
this.guildId = guildId; this.guildId = guildId;


this.Options = model.Options.IsSpecified this.Options = model.Options.IsSpecified
? model.Options.Value.Select(x => new SocketInteractionDataOption(x, this.Discord, guildId)).ToImmutableArray()
? model.Options.Value.Select(x => new SocketInteractionDataOption(x, this.Discord, guildId)).ToImmutableArray().ToReadOnlyCollection()
: null; : null;
} }




+ 1
- 1
src/Discord.Net.WebSocket/Entities/Interaction/SocketInteractionDataOption.cs View File

@@ -36,7 +36,7 @@ namespace Discord.WebSocket
this.guild = guild; this.guild = guild;


this.Options = model.Options.IsSpecified this.Options = model.Options.IsSpecified
? model.Options.Value.Select(x => new SocketInteractionDataOption(x, discord, guild)).ToImmutableArray()
? model.Options.Value.Select(x => new SocketInteractionDataOption(x, discord, guild)).ToImmutableArray().ToReadOnlyCollection()
: null; : null;


} }


Loading…
Cancel
Save