Skip to content

Commit

Permalink
chore: some experimental stuff
Browse files Browse the repository at this point in the history
chore: some experimental stuff
  • Loading branch information
Lulalaby committed Jan 15, 2024
1 parent 5837253 commit fc04960
Show file tree
Hide file tree
Showing 11 changed files with 169 additions and 481 deletions.
4 changes: 2 additions & 2 deletions DisCatSharp.ApplicationCommands/Context/BaseContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class BaseContext
/// <summary>
/// Gets the guild this interaction was executed in.
/// </summary>
public DiscordGuild Guild { get; internal init; }
public DiscordGuild? Guild { get; internal init; }

/// <summary>
/// Gets the channel this interaction was executed in.
Expand All @@ -43,7 +43,7 @@ public class BaseContext
/// <summary>
/// Gets the member which executed this interaction, or null if the command is in a DM.
/// </summary>
public DiscordMember Member
public DiscordMember? Member
=> this.User is DiscordMember member ? member : null;

/// <summary>
Expand Down
7 changes: 4 additions & 3 deletions DisCatSharp.CommandsNext/EventArgs/CommandContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public DiscordChannel Channel
/// <summary>
/// Gets the guild in which the execution was triggered. This property is null for commands sent over direct messages.
/// </summary>
public DiscordGuild Guild
public DiscordGuild? Guild
=> this.Message.GuildId.HasValue ? this.Message.Guild : null;

/// <summary>
Expand Down Expand Up @@ -99,7 +99,7 @@ public DiscordMember Member
/// </summary>
internal CommandContext()
{
this._lazyMember = new(() => this.Guild != null && this.Guild.Members.TryGetValue(this.User.Id, out var member) ? member : this.Guild?.GetMemberAsync(this.User.Id).ConfigureAwait(false).GetAwaiter().GetResult());
this._lazyMember = new(() => this.Guild is not null && this.Guild.Members.TryGetValue(this.User.Id, out var member) ? member : this.Guild?.GetMemberAsync(this.User.Id).ConfigureAwait(false).GetAwaiter().GetResult());
}

/// <summary>
Expand Down Expand Up @@ -182,6 +182,7 @@ public ServiceContext(IServiceProvider services, IServiceScope scope)
/// <summary>
/// Disposes the command context.
/// </summary>
public void Dispose() => this.Scope?.Dispose();
public void Dispose()
=> this.Scope?.Dispose();
}
}
14 changes: 7 additions & 7 deletions DisCatSharp/Entities/Application/DiscordApplicationCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ public class DiscordApplicationCommand : SnowflakeObject, IEquatable<DiscordAppl
/// Sets the name localizations.
/// </summary>
[JsonProperty("name_localizations", NullValueHandling = NullValueHandling.Ignore)]
internal Dictionary<string, string> RawNameLocalizations { get; set; }
internal Dictionary<string, string>? RawNameLocalizations { get; set; }

/// <summary>
/// Gets the name localizations.
/// </summary>
[JsonIgnore]
public DiscordApplicationCommandLocalization NameLocalizations
=> new(this.RawNameLocalizations);
public DiscordApplicationCommandLocalization? NameLocalizations
=> this.RawNameLocalizations != null ? new(this.RawNameLocalizations) : null;

/// <summary>
/// Gets the description of this command.
Expand All @@ -55,14 +55,14 @@ public DiscordApplicationCommandLocalization NameLocalizations
/// Sets the description localizations.
/// </summary>
[JsonProperty("description_localizations", NullValueHandling = NullValueHandling.Ignore)]
internal Dictionary<string, string> RawDescriptionLocalizations { get; set; }
internal Dictionary<string, string>? RawDescriptionLocalizations { get; set; }

/// <summary>
/// Gets the description localizations.
/// </summary>
[JsonIgnore]
public DiscordApplicationCommandLocalization DescriptionLocalizations
=> new(this.RawDescriptionLocalizations);
public DiscordApplicationCommandLocalization? DescriptionLocalizations
=> this.RawDescriptionLocalizations != null ? new(this.RawDescriptionLocalizations) : null;

/// <summary>
/// Gets the potential parameters for this command.
Expand Down Expand Up @@ -145,7 +145,7 @@ public DiscordApplicationCommand(
{
if (!Utilities.IsValidSlashCommandName(name))
throw new ArgumentException("Invalid slash command name specified. It must be below 32 characters and not contain any whitespace.", nameof(name));
if (name.Any(ch => char.IsUpper(ch)))
if (name.Any(char.IsUpper))
throw new ArgumentException("Slash command name cannot have any upper case characters.", nameof(name));
if (description.Length > 100)
throw new ArgumentException("Slash command description cannot exceed 100 characters.", nameof(description));
Expand Down
49 changes: 49 additions & 0 deletions DisCatSharp/Entities/Core/IDisCatSharpCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using DisCatSharp.Enums.Core;

namespace DisCatSharp.Entities.Core;

/// <summary>
/// Interface for various command types like slash commands, user commands, message commands, text commands, etc.
/// </summary>
internal interface IDisCatSharpCommand
{
/// <summary>
/// Gets the id of the user who executes this command.
/// </summary>
ulong UserId { get; internal set; }

/// <summary>
/// Gets the id of the channel this command gets executed in.
/// </summary>
ulong ChannelId { get; internal set; }

/// <summary>
/// Gets the id of the guild this command gets executed in.
/// </summary>
ulong? GuildId { get; internal set; }

/// <summary>
/// Gets the id of the member who executes this command.
/// </summary>
ulong? MemberId { get; internal set; }

/// <summary>
/// Gets the id of the command.
/// </summary>
ulong? CommandId { get; internal set; }

/// <summary>
/// Gets the name of the command if <see cref="CommandId"/> is not available.
/// </summary>
string? CommandName { get; internal set; }

/// <summary>
/// Gets the type of the command.
/// </summary>
DisCatSharpCommandType CommandType { get; internal set; }

/// <summary>
/// Gets the command grouping type of the command.
/// </summary>
DisCatSharpCommandGroupingType CommandGroupingType { get; internal set; }
}
183 changes: 0 additions & 183 deletions DisCatSharp/Entities/DCS/DisCatSharpTeam.cs

This file was deleted.

71 changes: 0 additions & 71 deletions DisCatSharp/Entities/DCS/DisCatSharpTeamMember.cs

This file was deleted.

Loading

0 comments on commit fc04960

Please sign in to comment.