Update packages; fix Npgsql issues

This commit is contained in:
Noi 2021-09-30 13:45:37 -07:00
parent fbd310ba35
commit f16628a44e
6 changed files with 26 additions and 26 deletions

View file

@ -65,8 +65,8 @@ namespace Noikoio.RegexBot.EntityCache
{
c.CommandText = $"SELECT {QueryColumns} from {SqlHelper.TableTextChannel} WHERE "
+ "channel_id = @Cid AND guild_id = @Gid";
c.Parameters.Add("@Cid", NpgsqlTypes.NpgsqlDbType.Bigint).Value = channel;
c.Parameters.Add("@Gid", NpgsqlTypes.NpgsqlDbType.Bigint).Value = guild;
c.Parameters.Add("@Cid", NpgsqlTypes.NpgsqlDbType.Bigint).Value = (long)channel;
c.Parameters.Add("@Gid", NpgsqlTypes.NpgsqlDbType.Bigint).Value = (long)guild;
c.Prepare();
using (var r = await c.ExecuteReaderAsync())
{

View file

@ -125,8 +125,8 @@ namespace Noikoio.RegexBot.EntityCache
{
c.CommandText = $"SELECT {QueryColumns} FROM {SqlHelper.TableUser} WHERE "
+ "user_id = @Uid AND guild_id = @Gid";
c.Parameters.Add("@Uid", NpgsqlTypes.NpgsqlDbType.Bigint).Value = user;
c.Parameters.Add("@Gid", NpgsqlTypes.NpgsqlDbType.Bigint).Value = guild;
c.Parameters.Add("@Uid", NpgsqlTypes.NpgsqlDbType.Bigint).Value = (long)user;
c.Parameters.Add("@Gid", NpgsqlTypes.NpgsqlDbType.Bigint).Value = (long)guild;
c.Prepare();
using (var r = await c.ExecuteReaderAsync())
{

View file

@ -102,7 +102,7 @@ namespace Noikoio.RegexBot.EntityCache
+ "VALUES (@GuildId, now(), @CurrentName) "
+ "ON CONFLICT (guild_id) DO UPDATE SET "
+ "current_name = EXCLUDED.current_name, cache_date = EXCLUDED.cache_date";
c.Parameters.Add("@GuildId", NpgsqlDbType.Bigint).Value = g.Id;
c.Parameters.Add("@GuildId", NpgsqlDbType.Bigint).Value = (long)g.Id;
c.Parameters.Add("@CurrentName", NpgsqlDbType.Text).Value = g.Name;
c.Prepare();
await c.ExecuteNonQueryAsync();
@ -140,8 +140,8 @@ namespace Noikoio.RegexBot.EntityCache
{
if (item.IsWebhook) continue;
uid.Value = item.Id;
gid.Value = item.Guild.Id;
uid.Value = (long)item.Id;
gid.Value = (long)item.Guild.Id;
uname.Value = item.Username;
disc.Value = item.Discriminator;
nname.Value = item.Nickname;
@ -180,8 +180,8 @@ namespace Noikoio.RegexBot.EntityCache
{
if (!(item is ITextChannel ich)) continue;
cid.Value = item.Id;
gid.Value = item.Guild.Id;
cid.Value = (long)item.Id;
gid.Value = (long)item.Guild.Id;
cname.Value = item.Name;
await c.ExecuteNonQueryAsync();
}

View file

@ -178,8 +178,8 @@ namespace Noikoio.RegexBot.Module.ModLogs
{
c.CommandText = $"SELECT {QueryColumns} FROM {TblEntry} "
+ "WHERE guild_id = @Guild and id = @Id";
c.Parameters.Add("@Guild", NpgsqlTypes.NpgsqlDbType.Bigint).Value = guild;
c.Parameters.Add("@Id", NpgsqlTypes.NpgsqlDbType.Numeric).Value = id;
c.Parameters.Add("@Guild", NpgsqlTypes.NpgsqlDbType.Bigint).Value = (long)guild;
c.Parameters.Add("@Id", NpgsqlTypes.NpgsqlDbType.Numeric).Value = (long)id;
c.Prepare();
using (var r = await c.ExecuteReaderAsync())
{
@ -221,21 +221,21 @@ namespace Noikoio.RegexBot.Module.ModLogs
if (and) c.CommandText += " AND";
else and = true;
c.CommandText += " target_id = @TargetId";
c.Parameters.Add("@TargetId", NpgsqlTypes.NpgsqlDbType.Bigint).Value = target.Value;
c.Parameters.Add("@TargetId", NpgsqlTypes.NpgsqlDbType.Bigint).Value = (long)target.Value;
}
if (invoker.HasValue)
{
if (and) c.CommandText += " AND";
else and = true;
c.CommandText += " invoke_id = @InvokeId";
c.Parameters.Add("@InvokeId", NpgsqlTypes.NpgsqlDbType.Bigint).Value = invoker.Value;
c.Parameters.Add("@InvokeId", NpgsqlTypes.NpgsqlDbType.Bigint).Value = (long)invoker.Value;
}
if (channel.HasValue)
{
if (and) c.CommandText += " AND";
else and = true;
c.CommandText += " target_channel_id = @ChannelId";
c.Parameters.Add("@ChannelId", NpgsqlTypes.NpgsqlDbType.Bigint).Value = channel.Value;
c.Parameters.Add("@ChannelId", NpgsqlTypes.NpgsqlDbType.Bigint).Value = (long)channel.Value;
}
if (category.HasValue)
{

View file

@ -105,7 +105,7 @@ namespace Noikoio.RegexBot.Module.ModLogs
{
c.CommandText = "SELECT author_id, message, created_ts, edited_ts as msgtime FROM " + TableMessage
+ " WHERE message_id = @MessageId";
c.Parameters.Add("@MessageId", NpgsqlDbType.Bigint).Value = messageId;
c.Parameters.Add("@MessageId", NpgsqlDbType.Bigint).Value = (long)messageId;
c.Prepare();
using (var r = await c.ExecuteReaderAsync())
{
@ -320,15 +320,15 @@ namespace Noikoio.RegexBot.Module.ModLogs
+ " (@MessageId, @UserId, @GuildId, @ChannelId, @Date, @Edit, @Message)"
+ " ON CONFLICT (message_id) DO UPDATE"
+ " SET message = EXCLUDED.message, edited_ts = EXCLUDED.edited_ts";
c.Parameters.Add("@MessageId", NpgsqlDbType.Bigint).Value = msg.Id;
c.Parameters.Add("@UserId", NpgsqlDbType.Bigint).Value = msg.Author.Id;
c.Parameters.Add("@GuildId", NpgsqlDbType.Bigint).Value = ((SocketGuildUser)msg.Author).Guild.Id;
c.Parameters.Add("@ChannelId", NpgsqlDbType.Bigint).Value = msg.Channel.Id;
c.Parameters.Add("@Date", NpgsqlDbType.TimestampTZ).Value = msg.Timestamp;
c.Parameters.Add("@MessageId", NpgsqlDbType.Bigint).Value = (long)msg.Id;
c.Parameters.Add("@UserId", NpgsqlDbType.Bigint).Value = (long)msg.Author.Id;
c.Parameters.Add("@GuildId", NpgsqlDbType.Bigint).Value = (long)((SocketGuildUser)msg.Author).Guild.Id;
c.Parameters.Add("@ChannelId", NpgsqlDbType.Bigint).Value = (long)msg.Channel.Id;
c.Parameters.Add("@Date", NpgsqlDbType.TimestampTz).Value = msg.Timestamp;
if (msg.EditedTimestamp.HasValue)
c.Parameters.Add("@Edit", NpgsqlDbType.TimestampTZ).Value = msg.EditedTimestamp.Value;
c.Parameters.Add("@Edit", NpgsqlDbType.TimestampTz).Value = msg.EditedTimestamp.Value;
else
c.Parameters.Add("@Edit", NpgsqlDbType.TimestampTZ).Value = DBNull.Value;
c.Parameters.Add("@Edit", NpgsqlDbType.TimestampTz).Value = DBNull.Value;
c.Parameters.Add("@Message", NpgsqlDbType.Text).Value = dbinsert.ToString();
c.Prepare();
await c.ExecuteNonQueryAsync();
@ -351,7 +351,7 @@ namespace Noikoio.RegexBot.Module.ModLogs
{
c.CommandText = "SELECT message FROM " + TableMessage
+ " WHERE message_id = @MessageId";
c.Parameters.Add("@MessageId", NpgsqlDbType.Bigint).Value = messageId;
c.Parameters.Add("@MessageId", NpgsqlDbType.Bigint).Value = (long)messageId;
c.Prepare();
using (var r = await c.ExecuteReaderAsync())
{

View file

@ -15,9 +15,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Discord.Net" Version="2.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Npgsql" Version="3.2.7" />
<PackageReference Include="Discord.Net" Version="2.4.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Npgsql" Version="5.0.10" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>