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:
parent
3fa8fac867
commit
193a651495
2 changed files with 12 additions and 12 deletions
|
@ -34,7 +34,7 @@ public class Karma
|
||||||
KarmaChange.Down => Localization.Karma.CannotChangeOwnDown,
|
KarmaChange.Down => Localization.Karma.CannotChangeOwnDown,
|
||||||
_ => throw new ArgumentOutOfRangeException(nameof(change), change, null)
|
_ => 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;
|
var timeoutMinutes = 3;
|
||||||
|
@ -42,7 +42,7 @@ public class Karma
|
||||||
{
|
{
|
||||||
var remaining = authorRecord.TimeOut.AddMinutes(timeoutMinutes) - DateTimeOffset.Now.ToUniversalTime();
|
var remaining = authorRecord.TimeOut.AddMinutes(timeoutMinutes) - DateTimeOffset.Now.ToUniversalTime();
|
||||||
var formatedWaitTime = DateLocalization.FormatDateTimeAsRemaining(remaining);
|
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
|
// Get the values for the change direction
|
||||||
|
@ -81,16 +81,6 @@ public class Karma
|
||||||
return eb;
|
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)
|
private async Task<KarmaModel> GetUser(long userId)
|
||||||
{
|
{
|
||||||
var user = _database.Karma.FirstOrDefault(u => u.GuildId.Equals(_guildId) && u.UserId.Equals(userId)) ?? await CreateNewRow(userId);
|
var user = _database.Karma.FirstOrDefault(u => u.GuildId.Equals(_guildId) && u.UserId.Equals(userId)) ?? await CreateNewRow(userId);
|
||||||
|
|
|
@ -124,5 +124,15 @@ namespace Geekbot.Interactions.Embed
|
||||||
|
|
||||||
return eb;
|
return eb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Embed ErrorEmbed(string errorMessage)
|
||||||
|
{
|
||||||
|
var eb = new Embed()
|
||||||
|
{
|
||||||
|
Description = errorMessage
|
||||||
|
};
|
||||||
|
eb.SetColor(System.Drawing.Color.Red);
|
||||||
|
return eb;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue