Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor improvements #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
# Discord-VZBot
Our discord VZBot managing the serial ids.
# Discord-VzBoT

This bots usage is mainly to manage our Discord org.vzbot.discordbot.vzbot.VzBot.
Its built around having custom rules for channels and managing our Serial IDS we gave out for custom VZBots.
*A friendly and Vz Bot*

In the future it will support a custom warn and punish system which is currently WIP.
This bot (mainly) manages several functions on the VzBoT Discord server:

![Join us on Discord](https://discordapp.com/api/guilds/829828765512106054/widget.png?style=banner2)
* Applying for and granting VzBoT serial ID's
* EzVz orders and providers
* Some support features

It's built around having custom rules for channels, to make management and permissions easier.

Plans for the future include implementing a custom warnings and punishments system, which is currently WIP. Time will tell whether this is still necessary.

The bot contains some functionality and features previously used on the TronXY Discord server, which are now no longer used. These will be removed in the future in order to streamline the VzBot Discord bot.

<span style="font-size: 150%">Read the VzBot documentation: [docs.vzbot.org](https://docs.vzbot.org/)</span>
<span style="font-size: 150%">Join us on Discord: [discord.gg/vzbot](https://discord.gg/vzbot/)</span>

![Discord widget](https://discordapp.com/api/guilds/829828765512106054/widget.png?style=banner3)

![d83b489c-6b62-4fff-923e-577ffe9a15dd](https://user-images.githubusercontent.com/37383368/148010563-464f9006-6cf8-4430-93d2-a66cc4282bac.jpg)

This project is licensed as [Attribution-NonCommercial 4.0](https://creativecommons.org/licenses/by-nc/4.0/).
More info: [creativecommons.org/licenses/by-nc/4.0](https://creativecommons.org/licenses/by-nc/4.0/)

This project is licensed as
![image](https://user-images.githubusercontent.com/37383368/139769027-7267da5b-7f58-499d-96bc-e41d164a3aac.png)

https://creativecommons.org/licenses/by-nc/4.0/
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import kotlin.math.max
import kotlin.math.round
import kotlin.math.sqrt

private val cmd = Commands.slash("accel", "will calculate a acceleration diagram and display it")
.addOption(OptionType.NUMBER, "acceleration", "The acceleration of the movement in mm/s²", true)
.addOption(OptionType.NUMBER, "desired-speed", "The speed it should reach in mm/s", true)
.addOption(OptionType.NUMBER, "mass", "mass of the moving gantry im g", true)
.addOption(OptionType.NUMBER, "movement-length", "The size of the movement in mm", true)
private val cmd = Commands.slash("accel", "will calculate an acceleration diagram and display it")
.addOption(OptionType.NUMBER, "acceleration", "The acceleration of the movement, in mm/s²", true)
.addOption(OptionType.NUMBER, "desired-speed", "The desired movement speed, in mm/s", true)
.addOption(OptionType.NUMBER, "mass", "The mass of the moving gantry, in grams", true)
.addOption(OptionType.NUMBER, "movement-length", "The distance of the movement, in mm", true)

class AccelCommand : Command("accel", cmd, false) {
override fun execute(member: Member, event: SlashCommandInteractionEvent) {
Expand Down Expand Up @@ -101,15 +101,15 @@ class AccelCommand : Command("accel", cmd, false) {
embed.addField("Desired speed", "${givenSpeed}mm/s", true)
embed.addField("Distance where speed is matched", "${round((maxDistance - minDistance) * 2)}mm", true)
embed.addField(
"Amount of movement with desired speed covered",
"Movement distance with desired speed covered",
"${round(((maxDistance - minDistance) * 2) / length * 100)}%",
true,
)
embed.addField("Movement length", "${length}mm", true)
embed.addField("Movement distance", "${length}mm", true)
val duration = timeToFullSpeed + (round((maxDistance - minDistance) * 2) / givenSpeed) + timeToFullSpeed
embed.addField("Movement duration", "${round(duration * 1000) / 1000}s", true)
embed.addField("Time to full speed", "${(timeToFullSpeed)}s", true)
embed.addField("Distance to move until full speed", "${round((distanceToFullSpeed))}mm", true)
embed.addField("Distance to move until reaching full speed", "${round((distanceToFullSpeed))}mm", true)
embed.setImage("attachment://temp.png")
event.replyEmbeds(embed.build()).addFiles(FileUpload.fromData(temp)).queue()
temp.delete()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CreateSubmissionCommand: Command("submit",dat , false) {

if (submissionDAO.hasSubmission(member.idLong)) {
val sub = submissionDAO.getSubmission(member.idLong)
event.replyEmbeds(defaultEmbed("You already have sent your submission- ID: ${sub.id}")).queue()
event.replyEmbeds(defaultEmbed("You have already sent in your submission with ID: ${sub.id}")).queue()
return
}

Expand All @@ -45,4 +45,4 @@ class CreateSubmissionCommand: Command("submit",dat , false) {

event.reply("Done").complete().deleteOriginal().queue()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ import java.util.concurrent.TimeUnit
* @version 1.0
* @author Devin Fritz
*/
@DCommand("sendapplypanel", "Creates a application panel for the ezvz in this channel")
@DCommand("sendapplypanel", "Creates an EzVz application panel (embed) in the current channel")
class EzVzPanelCommand : DiscordCommand() {

override fun execute(actionSender: ActionSender) {
if (!actionSender.getMember().isModerator()) {
actionSender.respondText("You're lacking the permission to execute this command", userOnly = true)
actionSender.respondText("You lack the required permissions to perform this action." + "\n" + "(not a moderator)", userOnly = true)
return
}

Expand Down Expand Up @@ -78,23 +78,22 @@ class ApplyButton(discordButton: DiscordButton = DiscordButton()) :
}

if (ApplicationDAO.hasApplied(actionSender.getMember().idLong)) {
actionSender.respondText("You have already applied to the program", userOnly = true)
actionSender.respondText("You have already applied to the EzVz program", userOnly = true)
return
}

if (ApplicationDAO.hasBeenAccepted(actionSender.getMember().idLong)) {
actionSender.respondText("You are already in the program", userOnly = true)
actionSender.respondText("You are already a member of the EzVz program", userOnly = true)
return
}

val country =
ActionRow.of(
TextInput.create("country", "Country", TextInputStyle.SHORT)
.setPlaceholder("From which country are you?").build(),
)
val country = ActionRow.of(
TextInput.create("country", "Country", TextInputStyle.SHORT)
.setPlaceholder("Which country are you located in?").build(),
)
val continent = ActionRow.of(
TextInput.create("continent", "Continent", TextInputStyle.SHORT)
.setPlaceholder("From which continent are you").build(),
.setPlaceholder("Which continent are you located on?").build(),
)
val printers = ActionRow.of(
TextInput.create("printers", "Printers", TextInputStyle.SHORT)
Expand All @@ -103,10 +102,10 @@ class ApplyButton(discordButton: DiscordButton = DiscordButton()) :

val filaments = ActionRow.of(
TextInput.create("filaments", "Filaments", TextInputStyle.SHORT)
.setPlaceholder("Whats filaments are you capable of printing?").build(),
.setPlaceholder("What filaments are you capable of printing?").build(),
)

val modal = DiscordModal("EzVz Application", { sender, _, values ->
val modal = DiscordModal("EzVz Provider Application", { sender, _, values ->
run {
val countryInput = values["country"]!!.asString
val continentInput = values["continent"]!!.asString
Expand Down Expand Up @@ -152,7 +151,7 @@ class ApplyButton(discordButton: DiscordButton = DiscordButton()) :

sender.respondText(
userOnly = true,
text = "Your application has been created in ${textChannel.asMention}",
text = "Your application has been submitted in ${textChannel.asMention}",
)

val applicationInfoEmbed = EmbedBuilder(defaultEmbed("Information about this application"))
Expand All @@ -167,8 +166,11 @@ class ApplyButton(discordButton: DiscordButton = DiscordButton()) :
}

val infoEmbed = defaultEmbed(
"Welcome to your application ${actionSender.getMember().asMention}." +
" Please follow the rules of the application here. To begin: Send pictures of all 6 Sides of the VzCube in here.",
"Welcome to your EzVz Provider application, ${actionSender.getMember().asMention}!" +
"\n\n" +
"Please follow the rules of the application here." +
"\n" +
"To start off, please send pictures of all 6 sides of the requested printed VzCube in here.",
Color.YELLOW,
"EzVz Application",
)
Expand All @@ -192,7 +194,7 @@ class DeclineApplication(
PermanentDiscordButton("ezvz_accept", discordButton) {
override fun execute(actionSender: ActionSender, hook: Message) {
if (!actionSender.getMember().isModerator()) {
actionSender.respondText("You're missing the permissions to do this.", userOnly = true)
actionSender.respondText("You lack the required permissions to perform this action." + "\n" + "(not a moderator)", userOnly = true)
return
}

Expand All @@ -205,15 +207,15 @@ class DeclineApplication(
val application = ApplicationDAO.getApplicationFromTextChannel(channelID)

if (application.status != ApplicationStatus.PENDING) {
actionSender.respondText(userOnly = true, text = "This application has already been processed")
actionSender.respondText(userOnly = true, text = "This application has already been processed!")
return
}

val applicantID = application.applicant
val user = VzBot.discord.retrieveMemberById(applicantID).complete()

if (user == null) {
actionSender.respondText("The user has left the server. This application will be deleted in 10 seconds")
actionSender.respondText("The user cannot be found or has left the server. This application will be deleted in 10 seconds")
ApplicationDAO.remove(application)
hook.channel.delete().queueAfter(10, TimeUnit.SECONDS)
return
Expand All @@ -224,7 +226,9 @@ class DeclineApplication(

val declinedEmbed =
defaultEmbed(
"Unfortunately your application has been declined ${user.asMention}. You can delete this channel by pressing the delete button below.",
"${user.asMention}," + "\n" +
"Unfortunately, your EzVz Providers Application was denied." + "\n" +
"You can delete this channel with the delete button below.",
Color.RED,
"Declined",
)
Expand All @@ -245,7 +249,7 @@ class AcceptApplication(
PermanentDiscordButton("ezvz_decline", discordButton) {
override fun execute(actionSender: ActionSender, hook: Message) {
if (!actionSender.getMember().isModerator()) {
actionSender.respondText("You're missing the permissions to do this.", userOnly = true)
actionSender.respondText("You lack the required permissions to perform this action." + "\n" + "(not a moderator)", userOnly = true)
return
}

Expand All @@ -267,7 +271,7 @@ class AcceptApplication(
val user = VzBot.discord.retrieveMemberById(applicantID).complete()

if (user == null) {
actionSender.respondText("The user has left the server. This application will be deleted in 10 seconds")
actionSender.respondText("The user has left the server. This application will be closed in 10 seconds")
ApplicationDAO.remove(application)
hook.channel.delete().queueAfter(10, TimeUnit.SECONDS)
return
Expand All @@ -278,7 +282,9 @@ class AcceptApplication(

val acceptedEmbed =
defaultEmbed(
"Congratulation your application has been accepted ${user.asMention}. You are now able to see all the content belonging to the EzVz Program.",
"Congratulations, ${user.asMention}!" + "\n" +
"Your EzVz Providers Application has been accepted!" + "\n" +
"You can now access the EzVz Program. Click on an order channel to get started ",
Color.GREEN,
"Accepted",
)
Expand Down Expand Up @@ -319,7 +325,7 @@ class DeleteApplication(
return
}

actionSender.respondText("This channel will delete itself in 10 seconds")
actionSender.respondText("This channel will be closed in 10 seconds")
hook.channel.delete().queueAfter(10, TimeUnit.SECONDS)
}
}