Move the error embed from /karma into the embad class as a static method so it can be used by other commands as well

This commit is contained in:
Daan Boerlage 2021-12-27 21:58:49 +08:00
parent 3fa8fac867
commit 193a651495
Signed by: daan
GPG key ID: FCE070E1E4956606
2 changed files with 12 additions and 12 deletions

View file

@ -34,7 +34,7 @@ public class Karma
KarmaChange.Down => Localization.Karma.CannotChangeOwnDown,
_ => throw new ArgumentOutOfRangeException(nameof(change), change, null)
};
return CreateErrorEmbed(string.Format(message, author.Username));
return Embed.ErrorEmbed(string.Format(message, author.Username));
}
var timeoutMinutes = 3;
@ -42,7 +42,7 @@ public class Karma
{
var remaining = authorRecord.TimeOut.AddMinutes(timeoutMinutes) - DateTimeOffset.Now.ToUniversalTime();
var formatedWaitTime = DateLocalization.FormatDateTimeAsRemaining(remaining);
return CreateErrorEmbed(string.Format(Localization.Karma.WaitUntill, author.Username, formatedWaitTime));
return Embed.ErrorEmbed(string.Format(Localization.Karma.WaitUntill, author.Username, formatedWaitTime));
}
// Get the values for the change direction
@ -81,16 +81,6 @@ public class Karma
return eb;
}
private Embed CreateErrorEmbed(string errorMessage)
{
var eb = new Embed()
{
Description = errorMessage
};
eb.SetColor(Color.Red);
return eb;
}
private async Task<KarmaModel> GetUser(long userId)
{
var user = _database.Karma.FirstOrDefault(u => u.GuildId.Equals(_guildId) && u.UserId.Equals(userId)) ?? await CreateNewRow(userId);

View file

@ -124,5 +124,15 @@ namespace Geekbot.Interactions.Embed
return eb;
}
public static Embed ErrorEmbed(string errorMessage)
{
var eb = new Embed()
{
Description = errorMessage
};
eb.SetColor(System.Drawing.Color.Red);
return eb;
}
}
}