mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 01:38:27 -04:00
Merge branch 'thread_log' into 'v4'
Thread log See merge request Kwoth/nadekobot!274
This commit is contained in:
@@ -29,4 +29,7 @@ public enum LogType
|
|||||||
VoicePresenceTts,
|
VoicePresenceTts,
|
||||||
UserMuted,
|
UserMuted,
|
||||||
UserWarned,
|
UserWarned,
|
||||||
|
|
||||||
|
ThreadDeleted,
|
||||||
|
ThreadCreated
|
||||||
}
|
}
|
@@ -20,6 +20,10 @@ public class LogSetting : DbEntity
|
|||||||
public ulong? ChannelDestroyedId { get; set; }
|
public ulong? ChannelDestroyedId { get; set; }
|
||||||
public ulong? ChannelUpdatedId { get; set; }
|
public ulong? ChannelUpdatedId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public ulong? ThreadDeletedId { get; set; }
|
||||||
|
public ulong? ThreadCreatedId { get; set; }
|
||||||
|
|
||||||
public ulong? UserMutedId { get; set; }
|
public ulong? UserMutedId { get; set; }
|
||||||
|
|
||||||
//userpresence
|
//userpresence
|
||||||
|
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")
|
.HasColumnType("bigint unsigned")
|
||||||
.HasColumnName("messageupdatedid");
|
.HasColumnName("messageupdatedid");
|
||||||
|
|
||||||
|
b.Property<ulong?>("ThreadCreatedId")
|
||||||
|
.HasColumnType("bigint unsigned")
|
||||||
|
.HasColumnName("threadcreatedid");
|
||||||
|
|
||||||
|
b.Property<ulong?>("ThreadDeletedId")
|
||||||
|
.HasColumnType("bigint unsigned")
|
||||||
|
.HasColumnName("threaddeletedid");
|
||||||
|
|
||||||
b.Property<ulong?>("UserBannedId")
|
b.Property<ulong?>("UserBannedId")
|
||||||
.HasColumnType("bigint unsigned")
|
.HasColumnType("bigint unsigned")
|
||||||
.HasColumnName("userbannedid");
|
.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)")
|
.HasColumnType("numeric(20,0)")
|
||||||
.HasColumnName("messageupdatedid");
|
.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")
|
b.Property<decimal?>("UserBannedId")
|
||||||
.HasColumnType("numeric(20,0)")
|
.HasColumnType("numeric(20,0)")
|
||||||
.HasColumnName("userbannedid");
|
.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")
|
b.Property<ulong?>("MessageUpdatedId")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<ulong?>("ThreadCreatedId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<ulong?>("ThreadDeletedId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<ulong?>("UserBannedId")
|
b.Property<ulong?>("UserBannedId")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
@@ -79,6 +79,9 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
_client.ChannelUpdated += _client_ChannelUpdated;
|
_client.ChannelUpdated += _client_ChannelUpdated;
|
||||||
_client.RoleDeleted += _client_RoleDeleted;
|
_client.RoleDeleted += _client_RoleDeleted;
|
||||||
|
|
||||||
|
_client.ThreadCreated += _client_ThreadCreated;
|
||||||
|
_client.ThreadDeleted += _client_ThreadDeleted;
|
||||||
|
|
||||||
_mute.UserMuted += MuteCommands_UserMuted;
|
_mute.UserMuted += MuteCommands_UserMuted;
|
||||||
_mute.UserUnmuted += MuteCommands_UserUnmuted;
|
_mute.UserUnmuted += MuteCommands_UserUnmuted;
|
||||||
|
|
||||||
@@ -87,6 +90,72 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
_punishService.OnUserWarned += PunishServiceOnOnUserWarned;
|
_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()
|
public async Task OnReadyAsync()
|
||||||
=> await Task.WhenAll(PresenceUpdateTask(), IgnoreMessageIdsClearTask());
|
=> await Task.WhenAll(PresenceUpdateTask(), IgnoreMessageIdsClearTask());
|
||||||
|
|
||||||
@@ -725,6 +794,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
|||||||
ITextChannel? logChannel;
|
ITextChannel? logChannel;
|
||||||
if ((logChannel = await TryGetLogChannel(ch.Guild, logSetting, LogType.ChannelDestroyed)) is null)
|
if ((logChannel = await TryGetLogChannel(ch.Guild, logSetting, LogType.ChannelDestroyed)) is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string title;
|
string title;
|
||||||
if (ch is IVoiceChannel)
|
if (ch is IVoiceChannel)
|
||||||
title = GetText(logChannel.Guild, strs.voice_chan_destroyed);
|
title = GetText(logChannel.Guild, strs.voice_chan_destroyed);
|
||||||
|
@@ -1051,5 +1051,7 @@
|
|||||||
"patron_insuff_tier": "Your Patron Tier insufficient to perform this action.",
|
"patron_insuff_tier": "Your Patron Tier insufficient to perform this action.",
|
||||||
"xpshop_already_owned": "You already own this item.",
|
"xpshop_already_owned": "You already own this item.",
|
||||||
"xpshop_item_not_found": "An item with that key doesn't exist.",
|
"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"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user