This commit is contained in:
Tabby 2025-11-02 13:24:43 +11:00
parent 514d68adbf
commit 788633c014
12 changed files with 89 additions and 14 deletions

View file

@ -6,5 +6,11 @@
- [X] unloading a spool returns it to the library
- [ ] job management?
- [x] shoot some of the printers can hold multiple fillaments: endermixer 2, ams: 4
- [ ] handling of spools when printer is deleted
- [ ] command permissions
- [x] handling of spools when printer is deleted
- [x] command permissions
- [ ] refactoring
- [ ] documentation
- [ ] readme
- [ ] fabsoc docs
- [ ] help command -> points to fabsoc docs?
- [ ] offer to delete /unloaded spools

17
Tools.gd Normal file
View file

@ -0,0 +1,17 @@
extends Node
const technician_role_id : String = "692291233627897876"
func check_perms(interaction : DiscordInteraction) -> bool:
print(interaction.member.roles)
for role : String in interaction.member.roles:
if role == technician_role_id:
return true
#havent found the role, sending error
interaction.reply({
"content" : "sorry! only users with the `technician` role can use this command",
"ephemeral" : true
})
return false

1
Tools.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://b8a7fx3a3ieqc

View file

@ -7,6 +7,9 @@ extends RefCounted
# pass
func execute(main, bot: DiscordBot, interaction: DiscordInteraction, options: Array) -> void:
if not Tools.check_perms(interaction):
return
print(options)
var printer_name = options[0].value

View file

@ -35,6 +35,9 @@ func on_autocomplete(main, bot: DiscordBot, interaction: DiscordInteraction, opt
pass
func execute(main, bot: DiscordBot, interaction: DiscordInteraction, options: Array) -> void:
if not Tools.check_perms(interaction):
return
print(options)
var printer_name = options[0].value
var printer_exists : bool = false
@ -73,16 +76,24 @@ func execute(main, bot: DiscordBot, interaction: DiscordInteraction, options: Ar
pass
func on_interaction_create(bot: DiscordBot, interaction : DiscordInteraction):
if not interaction.is_button():
return
print(interaction.data.custom_id)
if(interaction.data.custom_id == "delete-printer"):
if not Tools.check_perms(interaction):
return
#print("deleting: " + endangered_printer)
for printer in Library.save.printers:
if printer.name == endangered_printer:
for spool : Spool in printer.spools:
Library.save.spools.append(spool)
#dont need to erase, the whole printers about to get obilierated
Library.save.printers.erase(printer)
Library.save_data()
var embed = Embed.new().set_description(endangered_printer + " has been deleted")
@ -94,6 +105,8 @@ func on_interaction_create(bot: DiscordBot, interaction : DiscordInteraction):
})
elif(interaction.data.custom_id == "keep-printer"):
if not Tools.check_perms(interaction):
return
endangered_printer = ""
var embed = Embed.new().set_description("cancelled deletion")
var new_embeds = interaction.message.embeds + [embed]

View file

@ -19,6 +19,9 @@ func on_autocomplete(main, bot: DiscordBot, interaction: DiscordInteraction, opt
pass
func execute(main, bot: DiscordBot, interaction: DiscordInteraction, options: Array) -> void:
if not Tools.check_perms(interaction):
return
print(options)
var printer_name = options[0].value
var printer_exists : bool = false
@ -114,6 +117,9 @@ func on_interaction_create(bot: DiscordBot, interaction : DiscordInteraction):
print(interaction.data.custom_id)
if(interaction.data.custom_id == "delete-oldspool"):
if not Tools.check_perms(interaction):
return
#print("deleting: " + endangered_printer)
for spool in Library.save.spools:
if spool == endangered_spool:
@ -129,6 +135,9 @@ func on_interaction_create(bot: DiscordBot, interaction : DiscordInteraction):
})
elif(interaction.data.custom_id == "keep-oldspool"):
if not Tools.check_perms(interaction):
return
endangered_spool = null
var embed = Embed.new().set_description("cancelled removal")
var new_embeds = interaction.message.embeds + [embed]

View file

@ -33,6 +33,9 @@ func on_autocomplete(main, bot: DiscordBot, interaction: DiscordInteraction, opt
pass
func execute(main, bot: DiscordBot, interaction: DiscordInteraction, options: Array) -> void:
if not Tools.check_perms(interaction):
return
print(options)
var printer_name = options[0].value
var new_nozzle = options[1].value

View file

@ -33,6 +33,9 @@ func on_autocomplete(main, bot: DiscordBot, interaction: DiscordInteraction, opt
pass
func execute(main, bot: DiscordBot, interaction: DiscordInteraction, options: Array) -> void:
if not Tools.check_perms(interaction):
return
print(options)
var printer_name = options[0].value
var new_slots : int = options[1].value

View file

@ -15,6 +15,9 @@ func on_autocomplete(main, bot: DiscordBot, interaction: DiscordInteraction, opt
pass
func execute(main, bot: DiscordBot, interaction: DiscordInteraction, options: Array) -> void:
if not Tools.check_perms(interaction):
return
print(options)
var printer_name = options[0].value
var printer_exists : bool = false
@ -86,6 +89,10 @@ func on_interaction_create(bot: DiscordBot, interaction : DiscordInteraction):
if not interaction.is_select_menu():
return
if(interaction.data.custom_id == "spool-select"):
if not Tools.check_perms(interaction):
return
print(interaction.data.values[0])
var spool_unloading : String = interaction.data.values[0]
for spool : Spool in printer_edit.spools:

View file

@ -7,6 +7,9 @@ extends RefCounted
# pass
func execute(main, bot: DiscordBot, interaction: DiscordInteraction, options: Array) -> void:
if not Tools.check_perms(interaction):
return
print(options)
var spool_name : String = options[0].value
var spool_link : String

View file

@ -35,6 +35,9 @@ func on_autocomplete(main, bot: DiscordBot, interaction: DiscordInteraction, opt
pass
func execute(main, bot: DiscordBot, interaction: DiscordInteraction, options: Array) -> void:
if not Tools.check_perms(interaction):
return
print(options)
var spool_name = options[0].value
var spool_exists : bool = false
@ -73,12 +76,16 @@ func execute(main, bot: DiscordBot, interaction: DiscordInteraction, options: Ar
pass
func on_interaction_create(bot: DiscordBot, interaction : DiscordInteraction):
if not interaction.is_button():
return
print(interaction.data.custom_id)
if(interaction.data.custom_id == "delete-spool"):
if not Tools.check_perms(interaction):
return
#print("deleting: " + endangered_printer)
for spool in Library.save.spools:
if spool.name == endangered_spool:
@ -94,6 +101,8 @@ func on_interaction_create(bot: DiscordBot, interaction : DiscordInteraction):
})
elif(interaction.data.custom_id == "keep-spool"):
if not Tools.check_perms(interaction):
return
endangered_spool = ""
var embed = Embed.new().set_description("cancelled deletion")
var new_embeds = interaction.message.embeds + [embed]

View file

@ -19,6 +19,7 @@ config/icon="uid://dta0nr1cvl70v"
Library="*res://Library.tscn"
AutocompleteTools="*res://AutocompleteTools.gd"
Tools="*res://Tools.gd"
[editor_plugins]