This commit is contained in:
EmotionChild 2022-05-19 23:38:59 +12:00
parent c9180130f9
commit b565047517
28 changed files with 1634 additions and 1635 deletions

View file

@ -1,4 +1,4 @@
# To get started with Dependabot version updates, you'll need to specify which # To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located. # package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options: # Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
@ -12,7 +12,7 @@ updates:
open-pull-requests-limit: 5 open-pull-requests-limit: 5
reviewers: reviewers:
- EmotionChild - EmotionChild
target-branch: "main" target-branch: "development"
labels: labels:
- "nuget" - "nuget"
- "dependencies" - "dependencies"

View file

@ -1,4 +1,4 @@
name: .NET name: .NET
on: on:
push: push:

View file

@ -51,7 +51,7 @@ namespace SupportChild.Commands
return; return;
} }
if (Database.AddMessage(identifier, command.Member.Id, message)) if(Database.AddMessage(identifier, command.Member.Id, message))
{ {
DiscordEmbed error = new DiscordEmbedBuilder DiscordEmbed error = new DiscordEmbedBuilder
{ {
@ -71,7 +71,6 @@ namespace SupportChild.Commands
await command.RespondAsync(error); await command.RespondAsync(error);
return; return;
} }
} }
} }
} }

View file

@ -115,7 +115,7 @@ namespace SupportChild.Commands
}; };
await staffMember.SendMessageAsync(message); await staffMember.SendMessageAsync(message);
} }
catch (UnauthorizedException) { } catch (UnauthorizedException) {}
} }

View file

@ -35,7 +35,7 @@ namespace SupportChild.Commands
DiscordEmbed error = new DiscordEmbedBuilder DiscordEmbed error = new DiscordEmbedBuilder
{ {
Color = DiscordColor.Red, Color = DiscordColor.Red,
Description = "Invalid list amount. (Must be an integer between 5 and 100)" Description = "Invalid list amount. (Must be integer between 5 and 100)"
}; };
await command.RespondAsync(error); await command.RespondAsync(error);
return; return;

View file

@ -121,8 +121,8 @@ namespace SupportChild.Commands
DiscordMember staffMember = await command.Guild.GetMemberAsync(staffID); DiscordMember staffMember = await command.Guild.GetMemberAsync(staffID);
await staffMember.SendMessageAsync(message); await staffMember.SendMessageAsync(message);
} }
catch (NotFoundException) { } catch (NotFoundException) {}
catch (UnauthorizedException) { } catch (UnauthorizedException) {}
} }
} }
@ -141,7 +141,7 @@ namespace SupportChild.Commands
{ {
Color = DiscordColor.Green, Color = DiscordColor.Green,
Description = "Ticket " + ticketChannel.Mention + " opened by " + command.Member.Mention + ".\n", Description = "Ticket " + ticketChannel.Mention + " opened by " + command.Member.Mention + ".\n",
Footer = new DiscordEmbedBuilder.EmbedFooter { Text = "Ticket " + ticketID } Footer = new DiscordEmbedBuilder.EmbedFooter {Text = "Ticket " + ticketID}
}; };
await logChannel.SendMessageAsync(logMessage); await logChannel.SendMessageAsync(logMessage);
} }

View file

@ -80,7 +80,7 @@ namespace SupportChild.Commands
}; };
await staffMember.SendMessageAsync(message); await staffMember.SendMessageAsync(message);
} }
catch (UnauthorizedException) { } catch (UnauthorizedException) {}
} }
// Log it if the log channel exists // Log it if the log channel exists

View file

