mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2024-10-02 20:13:13 +00:00
Merge branch 'thread_log' into 'v4'
Thread log See merge request Kwoth/nadekobot!274
This commit is contained in:
commit
3c23b58088
13 changed files with 10511 additions and 2 deletions
|
@ -29,4 +29,7 @@ public enum LogType
|
|||
VoicePresenceTts,
|
||||
UserMuted,
|
||||
UserWarned,
|
||||
|
||||
ThreadDeleted,
|
||||
ThreadCreated
|
||||
}
|
|
@ -19,6 +19,10 @@ public class LogSetting : DbEntity
|
|||
public ulong? ChannelCreatedId { get; set; }
|
||||
public ulong? ChannelDestroyedId { get; set; }
|
||||
public ulong? ChannelUpdatedId { get; set; }
|
||||
|
||||
|
||||
public ulong? ThreadDeletedId { get; set; }
|
||||
public ulong? ThreadCreatedId { get; set; }
|
||||
|
||||
public ulong? UserMutedId { get; set; }
|
||||
|
||||
|
|
3624
src/NadekoBot/Migrations/Mysql/20221118195208_log-thread.Designer.cs
generated
Normal file
3624
src/NadekoBot/Migrations/Mysql/20221118195208_log-thread.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
35
src/NadekoBot/Migrations/Mysql/20221118195208_log-thread.cs
Normal file
35
src/NadekoBot/Migrations/Mysql/20221118195208_log-thread.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace NadekoBot.Migrations.Mysql
|
||||
{
|
||||
public partial class logthread : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<ulong>(
|
||||
name: "threadcreatedid",
|
||||
table: "logsettings",
|
||||
type: "bigint unsigned",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<ulong>(
|
||||
name: "threaddeletedid",
|
||||
table: "logsettings",
|
||||
type: "bigint unsigned",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "threadcreatedid",
|
||||
table: "logsettings");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "threaddeletedid",
|
||||
table: "logsettings");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1518,6 +1518,14 @@ namespace NadekoBot.Migrations.Mysql
|
|||
.HasColumnType("bigint unsigned")
|
||||
.HasColumnName("messageupdatedid");
|
||||
|
||||
b.Property<ulong?>("ThreadCreatedId")
|
||||
.HasColumnType("bigint unsigned")
|
||||
.HasColumnName("threadcreatedid");
|
||||
|
||||
b.Property<ulong?>("ThreadDeletedId")
|
||||
.HasColumnType("bigint unsigned")
|
||||
.HasColumnName("threaddeletedid");
|
||||
|
||||
b.Property<ulong?>("UserBannedId")
|
||||
.HasColumnType("bigint unsigned")
|
||||
.HasColumnName("userbannedid");
|
||||
|
|
3772
src/NadekoBot/Migrations/PostgreSql/20221118195200_log-thread.Designer.cs
generated
Normal file
3772
src/NadekoBot/Migrations/PostgreSql/20221118195200_log-thread.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,35 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace NadekoBot.Migrations.PostgreSql
|
||||
{
|
||||
public partial class logthread : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<decimal>(
|
||||
name: "threadcreatedid",
|
||||
table: "logsettings",
|
||||
type: "numeric(20,0)",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<decimal>(
|
||||
name: "threaddeletedid",
|
||||
table: "logsettings",
|
||||
type: "numeric(20,0)",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "threadcreatedid",
|
||||
table: "logsettings");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "threaddeletedid",
|
||||
table: "logsettings");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1590,6 +1590,14 @@ namespace NadekoBot.Migrations.PostgreSql
|
|||
.HasColumnType("numeric(20,0)")
|
||||
.HasColumnName("messageupdatedid");
|
||||
|
||||
b.Property<decimal?>("ThreadCreatedId")
|
||||
.HasColumnType("numeric(20,0)")
|
||||
.HasColumnName("threadcreatedid");
|
||||
|
||||
b.Property<decimal?>("ThreadDeletedId")
|
||||
.HasColumnType("numeric(20,0)")
|
||||
.HasColumnName("threaddeletedid");
|
||||
|
||||
b.Property<decimal?>("UserBannedId")
|
||||
.HasColumnType("numeric(20,0)")
|
||||
.HasColumnName("userbannedid");
|
||||
|
|
2907
src/NadekoBot/Migrations/Sqlite/20221118195152_log-thread.Designer.cs
generated
Normal file
2907
src/NadekoBot/Migrations/Sqlite/20221118195152_log-thread.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
35
src/NadekoBot/Migrations/Sqlite/20221118195152_log-thread.cs
Normal file
35
src/NadekoBot/Migrations/Sqlite/20221118195152_log-thread.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace NadekoBot.Migrations
|
||||
{
|
||||
public partial class logthread : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<ulong>(
|
||||
name: "ThreadCreatedId",
|
||||
table: "LogSettings",
|
||||
type: "INTEGER",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<ulong>(
|
||||
name: "ThreadDeletedId",
|
||||
table: "LogSettings",
|
||||
type: "INTEGER",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ThreadCreatedId",
|
||||
table: "LogSettings");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ThreadDeletedId",
|
||||
table: "LogSettings");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1186,6 +1186,12 @@ namespace NadekoBot.Migrations
|
|||
b.Property<ulong?>("MessageUpdatedId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<ulong?>("ThreadCreatedId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<ulong?>("ThreadDeletedId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<ulong?>("UserBannedId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
|
|
|
@ -78,6 +78,9 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||
_client.ChannelDestroyed += _client_ChannelDestroyed;
|
||||
_client.ChannelUpdated += _client_ChannelUpdated;
|
||||
_client.RoleDeleted += _client_RoleDeleted;
|
||||
|
||||
_client.ThreadCreated += _client_ThreadCreated;
|
||||
_client.ThreadDeleted += _client_ThreadDeleted;
|
||||
|
||||
_mute.UserMuted += MuteCommands_UserMuted;
|
||||
_mute.UserUnmuted += MuteCommands_UserUnmuted;
|
||||
|
@ -87,6 +90,72 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||
_punishService.OnUserWarned += PunishServiceOnOnUserWarned;
|
||||
}
|
||||
|
||||
private async Task _client_ThreadDeleted(Cacheable<SocketThreadChannel, ulong> sch)
|
||||
{
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (sch.HasValue || sch.Value is not IGuildChannel ch)
|
||||
return;
|
||||
|
||||
if (!GuildLogSettings.TryGetValue(ch.Guild.Id, out var logSetting)
|
||||
|| logSetting.ThreadDeletedId is null)
|
||||
return;
|
||||
|
||||
ITextChannel? logChannel;
|
||||
if ((logChannel = await TryGetLogChannel(ch.Guild, logSetting, LogType.ThreadDeleted)) is null)
|
||||
return;
|
||||
|
||||
var title = GetText(logChannel.Guild, strs.thread_deleted);
|
||||
|
||||
await logChannel.EmbedAsync(_eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle("🆕 " + title)
|
||||
.WithDescription($"{ch.Name} | {ch.Id}")
|
||||
.WithFooter(CurrentTime(ch.Guild)));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Task _client_ThreadCreated(SocketThreadChannel sch)
|
||||
{
|
||||
_ = 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;
|
||||
|
||||
ITextChannel? logChannel;
|
||||
if ((logChannel = await TryGetLogChannel(ch.Guild, logSetting, LogType.ThreadCreated)) is null)
|
||||
return;
|
||||
|
||||
var title = GetText(logChannel.Guild, strs.thread_created);
|
||||
|
||||
await logChannel.EmbedAsync(_eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle("🆕 " + title)
|
||||
.WithDescription($"{ch.Name} | {ch.Id}")
|
||||
.WithFooter(CurrentTime(ch.Guild)));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
});
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task OnReadyAsync()
|
||||
=> await Task.WhenAll(PresenceUpdateTask(), IgnoreMessageIdsClearTask());
|
||||
|
||||
|
@ -725,6 +794,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||
ITextChannel? logChannel;
|
||||
if ((logChannel = await TryGetLogChannel(ch.Guild, logSetting, LogType.ChannelDestroyed)) is null)
|
||||
return;
|
||||
|
||||
string title;
|
||||
if (ch is IVoiceChannel)
|
||||
title = GetText(logChannel.Guild, strs.voice_chan_destroyed);
|
||||
|
@ -744,7 +814,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||
});
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
private Task _client_ChannelCreated(IChannel ich)
|
||||
{
|
||||
_ = Task.Run(async () =>
|
||||
|
|
|
@ -1051,5 +1051,7 @@
|
|||
"patron_insuff_tier": "Your Patron Tier insufficient to perform this action.",
|
||||
"xpshop_already_owned": "You already own this item.",
|
||||
"xpshop_item_not_found": "An item with that key doesn't exist.",
|
||||
"xpshop_website": "You can see the list of all Xp Shop items here: <https://xpshop.nadeko.bot>"
|
||||
"xpshop_website": "You can see the list of all Xp Shop items here: <https://xpshop.nadeko.bot>",
|
||||
"thread_deleted": "Thread Deleted",
|
||||
"thread_created": "Thread Created"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue