Browse Source

Merge branch 'release/3.x' of https://github.com/Discord-Net-Labs/Discord.Net-Labs into release/3.x

pull/1923/head
quin lynch 3 years ago
parent
commit
72b0c7bbe2
7 changed files with 63 additions and 31 deletions
  1. +2
    -0
      README.md
  2. +2
    -0
      docs/guides/interactions/application-commands/slash-commands/02-creating-slash-commands.md
  3. +5
    -0
      src/Discord.Net.Core/Entities/Interactions/ApplicationCommandProperties.cs
  4. +18
    -1
      src/Discord.Net.Core/Entities/Interactions/Context Menus/MessageCommandBuilder.cs
  5. +18
    -1
      src/Discord.Net.Core/Entities/Interactions/Context Menus/UserCommandBuilder.cs
  6. +0
    -5
      src/Discord.Net.Core/Entities/Interactions/SlashCommandProperties.cs
  7. +18
    -24
      src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs

+ 2
- 0
README.md View File

@@ -4,6 +4,8 @@

This repo is a custom fork of Discord.Net that introduces the newest features of discord for testing and experimenting. Nothing here is guaranteed to work but you are more than welcome to submit bugs in the issues tabs

If this projects benefits you (*and your financially stable*) consider donating or becoming a sponsor as it really helps out!

## Known issues
Labs will not work with normal package of Playwo's [InteractivityAddon](https://www.nuget.org/packages/Discord.InteractivityAddon). The reason is that his package depends on the base discord.net lib. You can instead use the [InteractivityAddon.Labs](https://www.nuget.org/packages/Discord.InteractivityAddon.Labs) package which implements some of the features added in Discord.Net-Labs.



+ 2
- 0
docs/guides/interactions/application-commands/slash-commands/02-creating-slash-commands.md View File

@@ -12,6 +12,8 @@ Guild commands are specific to the guild you specify when making them. Guild com

**Note**: Apps can have a maximum of 100 global commands, and an additional 100 guild-specific commands per guild.

**Note**: Global commands will take up to 1 hour to create, delete or modify on guilds. If you need to update a command quickly for testing you can create it as a guild command.

If you don't have the code for a bot ready yet please follow [this guide](https://docs.stillu.cc/guides/getting_started/first-bot.html).

## SlashCommandBuilder


+ 5
- 0
src/Discord.Net.Core/Entities/Interactions/ApplicationCommandProperties.cs View File

@@ -18,6 +18,11 @@ namespace Discord
/// </summary>
public Optional<string> Name { get; set; }

/// <summary>
/// Whether the command is enabled by default when the app is added to a guild. Default is <see langword="true"/>
/// </summary>
public Optional<bool> DefaultPermission { get; set; }

internal ApplicationCommandProperties() { }
}
}

+ 18
- 1
src/Discord.Net.Core/Entities/Interactions/Context Menus/MessageCommandBuilder.cs View File

@@ -36,6 +36,11 @@ namespace Discord
}
}

/// <summary>
/// Whether the command is enabled by default when the app is added to a guild
/// </summary>
public bool DefaultPermission { get; set; } = true;

private string _name { get; set; }

/// <summary>
@@ -49,6 +54,7 @@ namespace Discord
MessageCommandProperties props = new MessageCommandProperties()
{
Name = this.Name,
DefaultPermission = this.DefaultPermission
};

return props;
@@ -66,6 +72,17 @@ namespace Discord
{
this.Name = name;
return this;
}
}

/// <summary>
/// Sets the default permission of the current command.
/// </summary>
/// <param name="value">The default permission value to set.</param>
/// <returns>The current builder.</returns>
public MessageCommandBuilder WithDefaultPermission (bool value)
{
this.DefaultPermission = value;
return this;
}
}
}

+ 18
- 1
src/Discord.Net.Core/Entities/Interactions/Context Menus/UserCommandBuilder.cs View File

@@ -36,6 +36,11 @@ namespace Discord
}
}

/// <summary>
/// Whether the command is enabled by default when the app is added to a guild
/// </summary>
public bool DefaultPermission { get; set; } = true;

private string _name { get; set; }

/// <summary>
@@ -47,6 +52,7 @@ namespace Discord
UserCommandProperties props = new UserCommandProperties()
{
Name = this.Name,
DefaultPermission = this.DefaultPermission
};

return props;
@@ -64,6 +70,17 @@ namespace Discord
{
this.Name = name;
return this;
}
}

/// <summary>
/// Sets the default permission of the current command.
/// </summary>
/// <param name="value">The default permission value to set.</param>
/// <returns>The current builder.</returns>
public UserCommandBuilder WithDefaultPermission (bool value)
{
this.DefaultPermission = value;
return this;
}
}
}

+ 0
- 5
src/Discord.Net.Core/Entities/Interactions/SlashCommandProperties.cs View File

@@ -22,11 +22,6 @@ namespace Discord
/// </summary>
public Optional<List<ApplicationCommandOptionProperties>> Options { get; set; }

/// <summary>
/// Whether the command is enabled by default when the app is added to a guild. Default is <see langword="true"/>
/// </summary>
public Optional<bool> DefaultPermission { get; set; }

internal SlashCommandProperties() { }
}
}

+ 18
- 24
src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs View File

