Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f0caf7b
Refactor Utilities static constructor
Sombody101 Jul 10, 2025
8f97b41
Refactor Utilities.Contains to use Array.Exists instead of a foreach …
Sombody101 Jul 10, 2025
f20d504
Refactor task completion source field name
Sombody101 Jul 10, 2025
efb2fb1
Add XML comment for DiscordIntentExtensions
Sombody101 Jul 10, 2025
645b464
Remove useless assignments from AddIntent and RemoveIntent
Sombody101 Jul 10, 2025
836bb52
Fix XML comment typos
Sombody101 Jul 10, 2025
a2d8980
Rename MaskedUrl 'alt_text' to 'altText'
Sombody101 Jul 10, 2025
60a40f2
Refactor method variable names
Sombody101 Jul 10, 2025
460538e
Refactored member and variable names, and made an implementation for …
Sombody101 Jul 10, 2025
2016e43
Added nullable annotations
Sombody101 Jul 10, 2025
31b49e4
Rename variables and add nullable annotations
Sombody101 Jul 10, 2025
a8a23c4
Refactored variable names and added nullable annotations
Sombody101 Jul 10, 2025
cd677e0
Refactored variable names, replaced nested if statements in loops wit…
Sombody101 Jul 13, 2025
7a3b018
Renamed internal field
Sombody101 Jul 13, 2025
0600ce1
Part of property rename (I'm never touching this file again)
Sombody101 Jul 13, 2025
dcfdb05
Added nullable annotation
Sombody101 Jul 13, 2025
7aa3e25
Added nullable annotations and refactored variable names
Sombody101 Jul 13, 2025
9f9849a
Added nullable annotations
Sombody101 Jul 13, 2025
7ad0b50
Added nullable annotations
Sombody101 Jul 13, 2025
7163f54
Added nullable annotations
Sombody101 Jul 13, 2025
09bc734
Added nullable annotation
Sombody101 Jul 13, 2025
2a10506
Added nullable annotations
Sombody101 Jul 13, 2025
f607715
Added nullable annotations
Sombody101 Jul 13, 2025
75bbe55
Added nullable annotations
Sombody101 Jul 13, 2025
0566768
Refactored variable names
Sombody101 Jul 13, 2025
bfc6a4f
Added nullable annotations
Sombody101 Jul 13, 2025
13119fe
Nullable typecast
Sombody101 Jul 13, 2025
040fc05
Added nullable annotation
Sombody101 Jul 13, 2025
b008e38
Forgave a null unbox, refactored variable names, added nullability an…
Sombody101 Jul 13, 2025
7db8ef2
Refactor field to property
Sombody101 Jul 15, 2025
eb7457a
Undo nullability on DiscordChannelType
Sombody101 Jul 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal sealed class RequirePermissionsCheck : IContextCheck<RequirePermissions
{
return ValueTask.FromResult<string?>(RequireGuildCheck.ErrorMessage);
}
else if (!context.Guild!.CurrentMember.PermissionsIn(context.Channel).HasAllPermissions(attribute.BotPermissions))
else if (!context.Guild!.CurrentMember!.PermissionsIn(context.Channel).HasAllPermissions(attribute.BotPermissions))
{
return ValueTask.FromResult<string?>("The bot did not have the needed permissions to execute this command.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private async ValueTask<DiscordApplicationCommand> ModifyGlobalCommandAsync(ulon
return await this.extension.Client.EditGuildApplicationCommandAsync
(
this.extension.DebugGuildId,
id,
id,
x => CopyToEditModel(command, x)
);
}
Expand Down Expand Up @@ -117,11 +117,11 @@ private static void CopyToEditModel(DiscordApplicationCommand command, Applicati
editModel.NameLocalizations = command.NameLocalizations;
editModel.DescriptionLocalizations = command.DescriptionLocalizations;
editModel.IntegrationTypes = command.IntegrationTypes is not null
? new(command.IntegrationTypes)
: Optional.FromNoValue<IEnumerable<DiscordApplicationIntegrationType>>();
? new((IReadOnlyList<DiscordApplicationIntegrationType?>)command.IntegrationTypes)
: Optional.FromNoValue<IEnumerable<DiscordApplicationIntegrationType?>>();
editModel.AllowedContexts = command.Contexts is not null
? new(command.Contexts)
: Optional.FromNoValue<IEnumerable<DiscordInteractionContextType>>();
? new((IReadOnlyList<DiscordInteractionContextType?>)command.Contexts)
: Optional.FromNoValue<IEnumerable<DiscordInteractionContextType?>>();
editModel.NSFW = command.NSFW;
editModel.Options = command.Options is not null
? new(command.Options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ public override async Task<bool> ExecuteCheckAsync(CommandContext ctx, bool help
return this.IgnoreDms;
}

DiscordMember bot = await ctx.Guild.GetMemberAsync(ctx.Client.CurrentUser.Id);
if (bot == null)
DiscordMember member = await ctx.Guild.GetMemberAsync(ctx.Client.CurrentUser.Id);
if (member == null)
{
return false;
}

if (bot.Id == ctx.Guild.OwnerId)
if (member.Id == ctx.Guild.OwnerId)
{
return true;
}

DiscordPermissions pbot = ctx.Channel.PermissionsFor(bot);
DiscordPermissions permissions = ctx.Channel.PermissionsFor(member);

return pbot.HasAllPermissions([..this.Permissions]);
return permissions.HasAllPermissions([..this.Permissions]);
}
}
16 changes: 8 additions & 8 deletions DSharpPlus/AsyncManualResetEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,35 @@ namespace DSharpPlus;
/// </summary>
internal class AsyncManualResetEvent
{
public bool IsSet => this.tsc != null && this.tsc.Task.IsCompleted;
public bool IsSet => this.taskCompletionSource != null && this.taskCompletionSource.Task.IsCompleted;

private TaskCompletionSource<bool> tsc;
private TaskCompletionSource<bool> taskCompletionSource;

public AsyncManualResetEvent()
: this(false)
{ }

public AsyncManualResetEvent(bool initialState)
{
this.tsc = new TaskCompletionSource<bool>();
this.taskCompletionSource = new TaskCompletionSource<bool>();

if (initialState)
{
this.tsc.TrySetResult(true);
this.taskCompletionSource.TrySetResult(true);
}
}

public Task WaitAsync() => this.tsc.Task;
public Task WaitAsync() => this.taskCompletionSource.Task;

public Task SetAsync() => Task.Run(() => this.tsc.TrySetResult(true));
public Task SetAsync() => Task.Run(() => this.taskCompletionSource.TrySetResult(true));

public void Reset()
{
while (true)
{
TaskCompletionSource<bool> tsc = this.tsc;
TaskCompletionSource<bool> completionSource = this.taskCompletionSource;

if (!tsc.Task.IsCompleted || Interlocked.CompareExchange(ref this.tsc, new TaskCompletionSource<bool>(), tsc) == tsc)
if (!completionSource.Task.IsCompleted || Interlocked.CompareExchange(ref this.taskCompletionSource, new TaskCompletionSource<bool>(), completionSource) == completionSource)
{
return;
}
Expand Down
16 changes: 8 additions & 8 deletions DSharpPlus/Clients/DiscordClient.Dispatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ internal async Task OnReadyEventAsync(ReadyPayload ready, JArray rawGuilds, JArr
foreach (DiscordRole xr in guild.Roles.Values)
{
xr.Discord = this;
xr.guild_id = guild.Id;
xr.guildId = guild.Id;
}

JObject rawGuild = rawGuildIndex[guild.Id];
Expand Down Expand Up @@ -1221,7 +1221,7 @@ internal async Task OnGuildCreateEventAsync(DiscordGuild guild, JArray rawMember
foreach (DiscordRole xr in guild.roles.Values)
{
xr.Discord = this;
xr.guild_id = guild.Id;
xr.guildId = guild.Id;
}

foreach (DiscordStageInstance instance in guild.stageInstances.Values)
Expand Down Expand Up @@ -1382,7 +1382,7 @@ internal async Task OnGuildUpdateEventAsync(DiscordGuild guild, JArray rawMember
foreach (DiscordRole xr in guild.roles.Values)
{
xr.Discord = this;
xr.guild_id = guild.Id;
xr.guildId = guild.Id;
}

await this.dispatcher.DispatchAsync(this, new GuildUpdatedEventArgs
Expand Down Expand Up @@ -1661,7 +1661,7 @@ internal async Task OnGuildMembersChunkEventAsync(JObject dat)
internal async Task OnGuildRoleCreateEventAsync(DiscordRole role, DiscordGuild guild)
{
role.Discord = this;
role.guild_id = guild.Id;
role.guildId = guild.Id;

guild.roles[role.Id] = role;

Expand All @@ -1679,7 +1679,7 @@ internal async Task OnGuildRoleUpdateEventAsync(DiscordRole role, DiscordGuild g
DiscordRole newRole = await guild.GetRoleAsync(role.Id);
DiscordRole oldRole = new()
{
guild_id = guild.Id,
guildId = guild.Id,
color = newRole.color,
Discord = this,
IsHoisted = newRole.IsHoisted,
Expand All @@ -1693,7 +1693,7 @@ internal async Task OnGuildRoleUpdateEventAsync(DiscordRole role, DiscordGuild g
emoji = newRole.emoji
};

newRole.guild_id = guild.Id;
newRole.guildId = guild.Id;
newRole.color = role.color;
newRole.IsHoisted = role.IsHoisted;
newRole.IsManaged = role.IsManaged;
Expand Down Expand Up @@ -2340,7 +2340,7 @@ internal async Task OnVoiceStateUpdateEventAsync(JObject raw)

if (vstateNew.ChannelId != null)
{
gld.voiceStates[vstateNew.UserId] = vstateNew;
gld.voiceStates[(ulong)vstateNew.UserId!] = vstateNew;
}

if (gld.members.TryGetValue(uid, out DiscordMember? mbr))
Expand Down Expand Up @@ -2822,7 +2822,7 @@ internal async Task OnInteractionCreateAsync(ulong? guildId, ulong channelId, Tr

if (guildId.HasValue)
{
c.Value.guild_id = guildId.Value;
c.Value.guildId = guildId.Value;
if (this.guilds.TryGetValue(guildId.Value, out DiscordGuild? guild))
{
guild.roles.TryAdd(c.Value.Id, c.Value);
Expand Down
Loading
Loading