Fixed some stuff

Signed-off-by: Emotion <emotion@elliebot.net>
This commit is contained in:
Emotion 2023-03-24 01:21:20 +13:00
parent b4e833404c
commit acf63a745b
No known key found for this signature in database
GPG key ID: 15EBDFF858B9A65A
9 changed files with 1075 additions and 1064 deletions

View file

@ -3,7 +3,7 @@ using System.Threading.Tasks;
using DSharpPlus.Entities; using DSharpPlus.Entities;
using DSharpPlus.SlashCommands; using DSharpPlus.SlashCommands;
using DSharpPlus.SlashCommands.Attributes; using DSharpPlus.SlashCommands.Attributes;
using MySql.Data.MySqlClient; using MySqlConnector;
namespace SupportChild.Commands; namespace SupportChild.Commands;

View file

@ -86,7 +86,7 @@ public class CloseCommand : ApplicationCommandModule
await using FileStream file = new FileStream(Transcriber.GetPath(ticket.id), FileMode.Open, FileAccess.Read); await using FileStream file = new FileStream(Transcriber.GetPath(ticket.id), FileMode.Open, FileAccess.Read);
DiscordMessageBuilder message = new DiscordMessageBuilder(); DiscordMessageBuilder message = new DiscordMessageBuilder();
message.WithEmbed(embed); message.WithEmbed(embed);
message.WithFiles(new Dictionary<string, Stream> { { Transcriber.GetFilename(ticket.id), file } }); message.AddFiles(new Dictionary<string, Stream> { { Transcriber.GetFilename(ticket.id), file } });
await logChannel.SendMessageAsync(message); await logChannel.SendMessageAsync(message);
} }
@ -107,7 +107,7 @@ public class CloseCommand : ApplicationCommandModule
DiscordMessageBuilder message = new DiscordMessageBuilder(); DiscordMessageBuilder message = new DiscordMessageBuilder();
message.WithEmbed(embed); message.WithEmbed(embed);
message.WithFiles(new Dictionary<string, Stream> { { Transcriber.GetFilename(ticket.id), file } }); message.AddFiles(new Dictionary<string, Stream> { { Transcriber.GetFilename(ticket.id), file } });
await staffMember.SendMessageAsync(message); await staffMember.SendMessageAsync(message);
} }

View file

@ -105,7 +105,7 @@ public class NewCommand : ApplicationCommandModule
case ComponentType.Button: case ComponentType.Button:
stringID = interaction.Data.CustomId.Replace("supportchild_newcommandbutton ", ""); stringID = interaction.Data.CustomId.Replace("supportchild_newcommandbutton ", "");
break; break;
case ComponentType.Select: case ComponentType.StringSelect:
if (interaction.Data.Values == null || interaction.Data.Values.Length <= 0) return; if (interaction.Data.Values == null || interaction.Data.Values.Length <= 0) return;
stringID = interaction.Data.Values[0]; stringID = interaction.Data.Values[0];
break; break;

View file

@ -2,7 +2,7 @@
using DSharpPlus.Entities; using DSharpPlus.Entities;
using DSharpPlus.SlashCommands; using DSharpPlus.SlashCommands;
using DSharpPlus.SlashCommands.Attributes; using DSharpPlus.SlashCommands.Attributes;
using MySql.Data.MySqlClient; using MySqlConnector;
namespace SupportChild.Commands; namespace SupportChild.Commands;

View file

@ -2,7 +2,7 @@
using DSharpPlus.Entities; using DSharpPlus.Entities;
using DSharpPlus.SlashCommands; using DSharpPlus.SlashCommands;
using DSharpPlus.SlashCommands.Attributes; using DSharpPlus.SlashCommands.Attributes;
using MySql.Data.MySqlClient; using MySqlConnector;
namespace SupportChild.Commands; namespace SupportChild.Commands;

View file

@ -90,7 +90,7 @@ public class TranscriptCommand : ApplicationCommandModule
Description = "Ticket " + ticket.id.ToString("00000") + " transcript generated by " + command.Member.Mention + ".\n", Description = "Ticket " + ticket.id.ToString("00000") + " transcript generated by " + command.Member.Mention + ".\n",
Footer = new DiscordEmbedBuilder.EmbedFooter { Text = '#' + command.Channel.Name } Footer = new DiscordEmbedBuilder.EmbedFooter { Text = '#' + command.Channel.Name }
}); });
message.WithFiles(new Dictionary<string, Stream> { { Transcriber.GetFilename(ticket.id), file } }); message.AddFiles(new Dictionary<string, Stream> { { Transcriber.GetFilename(ticket.id), file } });
await logChannel.SendMessageAsync(message); await logChannel.SendMessageAsync(message);
} }
@ -106,7 +106,7 @@ public class TranscriptCommand : ApplicationCommandModule
Color = DiscordColor.Green, Color = DiscordColor.Green,
Description = "Transcript generated!\n" Description = "Transcript generated!\n"
}); });
directMessage.WithFiles(new Dictionary<string, Stream> { { Transcriber.GetFilename(ticket.id), file } }); directMessage.AddFiles(new Dictionary<string, Stream> { { Transcriber.GetFilename(ticket.id), file } });
await command.Member.SendMessageAsync(directMessage); await command.Member.SendMessageAsync(directMessage);
} }

