mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-04-20 00:43:36 +03:00
fix warnings
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
fcedb762eb
commit
eaf3ddf77e
1 changed files with 12 additions and 12 deletions
|
@ -24,10 +24,10 @@ namespace Boyfriend.Commands;
|
||||||
/// Handles the command to show information about this bot: /about
|
/// Handles the command to show information about this bot: /about
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SettingsCommandGroup : CommandGroup {
|
public class SettingsCommandGroup : CommandGroup {
|
||||||
private readonly ICommandContext _context;
|
private readonly ICommandContext _context;
|
||||||
private readonly GuildDataService _dataService;
|
private readonly GuildDataService _dataService;
|
||||||
private readonly FeedbackService _feedbackService;
|
private readonly FeedbackService _feedbackService;
|
||||||
private readonly IDiscordRestUserAPI _userApi;
|
private readonly IDiscordRestUserAPI _userApi;
|
||||||
|
|
||||||
public SettingsCommandGroup(
|
public SettingsCommandGroup(
|
||||||
ICommandContext context, GuildDataService dataService,
|
ICommandContext context, GuildDataService dataService,
|
||||||
|
@ -57,14 +57,12 @@ public class SettingsCommandGroup : CommandGroup {
|
||||||
|
|
||||||
foreach (var setting in typeof(GuildConfiguration).GetProperties()) {
|
foreach (var setting in typeof(GuildConfiguration).GetProperties()) {
|
||||||
builder.Append(Markdown.InlineCode(setting.Name))
|
builder.Append(Markdown.InlineCode(setting.Name))
|
||||||
.Append(": ");
|
.Append(": ");
|
||||||
var something = setting.GetValue(cfg);
|
var something = setting.GetValue(cfg);
|
||||||
if (something.GetType() == typeof(List<GuildConfiguration.NotificationReceiver>)) {
|
if (something!.GetType() == typeof(List<GuildConfiguration.NotificationReceiver>)) {
|
||||||
var list = (something as List<GuildConfiguration.NotificationReceiver>);
|
var list = (something as List<GuildConfiguration.NotificationReceiver>);
|
||||||
builder.AppendLine(string.Join(", ", list.Select(v => Markdown.InlineCode(v.ToString()))));
|
builder.AppendLine(string.Join(", ", list!.Select(v => Markdown.InlineCode(v.ToString()))));
|
||||||
} else {
|
} else { builder.AppendLine(Markdown.InlineCode(something.ToString()!)); }
|
||||||
builder.AppendLine(Markdown.InlineCode(something.ToString()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var embed = new EmbedBuilder().WithSmallTitle(Messages.SettingsListTitle, currentUser)
|
var embed = new EmbedBuilder().WithSmallTitle(Messages.SettingsListTitle, currentUser)
|
||||||
|
@ -73,8 +71,10 @@ public class SettingsCommandGroup : CommandGroup {
|
||||||
.Build();
|
.Build();
|
||||||
if (!embed.IsDefined(out var built)) return Result.FromError(embed);
|
if (!embed.IsDefined(out var built)) return Result.FromError(embed);
|
||||||
|
|
||||||
return (Result)await _feedbackService.SendContextualEmbedAsync(built, ct: CancellationToken, options: new FeedbackMessageOptions(MessageFlags: MessageFlags.Ephemeral));
|
return (Result)await _feedbackService.SendContextualEmbedAsync(
|
||||||
|
built, ct: CancellationToken, options: new FeedbackMessageOptions(MessageFlags: MessageFlags.Ephemeral));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A slash command that shows information about this bot.
|
/// A slash command that shows information about this bot.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -101,7 +101,7 @@ public class SettingsCommandGroup : CommandGroup {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
foreach (var prop in typeof(GuildConfiguration).GetProperties())
|
foreach (var prop in typeof(GuildConfiguration).GetProperties())
|
||||||
if (setting.ToLower() == prop.Name.ToLower())
|
if (string.Equals(setting, prop.Name, StringComparison.CurrentCultureIgnoreCase))
|
||||||
property = prop;
|
property = prop;
|
||||||
if (property == null || !property.CanWrite)
|
if (property == null || !property.CanWrite)
|
||||||
throw new ApplicationException(Messages.SettingDoesntExist);
|
throw new ApplicationException(Messages.SettingDoesntExist);
|
||||||
|
|
Loading…
Add table
Reference in a new issue