mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2024-10-02 20:13:13 +00:00
Merge branch 'v4' into v5
This commit is contained in:
commit
be1d14d095
11 changed files with 66 additions and 25 deletions
16
CHANGELOG.md
16
CHANGELOG.md
|
@ -2,6 +2,22 @@
|
|||
|
||||
Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o
|
||||
|
||||
## [4.3.16] - 24.05.2023
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed missing events from `.logevents`
|
||||
- Fixed `.log` thread deleted and thread created events not working properly
|
||||
|
||||
## [4.3.15] - 21.05.2023
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed -w 0 in trivia
|
||||
- Fixed `.rps` amount field in the response
|
||||
- Fixed `.showembed` output
|
||||
- Fixed bank award's incorrect output message
|
||||
|
||||
## [4.3.14] - 02.04.2023
|
||||
|
||||
### Fixed
|
||||
|
|
|
@ -68,11 +68,6 @@ Some features have their own specific placeholders which are noted in that featu
|
|||
- `%ban.reason%` - Reason for the ban, if provided
|
||||
- `%ban.duration%` - Duration of the ban in the form Days.Hours:Minutes (6.05:04)
|
||||
|
||||
### Bot stats placeholders
|
||||
|
||||
- `%servers%` - Server count bot has joined
|
||||
- `%users%` - Combined user count on servers the bot has joined
|
||||
|
||||
### Shard stats placeholders
|
||||
|
||||
- `%shard.servercount%` - Server count on current shard
|
||||
|
@ -89,6 +84,5 @@ Some features have their own specific placeholders which are noted in that featu
|
|||
|
||||
- `%rngX-Y%` - Returns a random number between X and Y
|
||||
- `%target%` - Returns anything the user has written after the trigger (only works on Expressions)
|
||||
- `%img:stuff%` - Returns an `imgur.com` search for "stuff" (only works on Expressions)
|
||||
|
||||
![img](https://puu.sh/B7mgI.png)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#nullable disable warnings
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace NadekoBot;
|
||||
|
||||
|
@ -7,14 +8,14 @@ public sealed record SmartEmbedArrayElementText : SmartEmbedTextBase
|
|||
{
|
||||
public string Color { get; init; } = string.Empty;
|
||||
|
||||
public SmartEmbedArrayElementText() : base()
|
||||
public SmartEmbedArrayElementText()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public SmartEmbedArrayElementText(IEmbed eb) : base(eb)
|
||||
{
|
||||
|
||||
Color = eb.Color is { } c ? new Rgba32(c.R, c.G, c.B).ToHex() : string.Empty;
|
||||
}
|
||||
|
||||
protected override EmbedBuilder GetEmbedInternal()
|
||||
|
@ -63,6 +64,7 @@ public abstract record SmartEmbedTextBase : SmartText
|
|||
public SmartTextEmbedFooter Footer { get; init; }
|
||||
public SmartTextEmbedField[] Fields { get; init; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool IsValid
|
||||
=> !string.IsNullOrWhiteSpace(Title)
|
||||
|| !string.IsNullOrWhiteSpace(Description)
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#nullable disable
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace NadekoBot;
|
||||
|
||||
public sealed record SmartEmbedTextArray : SmartText
|
||||
|
@ -6,6 +8,7 @@ public sealed record SmartEmbedTextArray : SmartText
|
|||
public string Content { get; set; }
|
||||
public SmartEmbedArrayElementText[] Embeds { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool IsValid
|
||||
=> Embeds?.All(x => x.IsValid) ?? false;
|
||||
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
#nullable disable
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace NadekoBot;
|
||||
|
||||
public abstract record SmartText
|
||||
{
|
||||
[JsonIgnore]
|
||||
public bool IsEmbed
|
||||
=> this is SmartEmbedText;
|
||||
|
||||
[JsonIgnore]
|
||||
public bool IsPlainText
|
||||
=> this is SmartPlainText;
|
||||
|
||||
[JsonIgnore]
|
||||
public bool IsEmbedArray
|
||||
=> this is SmartEmbedTextArray;
|
||||
|
||||
|
|
|
@ -149,9 +149,11 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||
{
|
||||
try
|
||||
{
|
||||
if (sch.HasValue || sch.Value is not IGuildChannel ch)
|
||||
if (!sch.HasValue)
|
||||
return;
|
||||
|
||||
var ch = sch.Value;
|
||||
|
||||
if (!GuildLogSettings.TryGetValue(ch.Guild.Id, out var logSetting)
|
||||
|| logSetting.ThreadDeletedId is null)
|
||||
return;
|
||||
|
@ -164,7 +166,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||
|
||||
await logChannel.EmbedAsync(_eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle("🆕 " + title)
|
||||
.WithTitle("🗑 " + title)
|
||||
.WithDescription($"{ch.Name} | {ch.Id}")
|
||||
.WithFooter(CurrentTime(ch.Guild)));
|
||||
}
|
||||
|
@ -176,15 +178,12 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task _client_ThreadCreated(SocketThreadChannel sch)
|
||||
private Task _client_ThreadCreated(SocketThreadChannel ch)
|
||||
{
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (sch.Guild is not IGuildChannel ch)
|
||||
return;
|
||||
|
||||
if (!GuildLogSettings.TryGetValue(ch.Guild.Id, out var logSetting)
|
||||
|| logSetting.ThreadCreatedId is null)
|
||||
return;
|
||||
|
@ -455,6 +454,12 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||
case LogType.UserWarned:
|
||||
channelId = logSetting.LogWarnsId = logSetting.LogWarnsId is null ? cid : default;
|
||||
break;
|
||||
case LogType.ThreadDeleted:
|
||||
channelId = logSetting.ThreadDeletedId = logSetting.ThreadDeletedId is null ? cid : default;
|
||||
break;
|
||||
case LogType.ThreadCreated:
|
||||
channelId = logSetting.ThreadCreatedId = logSetting.ThreadCreatedId is null ? cid : default;
|
||||
break;
|
||||
}
|
||||
|
||||
uow.SaveChanges();
|
||||
|
@ -1266,6 +1271,12 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||
case LogType.UserWarned:
|
||||
id = logSetting.LogWarnsId;
|
||||
break;
|
||||
case LogType.ThreadCreated:
|
||||
id = logSetting.ThreadCreatedId;
|
||||
break;
|
||||
case LogType.ThreadDeleted:
|
||||
id = logSetting.ThreadDeletedId;
|
||||
break;
|
||||
}
|
||||
|
||||
if (id is null or 0)
|
||||
|
|
|
@ -143,6 +143,12 @@ public partial class Administration
|
|||
return l.LogVoicePresenceTTSId;
|
||||
case LogType.UserMuted:
|
||||
return l.UserMutedId;
|
||||
case LogType.UserWarned:
|
||||
return l.LogWarnsId;
|
||||
case LogType.ThreadDeleted:
|
||||
return l.ThreadDeletedId;
|
||||
case LogType.ThreadCreated:
|
||||
return l.ThreadCreatedId;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -841,7 +841,7 @@ public partial class Gambling : GamblingModule<GamblingService>
|
|||
else if (result.Result == RpsResultType.Win)
|
||||
{
|
||||
if ((long)result.Won > 0)
|
||||
embed.AddField(GetText(strs.won), N(amount));
|
||||
embed.AddField(GetText(strs.won), N((long)result.Won));
|
||||
|
||||
msg = GetText(strs.rps_win(ctx.User.Mention,
|
||||
GetRpsPick(pick),
|
||||
|
|
|
@ -36,7 +36,7 @@ public partial class Games
|
|||
var (opts, _) = OptionsParser.ParseFrom(new TriviaOptions(), args);
|
||||
|
||||
var config = _gamesConfig.Data;
|
||||
if (config.Trivia.MinimumWinReq > 0 && config.Trivia.MinimumWinReq > opts.WinRequirement)
|
||||
if (opts.WinRequirement != 0 && config.Trivia.MinimumWinReq > 0 && config.Trivia.MinimumWinReq > opts.WinRequirement)
|
||||
return;
|
||||
|
||||
var trivia = new TriviaGame(opts, _cache);
|
||||
|
|
|
@ -157,7 +157,7 @@ public sealed class TriviaGame
|
|||
|
||||
var isWin = false;
|
||||
// if user won the game, tell the game to stop
|
||||
if (val >= _opts.WinRequirement)
|
||||
if (_opts.WinRequirement != 0 && val >= _opts.WinRequirement)
|
||||
{
|
||||
_isStopped = true;
|
||||
isWin = true;
|
||||
|
|
|
@ -91,7 +91,7 @@ public partial class Utility : NadekoModule
|
|||
|
||||
var rng = new NadekoRandom();
|
||||
var arr = await Task.Run(() => socketGuild.Users
|
||||
.Where(u => u.Activities.FirstOrDefault()?.Name?.ToUpperInvariant()
|
||||
.Where(u => u.Activities.FirstOrDefault()?.Name?.Trim().ToUpperInvariant()
|
||||
== game)
|
||||
.Select(u => u.Username)
|
||||
.OrderBy(_ => rng.Next())
|
||||
|
@ -547,15 +547,20 @@ public partial class Utility : NadekoModule
|
|||
return;
|
||||
}
|
||||
|
||||
var embed = msg.Embeds.FirstOrDefault();
|
||||
if (embed is null)
|
||||
if (!msg.Embeds.Any())
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.not_found);
|
||||
return;
|
||||
}
|
||||
|
||||
var json = SmartEmbedText.FromEmbed(embed, msg.Content).ToJson(_showEmbedSerializerOptions);
|
||||
await SendConfirmAsync(Format.Sanitize(json).Replace("](", "]\\("));
|
||||
var json = new SmartEmbedTextArray()
|
||||
{
|
||||
Content = msg.Content,
|
||||
Embeds = msg.Embeds
|
||||
.Map(x => new SmartEmbedArrayElementText(x))
|
||||
}.ToJson(_showEmbedSerializerOptions);
|
||||
|
||||
await SendConfirmAsync(Format.Code(json, "json").Replace("](", "]\\("));
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
|
|
Loading…
Reference in a new issue