mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
- .shopadd will now ignore negative price input
- Make sure bot has manage roles permission for .xprr - Small cleanup
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
namespace NadekoBot.Modules.Gambling.Common.Waifu
|
||||
{
|
||||
public struct WaifuProfileTitle
|
||||
{
|
||||
public int Count { get; }
|
||||
public string Title { get; }
|
||||
|
||||
public WaifuProfileTitle(int count, string title)
|
||||
{
|
||||
Count = count;
|
||||
Title = title;
|
||||
}
|
||||
}
|
||||
}
|
@@ -17,11 +17,6 @@ namespace NadekoBot.Modules.Gambling
|
||||
[Group]
|
||||
public class CurrencyEventsCommands : GamblingSubmodule<CurrencyEventsService>
|
||||
{
|
||||
public enum OtherEvent
|
||||
{
|
||||
BotListUpvoters
|
||||
}
|
||||
|
||||
public CurrencyEventsCommands(GamblingConfigService gamblingConf) : base(gamblingConf)
|
||||
{
|
||||
}
|
||||
@@ -37,41 +32,36 @@ namespace NadekoBot.Modules.Gambling
|
||||
ctx.Channel.Id,
|
||||
ev,
|
||||
opts,
|
||||
GetEmbed
|
||||
).ConfigureAwait(false))
|
||||
GetEmbed))
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.start_event_fail).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private IEmbedBuilder GetEmbed(CurrencyEvent.Type type, EventOptions opts, long currentPot)
|
||||
{
|
||||
switch (type)
|
||||
return type switch
|
||||
{
|
||||
case CurrencyEvent.Type.Reaction:
|
||||
return _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle(GetText(strs.event_title(type.ToString())))
|
||||
.WithDescription(GetReactionDescription(opts.Amount, currentPot))
|
||||
.WithFooter(GetText(strs.event_duration_footer(opts.Hours)));
|
||||
case CurrencyEvent.Type.GameStatus:
|
||||
return _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle(GetText(strs.event_title(type.ToString())))
|
||||
.WithDescription(GetGameStatusDescription(opts.Amount, currentPot))
|
||||
.WithFooter(GetText(strs.event_duration_footer(opts.Hours)));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
throw new ArgumentOutOfRangeException(nameof(type));
|
||||
CurrencyEvent.Type.Reaction => _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle(GetText(strs.event_title(type.ToString())))
|
||||
.WithDescription(GetReactionDescription(opts.Amount, currentPot))
|
||||
.WithFooter(GetText(strs.event_duration_footer(opts.Hours))),
|
||||
CurrencyEvent.Type.GameStatus => _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle(GetText(strs.event_title(type.ToString())))
|
||||
.WithDescription(GetGameStatusDescription(opts.Amount, currentPot))
|
||||
.WithFooter(GetText(strs.event_duration_footer(opts.Hours))),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(type))
|
||||
};
|
||||
}
|
||||
|
||||
private string GetReactionDescription(long amount, long potSize)
|
||||
{
|
||||
string potSizeStr = Format.Bold(potSize == 0
|
||||
var potSizeStr = Format.Bold(potSize == 0
|
||||
? "∞" + CurrencySign
|
||||
: potSize.ToString() + CurrencySign);
|
||||
: potSize + CurrencySign);
|
||||
|
||||
return GetText(strs.new_reaction_event(
|
||||
CurrencySign,
|
||||
Format.Bold(amount + CurrencySign),
|
||||
@@ -80,9 +70,10 @@ namespace NadekoBot.Modules.Gambling
|
||||
|
||||
private string GetGameStatusDescription(long amount, long potSize)
|
||||
{
|
||||
string potSizeStr = Format.Bold(potSize == 0
|
||||
var potSizeStr = Format.Bold(potSize == 0
|
||||
? "∞" + CurrencySign
|
||||
: potSize.ToString() + CurrencySign);
|
||||
: potSize + CurrencySign);
|
||||
|
||||
return GetText(strs.new_gamestatus_event(
|
||||
CurrencySign,
|
||||
Format.Bold(amount + CurrencySign),
|
||||
|
@@ -225,6 +225,9 @@ namespace NadekoBot.Modules.Gambling
|
||||
[BotPerm(GuildPerm.ManageRoles)]
|
||||
public async Task ShopAdd(Role _, int price, [Leftover] IRole role)
|
||||
{
|
||||
if (price < 1)
|
||||
return;
|
||||
|
||||
var entry = new ShopEntry()
|
||||
{
|
||||
Name = "-",
|
||||
@@ -252,8 +255,11 @@ namespace NadekoBot.Modules.Gambling
|
||||
[NadekoCommand, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[UserPerm(GuildPerm.Administrator)]
|
||||
public async Task ShopAdd(List _, int price, [Leftover]string name)
|
||||
public async Task ShopAdd(List _, int price, [Leftover] string name)
|
||||
{
|
||||
if (price < 1)
|
||||
return;
|
||||
|
||||
var entry = new ShopEntry()
|
||||
{
|
||||
Name = name.TrimTo(100),
|
||||
@@ -266,13 +272,14 @@ namespace NadekoBot.Modules.Gambling
|
||||
{
|
||||
var entries = new IndexedCollection<ShopEntry>(uow.GuildConfigsForId(ctx.Guild.Id,
|
||||
set => set.Include(x => x.ShopEntries)
|
||||
.ThenInclude(x => x.Items)).ShopEntries)
|
||||
.ThenInclude(x => x.Items)).ShopEntries)
|
||||
{
|
||||
entry
|
||||
};
|
||||
uow.GuildConfigsForId(ctx.Guild.Id, set => set).ShopEntries = entries;
|
||||
uow.SaveChanges();
|
||||
}
|
||||
|
||||
await ctx.Channel.EmbedAsync(EntryToEmbed(entry)
|
||||
.WithTitle(GetText(strs.shop_item_add))).ConfigureAwait(false);
|
||||
}
|
||||
|
@@ -123,6 +123,7 @@ namespace NadekoBot.Modules.Xp
|
||||
|
||||
[NadekoCommand, Aliases]
|
||||
[UserPerm(GuildPerm.Administrator)]
|
||||
[BotPerm(GuildPerm.ManageRoles)]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[Priority(2)]
|
||||
public async Task XpRoleReward(int level)
|
||||
@@ -133,6 +134,7 @@ namespace NadekoBot.Modules.Xp
|
||||
|
||||
[NadekoCommand, Aliases]
|
||||
[UserPerm(GuildPerm.Administrator)]
|
||||
[BotPerm(GuildPerm.ManageRoles)]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[Priority(1)]
|
||||
public async Task XpRoleReward(int level, AddRemove action, [Leftover] IRole role)
|
||||
|
Reference in New Issue
Block a user