@ -40,7 +40,7 @@ namespace SupportChild.Commands
return; return;
} }
if (Database.RemoveMessage(identifier)) if(Database.RemoveMessage(identifier))
{ {
DiscordEmbed error = new DiscordEmbedBuilder DiscordEmbed error = new DiscordEmbedBuilder
{ {

View file

@ -8,7 +8,7 @@ using MySql.Data.MySqlClient;
namespace SupportChild.Commands namespace SupportChild.Commands
{ {
public class SetTicketCommand : BaseCommandModule public class SetTicketCommand :BaseCommandModule
{ {
[Command("setticket")] [Command("setticket")]
[Description("Turns a channel into a ticket, warning: this will let anyone with write access delete the channel using the close command.")] [Description("Turns a channel into a ticket, warning: this will let anyone with write access delete the channel using the close command.")]

View file

@ -98,7 +98,7 @@ namespace SupportChild.Commands
} }
// If there is no open or closed ticket, send an error. If there is a closed ticket we will simply use the old transcript from when the ticket was closed. // If there is no open or closed ticket, send an error. If there is a closed ticket we will simply use the old transcript from when the ticket was closed.
else if (!Database.TryGetClosedTicket(ticketID, out ticket) || ticket?.creatorID != command.Member.Id && !Database.IsStaff(command.Member.Id)) else if (!Database.TryGetClosedTicket(ticketID, out ticket) || (ticket?.creatorID != command.Member.Id && !Database.IsStaff(command.Member.Id)))
{ {
DiscordEmbed error = new DiscordEmbedBuilder DiscordEmbed error = new DiscordEmbedBuilder
{ {

View file

@ -0,0 +1,71 @@
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using Microsoft.Extensions.Logging;
namespace SupportChild.Commands
{
public class UnassignCommand : BaseCommandModule
{
[Command("unassign")]
[Description("Unassigns a staff member from a ticket.")]
public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
{
// Check if the user has permission to use this command.
if (!Config.HasPermission(command.Member, "unassign"))
{
DiscordEmbed error = new DiscordEmbedBuilder
{
Color = DiscordColor.Red,
Description = "You do not have permission to use this command."
};
await command.RespondAsync(error);
command.Client.Logger.Log(LogLevel.Information, "User tried to use the unassign command but did not have permission.");
return;
}
// Check if ticket exists in the database
if (!Database.TryGetOpenTicket(command.Channel.Id, out Database.Ticket ticket))
{
DiscordEmbed error = new DiscordEmbedBuilder
{
Color = DiscordColor.Red,
Description = "This channel is not a ticket."
};
await command.RespondAsync(error);
return;
}
if (!Database.UnassignStaff(ticket))
{
DiscordEmbed error = new DiscordEmbedBuilder
{
Color = DiscordColor.Red,
Description = "Error: Failed to unassign staff from ticket."
};
await command.RespondAsync(error);
return;
}
DiscordEmbed message = new DiscordEmbedBuilder
{
Color = DiscordColor.Green,
Description = "Unassigned staff from ticket."
};
await command.RespondAsync(message);
// Log it if the log channel exists
DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
if (logChannel != null)
{
DiscordEmbed logMessage = new DiscordEmbedBuilder
{
Color = DiscordColor.Green,
Description = "Staff was unassigned from " + command.Channel.Mention + " by " + command.Member.Mention + "."
};
await logChannel.SendMessageAsync(logMessage);
}
}
}
}

View file

@ -1,71 +0,0 @@
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using Microsoft.Extensions.Logging;
namespace SupportChild.Commands
{
public class UnassignCommand : BaseCommandModule
{
[Command("unassign")]
[Description("Unassigns a staff member from a ticket.")]
public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
{
// Check if the user has permission to use this command.
if (!Config.HasPermission(command.Member, "unassign"))
{
DiscordEmbed error = new DiscordEmbedBuilder
{
Color = DiscordColor.Red,
Description = "You do not have permission to use this command."
};
await command.RespondAsync(error);
command.Client.Logger.Log(LogLevel.Information, "User tried to use the unassign command but did not have permission.");
return;
}
// Check if ticket exists in the database
if (!Database.TryGetOpenTicket(command.Channel.Id, out Database.Ticket ticket))
{
DiscordEmbed error = new DiscordEmbedBuilder
{
Color = DiscordColor.Red,
Description = "This channel is not a ticket."
};
await command.RespondAsync(error);
return;
}
if (!Database.UnassignStaff(ticket))
{
DiscordEmbed error = new DiscordEmbedBuilder
{
Color = DiscordColor.Red,
Description = "Error: Failed to unassign staff from ticket."
};
await command.RespondAsync(error);
return;
}
DiscordEmbed message = new DiscordEmbedBuilder
{
Color = DiscordColor.Green,
Description = "Unassigned staff from ticket."
};
await command.RespondAsync(message);
// Log it if the log channel exists
DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
if (logChannel != null)
{
DiscordEmbed logMessage = new DiscordEmbedBuilder
{
Color = DiscordColor.Green,
Description = "Staff was unassigned from " + command.Channel.Mention + " by " + command.Member.Mention + "."
};
await logChannel.SendMessageAsync(logMessage);
}
}
}
}