@@ -68,6 +68,9 @@ namespace Discord.Rest
{
Name = arg.Name.Value,
Type = arg.Type,
DefaultPermission = arg.DefaultPermission.IsSpecified
? arg.DefaultPermission.Value
: Optional<bool>.Unspecified
};

if (arg is SlashCommandProperties slashProps)
@@ -79,10 +82,6 @@ namespace Discord.Rest
model.Options = slashProps.Options.IsSpecified
? slashProps.Options.Value.Select(x => new Discord.API.ApplicationCommandOption(x)).ToArray()
: Optional<Discord.API.ApplicationCommandOption[]>.Unspecified;

model.DefaultPermission = slashProps.DefaultPermission.IsSpecified
? slashProps.DefaultPermission.Value
: Optional<bool>.Unspecified;
}

return await client.ApiClient.CreateGlobalApplicationCommandAsync(model, options).ConfigureAwait(false);
@@ -103,6 +102,9 @@ namespace Discord.Rest
{
Name = arg.Name.Value,
Type = arg.Type,
DefaultPermission = arg.DefaultPermission.IsSpecified
? arg.DefaultPermission.Value
: Optional<bool>.Unspecified
};

if (arg is SlashCommandProperties slashProps)
@@ -114,10 +116,6 @@ namespace Discord.Rest
model.Options = slashProps.Options.IsSpecified
? slashProps.Options.Value.Select(x => new Discord.API.ApplicationCommandOption(x)).ToArray()
: Optional<Discord.API.ApplicationCommandOption[]>.Unspecified;

model.DefaultPermission = slashProps.DefaultPermission.IsSpecified
? slashProps.DefaultPermission.Value
: Optional<bool>.Unspecified;
}

models.Add(model);
@@ -141,6 +139,9 @@ namespace Discord.Rest
{
Name = arg.Name.Value,
Type = arg.Type,
DefaultPermission = arg.DefaultPermission.IsSpecified
? arg.DefaultPermission.Value
: Optional<bool>.Unspecified
};

if (arg is SlashCommandProperties slashProps)
@@ -152,10 +153,6 @@ namespace Discord.Rest
model.Options = slashProps.Options.IsSpecified
? slashProps.Options.Value.Select(x => new Discord.API.ApplicationCommandOption(x)).ToArray()
: Optional<Discord.API.ApplicationCommandOption[]>.Unspecified;

model.DefaultPermission = slashProps.DefaultPermission.IsSpecified
? slashProps.DefaultPermission.Value
: Optional<bool>.Unspecified;
}

models.Add(model);
@@ -202,6 +199,9 @@ namespace Discord.Rest
var model = new Discord.API.Rest.ModifyApplicationCommandParams()
{
Name = args.Name,
DefaultPermission = args.DefaultPermission.IsSpecified
? args.DefaultPermission.Value
: Optional<bool>.Unspecified
};

if(args is SlashCommandProperties slashProps)
@@ -223,10 +223,6 @@ namespace Discord.Rest
model.Options = slashProps.Options.IsSpecified
? slashProps.Options.Value.Select(x => new Discord.API.ApplicationCommandOption(x)).ToArray()
: Optional<Discord.API.ApplicationCommandOption[]>.Unspecified;

model.DefaultPermission = slashProps.DefaultPermission.IsSpecified
? slashProps.DefaultPermission.Value
: Optional<bool>.Unspecified;
}

return await client.ApiClient.ModifyGlobalApplicationCommandAsync(model, command.Id, options).ConfigureAwait(false);
@@ -257,6 +253,9 @@ namespace Discord.Rest
{
Name = arg.Name.Value,
Type = arg.Type,
DefaultPermission = arg.DefaultPermission.IsSpecified
? arg.DefaultPermission.Value
: Optional<bool>.Unspecified
};

if (arg is SlashCommandProperties slashProps)
@@ -268,10 +267,6 @@ namespace Discord.Rest
model.Options = slashProps.Options.IsSpecified
? slashProps.Options.Value.Select(x => new Discord.API.ApplicationCommandOption(x)).ToArray()
: Optional<Discord.API.ApplicationCommandOption[]>.Unspecified;

model.DefaultPermission = slashProps.DefaultPermission.IsSpecified
? slashProps.DefaultPermission.Value
: Optional<bool>.Unspecified;
}

return await client.ApiClient.CreateGuildApplicationCommandAsync(model, guildId, options).ConfigureAwait(false);
@@ -291,6 +286,9 @@ namespace Discord.Rest
var model = new ModifyApplicationCommandParams()
{
Name = arg.Name,
DefaultPermission = arg.DefaultPermission.IsSpecified
? arg.DefaultPermission.Value
: Optional<bool>.Unspecified
};

if (arg is SlashCommandProperties slashProps)
@@ -302,10 +300,6 @@ namespace Discord.Rest
model.Options = slashProps.Options.IsSpecified
? slashProps.Options.Value.Select(x => new Discord.API.ApplicationCommandOption(x)).ToArray()
: Optional<Discord.API.ApplicationCommandOption[]>.Unspecified;

model.DefaultPermission = slashProps.DefaultPermission.IsSpecified
? slashProps.DefaultPermission.Value
: Optional<bool>.Unspecified;
}

return await client.ApiClient.ModifyGuildApplicationCommandAsync(model, guildId, command.Id, options).ConfigureAwait(false);


Loading…
Cancel
Save