View file

@ -2,7 +2,7 @@
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using DSharpPlus; using DSharpPlus;
using MySql.Data.MySqlClient; using MySqlConnector;
namespace SupportChild; namespace SupportChild;
@ -368,6 +368,7 @@ public static class Database
// Check if user is blacklisted // Check if user is blacklisted
if (results.Read()) if (results.Read())
{ {
results.Close();
return true; return true;
} }
results.Close(); results.Close();

View file

@ -134,12 +134,22 @@ internal static class EventHandler
DiscordChannel channel = await client.GetChannelAsync(ticket.channelID); DiscordChannel channel = await client.GetChannelAsync(ticket.channelID);
if (channel?.GuildId == e.Guild.Id) if (channel?.GuildId == e.Guild.Id)
{ {
try
{
await channel.AddOverwriteAsync(e.Member, Permissions.AccessChannels);
await channel.SendMessageAsync(new DiscordEmbedBuilder await channel.SendMessageAsync(new DiscordEmbedBuilder
{ {
Color = DiscordColor.Green, Color = DiscordColor.Green,
Description = "User '" + e.Member.Username + "#" + e.Member.Discriminator + "' has rejoined the server, and has been re-added to the ticket." Description = "User '" + e.Member.Username + "#" + e.Member.Discriminator + "' has rejoined the server, and has been re-added to the ticket."
}); });
} }
catch (DiscordException ex)
{
Logger.Error("Exception occurred trying to add channel permissions: " + ex);
Logger.Error("JsomMessage: " + ex.JsonMessage);
}
}
} }
catch (Exception) { /* ignored */ } catch (Exception) { /* ignored */ }
} }
@ -224,7 +234,7 @@ internal static class EventHandler
Logger.Warn("Unknown button press received! '" + e.Id + "'"); Logger.Warn("Unknown button press received! '" + e.Id + "'");
return; return;
} }
case ComponentType.Select: case ComponentType.StringSelect:
switch (e.Id) switch (e.Id)
{ {
case { } when e.Id.StartsWith("supportchild_newcommandselector"): case { } when e.Id.StartsWith("supportchild_newcommandselector"):

View file

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
@ -16,8 +16,8 @@
<PackageIconUrl>https://cdn.discordapp.com/attachments/765441543100170271/914327948667011132/Ellie_Concept_2_transparent_ver.png</PackageIconUrl> <PackageIconUrl>https://cdn.discordapp.com/attachments/765441543100170271/914327948667011132/Ellie_Concept_2_transparent_ver.png</PackageIconUrl>
<Description>A Discord support ticket bot built for the Ellie's home server</Description> <Description>A Discord support ticket bot built for the Ellie's home server</Description>
<NeutralLanguage>en</NeutralLanguage> <NeutralLanguage>en</NeutralLanguage>
<Version>1.3.0</Version> <Version>1.3.1</Version>
<PackageVersion>1.3.0</PackageVersion> <PackageVersion>1.3.1</PackageVersion>
<AssemblyVersion>3.0.0.1</AssemblyVersion> <AssemblyVersion>3.0.0.1</AssemblyVersion>
<FileVersion>3.0.0.1</FileVersion> <FileVersion>3.0.0.1</FileVersion>
</PropertyGroup> </PropertyGroup>
@ -27,19 +27,19 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DSharpPlus" Version="4.2.0" /> <PackageReference Include="DSharpPlus" Version="4.4.0-nightly-01249" />
<PackageReference Include="DSharpPlus.Interactivity" Version="4.2.0" /> <PackageReference Include="DSharpPlus.Interactivity" Version="4.4.0-nightly-01249" />
<PackageReference Include="DSharpPlus.SlashCommands" Version="4.2.0" /> <PackageReference Include="DSharpPlus.SlashCommands" Version="4.4.0-nightly-01249" />
<PackageReference Include="Gress" Version="2.0.1" /> <PackageReference Include="Gress" Version="2.0.1" />
<PackageReference Include="JsonExtensions" Version="1.2.0" /> <PackageReference Include="JsonExtensions" Version="1.2.0" />
<PackageReference Include="MiniRazor.CodeGen" Version="2.2.2" /> <PackageReference Include="MiniRazor.CodeGen" Version="2.2.2" />
<PackageReference Include="MySql.Data" Version="8.0.30" /> <PackageReference Include="MySqlConnector" Version="2.2.5" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Polly" Version="7.2.3" /> <PackageReference Include="Polly" Version="7.2.3" />
<PackageReference Include="Superpower" Version="3.0.0" /> <PackageReference Include="Superpower" Version="3.0.0" />
<PackageReference Include="Tyrrrz.Extensions" Version="1.6.5" /> <PackageReference Include="Tyrrrz.Extensions" Version="1.6.5" />
<PackageReference Include="WebMarkupMin.Core" Version="2.13.0" /> <PackageReference Include="WebMarkupMin.Core" Version="2.13.0" />
<PackageReference Include="YamlDotNet" Version="12.2.1" /> <PackageReference Include="YamlDotNet" Version="12.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>