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]
|
[Group]
|
||||||
public class CurrencyEventsCommands : GamblingSubmodule<CurrencyEventsService>
|
public class CurrencyEventsCommands : GamblingSubmodule<CurrencyEventsService>
|
||||||
{
|
{
|
||||||
public enum OtherEvent
|
|
||||||
{
|
|
||||||
BotListUpvoters
|
|
||||||
}
|
|
||||||
|
|
||||||
public CurrencyEventsCommands(GamblingConfigService gamblingConf) : base(gamblingConf)
|
public CurrencyEventsCommands(GamblingConfigService gamblingConf) : base(gamblingConf)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -37,41 +32,36 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
ctx.Channel.Id,
|
ctx.Channel.Id,
|
||||||
ev,
|
ev,
|
||||||
opts,
|
opts,
|
||||||
GetEmbed
|
GetEmbed))
|
||||||
).ConfigureAwait(false))
|
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalizedAsync(strs.start_event_fail).ConfigureAwait(false);
|
await ReplyErrorLocalizedAsync(strs.start_event_fail).ConfigureAwait(false);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEmbedBuilder GetEmbed(CurrencyEvent.Type type, EventOptions opts, long currentPot)
|
private IEmbedBuilder GetEmbed(CurrencyEvent.Type type, EventOptions opts, long currentPot)
|
||||||
{
|
{
|
||||||
switch (type)
|
return type switch
|
||||||
{
|
{
|
||||||
case CurrencyEvent.Type.Reaction:
|
CurrencyEvent.Type.Reaction => _eb.Create()
|
||||||
return _eb.Create()
|
.WithOkColor()
|
||||||
.WithOkColor()
|
.WithTitle(GetText(strs.event_title(type.ToString())))
|
||||||
.WithTitle(GetText(strs.event_title(type.ToString())))
|
.WithDescription(GetReactionDescription(opts.Amount, currentPot))
|
||||||
.WithDescription(GetReactionDescription(opts.Amount, currentPot))
|
.WithFooter(GetText(strs.event_duration_footer(opts.Hours))),
|
||||||
.WithFooter(GetText(strs.event_duration_footer(opts.Hours)));
|
CurrencyEvent.Type.GameStatus => _eb.Create()
|
||||||
case CurrencyEvent.Type.GameStatus:
|
.WithOkColor()
|
||||||
return _eb.Create()
|
.WithTitle(GetText(strs.event_title(type.ToString())))
|
||||||
.WithOkColor()
|
.WithDescription(GetGameStatusDescription(opts.Amount, currentPot))
|
||||||
.WithTitle(GetText(strs.event_title(type.ToString())))
|
.WithFooter(GetText(strs.event_duration_footer(opts.Hours))),
|
||||||
.WithDescription(GetGameStatusDescription(opts.Amount, currentPot))
|
_ => throw new ArgumentOutOfRangeException(nameof(type))
|
||||||
.WithFooter(GetText(strs.event_duration_footer(opts.Hours)));
|
};
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
throw new ArgumentOutOfRangeException(nameof(type));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetReactionDescription(long amount, long potSize)
|
private string GetReactionDescription(long amount, long potSize)
|
||||||
{
|
{
|
||||||
string potSizeStr = Format.Bold(potSize == 0
|
var potSizeStr = Format.Bold(potSize == 0
|
||||||
? "∞" + CurrencySign
|
? "∞" + CurrencySign
|
||||||
: potSize.ToString() + CurrencySign);
|
: potSize + CurrencySign);
|
||||||
|
|
||||||
return GetText(strs.new_reaction_event(
|
return GetText(strs.new_reaction_event(
|
||||||
CurrencySign,
|
CurrencySign,
|
||||||
Format.Bold(amount + CurrencySign),
|
Format.Bold(amount + CurrencySign),
|
||||||
@@ -80,9 +70,10 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
|
|
||||||
private string GetGameStatusDescription(long amount, long potSize)
|
private string GetGameStatusDescription(long amount, long potSize)
|
||||||
{
|
{
|
||||||
string potSizeStr = Format.Bold(potSize == 0
|
var potSizeStr = Format.Bold(potSize == 0
|
||||||
? "∞" + CurrencySign
|
? "∞" + CurrencySign
|
||||||
: potSize.ToString() + CurrencySign);
|
: potSize + CurrencySign);
|
||||||
|
|
||||||
return GetText(strs.new_gamestatus_event(
|
return GetText(strs.new_gamestatus_event(
|
||||||
CurrencySign,
|
CurrencySign,
|
||||||
Format.Bold(amount + CurrencySign),
|
Format.Bold(amount + CurrencySign),
|
||||||
|
@@ -225,6 +225,9 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
[BotPerm(GuildPerm.ManageRoles)]
|
[BotPerm(GuildPerm.ManageRoles)]
|
||||||
public async Task ShopAdd(Role _, int price, [Leftover] IRole role)
|
public async Task ShopAdd(Role _, int price, [Leftover] IRole role)
|
||||||
{
|
{
|
||||||
|
if (price < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
var entry = new ShopEntry()
|
var entry = new ShopEntry()
|
||||||
{
|
{
|
||||||
Name = "-",
|
Name = "-",
|
||||||
@@ -252,8 +255,11 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
[NadekoCommand, Aliases]
|
[NadekoCommand, Aliases]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[UserPerm(GuildPerm.Administrator)]
|
[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()
|
var entry = new ShopEntry()
|
||||||
{
|
{
|
||||||
Name = name.TrimTo(100),
|
Name = name.TrimTo(100),
|
||||||
@@ -266,13 +272,14 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
{
|
{
|
||||||
var entries = new IndexedCollection<ShopEntry>(uow.GuildConfigsForId(ctx.Guild.Id,
|
var entries = new IndexedCollection<ShopEntry>(uow.GuildConfigsForId(ctx.Guild.Id,
|
||||||
set => set.Include(x => x.ShopEntries)
|
set => set.Include(x => x.ShopEntries)
|
||||||
.ThenInclude(x => x.Items)).ShopEntries)
|
.ThenInclude(x => x.Items)).ShopEntries)
|
||||||
{
|
{
|
||||||
entry
|
entry
|
||||||
};
|
};
|
||||||
uow.GuildConfigsForId(ctx.Guild.Id, set => set).ShopEntries = entries;
|
uow.GuildConfigsForId(ctx.Guild.Id, set => set).ShopEntries = entries;
|
||||||
uow.SaveChanges();
|
uow.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
await ctx.Channel.EmbedAsync(EntryToEmbed(entry)
|
await ctx.Channel.EmbedAsync(EntryToEmbed(entry)
|
||||||
.WithTitle(GetText(strs.shop_item_add))).ConfigureAwait(false);
|
.WithTitle(GetText(strs.shop_item_add))).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
@@ -123,6 +123,7 @@ namespace NadekoBot.Modules.Xp
|
|||||||
|
|
||||||
[NadekoCommand, Aliases]
|
[NadekoCommand, Aliases]
|
||||||
[UserPerm(GuildPerm.Administrator)]
|
[UserPerm(GuildPerm.Administrator)]
|
||||||
|
[BotPerm(GuildPerm.ManageRoles)]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[Priority(2)]
|
[Priority(2)]
|
||||||
public async Task XpRoleReward(int level)
|
public async Task XpRoleReward(int level)
|
||||||
@@ -133,6 +134,7 @@ namespace NadekoBot.Modules.Xp
|
|||||||
|
|
||||||
[NadekoCommand, Aliases]
|
[NadekoCommand, Aliases]
|
||||||
[UserPerm(GuildPerm.Administrator)]
|
[UserPerm(GuildPerm.Administrator)]
|
||||||
|
[BotPerm(GuildPerm.ManageRoles)]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[Priority(1)]
|
[Priority(1)]
|
||||||
public async Task XpRoleReward(int level, AddRemove action, [Leftover] IRole role)
|
public async Task XpRoleReward(int level, AddRemove action, [Leftover] IRole role)
|
||||||
|
Reference in New Issue
Block a user