Skip to content

Commit

Permalink
Fix missed breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
FloatingMilkshake committed Oct 25, 2024
1 parent 0c92f38 commit 78d5e65
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 46 deletions.
20 changes: 10 additions & 10 deletions Commands/InteractionCommands/AnnouncementInteractions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,26 +261,26 @@ public async Task AnnounceBuildSlashCommand(SlashCommandContext ctx,

internal class WindowsVersionChoiceProvider : IChoiceProvider
{
public async ValueTask<IReadOnlyDictionary<string, object>> ProvideAsync(CommandParameter _)
public async ValueTask<IEnumerable<DiscordApplicationCommandOptionChoice>> ProvideAsync(CommandParameter _)
{
return new Dictionary<string, object>
return new List<DiscordApplicationCommandOptionChoice>
{
{ "Windows 10", "10" },
{ "Windows 11", "11" }
new("Windows 10", "10"),
new("Windows 11", "11")
};
}
}

internal class WindowsInsiderChannelChoiceProvider : IChoiceProvider
{
public async ValueTask<IReadOnlyDictionary<string, object>> ProvideAsync(CommandParameter _)
public async ValueTask<IEnumerable<DiscordApplicationCommandOptionChoice>> ProvideAsync(CommandParameter _)
{
return new Dictionary<string, object>
return new List<DiscordApplicationCommandOptionChoice>
{
{ "Canary Channel", "Canary" },
{ "Dev Channel", "Dev" },
{ "Beta Channel", "Beta" },
{ "Release Preview Channel", "RP" }
new("Canary Channel", "Canary"),
new("Dev Channel", "Dev"),
new("Beta Channel", "Beta"),
new("Release Preview Channel", "RP")
};
}
}
Expand Down
20 changes: 10 additions & 10 deletions Commands/InteractionCommands/RoleInteractions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,18 @@ public async Task RemoveRole(

internal class RoleCommandChoiceProvider : IChoiceProvider
{
public async ValueTask<IReadOnlyDictionary<string, object>> ProvideAsync(CommandParameter _)
public async ValueTask<IEnumerable<DiscordApplicationCommandOptionChoice>> ProvideAsync(CommandParameter _)
{
return new Dictionary<string, object>
return new List<DiscordApplicationCommandOptionChoice>
{
{ "Windows 11 Insiders (Canary)", "insiderCanary" },
{ "Windows 11 Insiders (Dev)", "insiderDev" },
{ "Windows 11 Insiders (Beta)", "insiderBeta" },
{ "Windows 11 Insiders (Release Preview)", "insiderRP" },
{ "Windows 10 Insiders (Release Preview)", "insider10RP" },
{ "Windows 10 Insiders (Beta)", "insider10Beta" },
{ "Patch Tuesday", "patchTuesday" },
{ "Giveaways", "giveaways" }
new("Windows 11 Insiders (Canary)", "insiderCanary"),
new("Windows 11 Insiders (Dev)", "insiderDev"),
new("Windows 11 Insiders (Beta)", "insiderBeta"),
new("Windows 11 Insiders (Release Preview)", "insiderRP"),
new("Windows 10 Insiders (Release Preview)", "insider10RP"),
new("Windows 10 Insiders (Beta)", "insider10Beta"),
new("Patch Tuesday", "patchTuesday"),
new("Giveaways", "giveaways")
};
}
}
Expand Down
16 changes: 8 additions & 8 deletions Commands/InteractionCommands/TechSupportInteractions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ public async Task RedistsCommand(

internal class VcRedistChoiceProvider : IChoiceProvider
{
public async ValueTask<IReadOnlyDictionary<string, object>> ProvideAsync(CommandParameter _)
public async ValueTask<IEnumerable<DiscordApplicationCommandOptionChoice>> ProvideAsync(CommandParameter _)
{
return new Dictionary<string, object>
return new List<DiscordApplicationCommandOptionChoice>
{
{ "Visual Studio 2015+ - v140", "140" },
{ "Visual Studio 2013 - v120", "120" },
{ "Visual Studio 2012 - v110", "110" },
{ "Visual Studio 2010 - v100", "100" },
{ "Visual Studio 2008 - v90", "90" },
{ "Visual Studio 2005 - v80", "80" }
new("Visual Studio 2015+ - v140", "140"),
new("Visual Studio 2013 - v120", "120"),
new("Visual Studio 2012 - v110", "110"),
new("Visual Studio 2010 - v100", "100"),
new("Visual Studio 2008 - v90", "90"),
new("Visual Studio 2005 - v80", "80")
};
}
}
Expand Down
6 changes: 3 additions & 3 deletions Commands/InteractionCommands/UserNoteInteractions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ public async Task ShowUserNoteAsync(SlashCommandContext ctx,

private class NotesAutocompleteProvider : IAutoCompleteProvider
{
public async ValueTask<IReadOnlyDictionary<string, object>> AutoCompleteAsync(AutoCompleteContext ctx)
public async ValueTask<IEnumerable<DiscordAutoCompleteChoice>> AutoCompleteAsync(AutoCompleteContext ctx)
{
var list = new Dictionary<string, object>();
var list = new List<DiscordAutoCompleteChoice>();

var useroption = ctx.Options.FirstOrDefault(x => x.Name == "user");
if (useroption == default)
Expand All @@ -223,7 +223,7 @@ public async ValueTask<IReadOnlyDictionary<string, object>> AutoCompleteAsync(Au
var focusedOption = ctx.Options.FirstOrDefault(option => option.Focused);
if (focusedOption is not null) // TODO(#202): is this right?
if (note.Value.NoteText.Contains((string)focusedOption.Value) || noteString.ToLower().Contains(focusedOption.Value.ToString().ToLower()))
list.Add(noteString, StringHelpers.Pad(note.Value.NoteId));
list.Add(new DiscordAutoCompleteChoice(noteString, StringHelpers.Pad(note.Value.NoteId)));
}

return list;
Expand Down
6 changes: 3 additions & 3 deletions Commands/InteractionCommands/WarningInteractions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ await LogChannelHelper.LogMessageAsync("mod",

internal partial class WarningsAutocompleteProvider : IAutoCompleteProvider
{
public async ValueTask<IReadOnlyDictionary<string, object>> AutoCompleteAsync(AutoCompleteContext ctx)
public async ValueTask<IEnumerable<DiscordAutoCompleteChoice>> AutoCompleteAsync(AutoCompleteContext ctx)
{
var list = new Dictionary<string, object>();
var list = new List<DiscordAutoCompleteChoice>();

var useroption = ctx.Options.FirstOrDefault(x => x.Name == "user");
if (useroption == default)
Expand All @@ -169,7 +169,7 @@ public async ValueTask<IReadOnlyDictionary<string, object>> AutoCompleteAsync(Au
var focusedOption = ctx.Options.FirstOrDefault(option => option.Focused);
if (focusedOption is not null) // TODO(#202): is this right?
if (warning.Value.WarnReason.Contains((string)focusedOption.Value) || warningString.ToLower().Contains(focusedOption.Value.ToString().ToLower()))
list.Add(warningString, StringHelpers.Pad(warning.Value.WarningId));
list.Add(new DiscordAutoCompleteChoice(warningString, StringHelpers.Pad(warning.Value.WarningId)));
}

return list;
Expand Down
27 changes: 15 additions & 12 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public async Task ReconnectRequestedAsync(IGatewayClient _) { }
public async Task ReconnectFailedAsync(IGatewayClient _) { }

public async Task SessionInvalidatedAsync(IGatewayClient _) { }

public async Task ResumeAttemptedAsync(IGatewayClient _) { }



Expand Down Expand Up @@ -179,20 +181,21 @@ static async Task Main(string[] _)
discordBuilder.ConfigureServices(services =>
{
services.Replace<IGatewayController, GatewayController>();
services.AddCommandsExtension(builder =>
{
builder.CommandErrored += ErrorEvents.CommandErrored;
});

discordBuilder.UseCommands((_, builder) =>
{
builder.CommandErrored += ErrorEvents.CommandErrored;

// Interaction commands
var slashCommandClasses = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsClass && t.Namespace == "Cliptok.Commands.InteractionCommands" && !t.IsNested);
foreach (var type in slashCommandClasses)
builder.AddCommands(type, cfgjson.ServerID);
// Interaction commands
var slashCommandClasses = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsClass && t.Namespace == "Cliptok.Commands.InteractionCommands" && !t.IsNested);
foreach (var type in slashCommandClasses)
builder.AddCommands(type, cfgjson.ServerID);

// Text commands TODO(#202): [Error] Failed to build command '"editwarn"' System.ArgumentException: An item with the same key has already been added. Key: editwarn
var commandClasses = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsClass && t.Namespace == "Cliptok.Commands" && !t.IsNested);
foreach (var type in commandClasses)
builder.AddCommands(type);
});
// Text commands TODO(#202): [Error] Failed to build command '"editwarn"' System.ArgumentException: An item with the same key has already been added. Key: editwarn
var commandClasses = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsClass && t.Namespace == "Cliptok.Commands" && !t.IsNested);
foreach (var type in commandClasses)
builder.AddCommands(type);
});

discordBuilder.ConfigureExtraFeatures(clientConfig =>
Expand Down

0 comments on commit 78d5e65

Please sign in to comment.