printer creation and deltion working
This commit is contained in:
parent
b53d33584c
commit
b7ce1a2162
7 changed files with 87 additions and 2 deletions
31
application_cmds/printer-create.gd
Normal file
31
application_cmds/printer-create.gd
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
extends RefCounted
|
||||||
|
|
||||||
|
#func on_ready(main, bot: DiscordBot) -> void:
|
||||||
|
# pass
|
||||||
|
#
|
||||||
|
#func on_autocomplete(main, bot: DiscordBot, interaction: DiscordInteraction, options: Array) -> void:
|
||||||
|
# pass
|
||||||
|
|
||||||
|
func execute(main, bot: DiscordBot, interaction: DiscordInteraction, options: Array) -> void:
|
||||||
|
print(options)
|
||||||
|
var printer_name = options[0].value
|
||||||
|
|
||||||
|
var new_printer : Printer = Printer.new()
|
||||||
|
new_printer.name = printer_name
|
||||||
|
Library.save.printers.append(new_printer)
|
||||||
|
Library.save_data()
|
||||||
|
|
||||||
|
var response : String = "Created new printer: `" + printer_name + "`\n"
|
||||||
|
var embed = Embed.new().set_description(Library.list_printers())
|
||||||
|
|
||||||
|
interaction.reply({
|
||||||
|
"content": response,
|
||||||
|
"embeds":[embed]
|
||||||
|
})
|
||||||
|
pass
|
||||||
|
|
||||||
|
var data = ApplicationCommand.new()\
|
||||||
|
.set_name("printer-create")\
|
||||||
|
.set_description("create a new printer")\
|
||||||
|
.add_option(ApplicationCommand.string_option("name", "the printers name",{"required":true}))\
|
||||||
|
|
||||||
1
application_cmds/printer-create.gd.uid
Normal file
1
application_cmds/printer-create.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://la4baew86v6g
|
||||||
38
application_cmds/printer-delete.gd
Normal file
38
application_cmds/printer-delete.gd
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
extends RefCounted
|
||||||
|
|
||||||
|
#func on_ready(main, bot: DiscordBot) -> void:
|
||||||
|
# pass
|
||||||
|
#
|
||||||
|
#func on_autocomplete(main, bot: DiscordBot, interaction: DiscordInteraction, options: Array) -> void:
|
||||||
|
# pass
|
||||||
|
|
||||||
|
func execute(main, bot: DiscordBot, interaction: DiscordInteraction, options: Array) -> void:
|
||||||
|
print(options)
|
||||||
|
var printer_name = options[0].value
|
||||||
|
|
||||||
|
for printer in Library.save.printers:
|
||||||
|
if printer.name == printer_name:
|
||||||
|
Library.save.printers.erase(printer)
|
||||||
|
|
||||||
|
Library.save_data()
|
||||||
|
|
||||||
|
var response : String = "erased printer: `" + printer_name + "`\n"
|
||||||
|
var embed = Embed.new().set_description(Library.list_printers())
|
||||||
|
|
||||||
|
interaction.reply({
|
||||||
|
"content": response,
|
||||||
|
"embeds":[embed]
|
||||||
|
})
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
var data = ApplicationCommand.new()\
|
||||||
|
.set_name("printer-delete")\
|
||||||
|
.set_description("remove a printer")\
|
||||||
|
.add_option(ApplicationCommand.string_option("name", "the printers name",
|
||||||
|
{
|
||||||
|
"required":true,
|
||||||
|
|
||||||
|
"choices" : Library.printer_choies()
|
||||||
|
}))\
|
||||||
|
|
||||||
1
application_cmds/printer-delete.gd.uid
Normal file
1
application_cmds/printer-delete.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://iig4ws0haoew
|
||||||
|
|
@ -1,2 +1,5 @@
|
||||||
extends Resource
|
extends Resource
|
||||||
class_name Printer
|
class_name Printer
|
||||||
|
|
||||||
|
@export var name : String
|
||||||
|
@export var spool : Spool
|
||||||
|
|
|
||||||
13
library.gd
13
library.gd
|
|
@ -37,4 +37,15 @@ func save_new():
|
||||||
save = LibrarySave.new()
|
save = LibrarySave.new()
|
||||||
var error = ResourceSaver.save(save, save_path)
|
var error = ResourceSaver.save(save, save_path)
|
||||||
print(error)
|
print(error)
|
||||||
|
|
||||||
|
func list_printers() -> String:
|
||||||
|
var response : String = "Current Printers:"
|
||||||
|
for printer : Printer in save.printers:
|
||||||
|
response += "\n- " + printer.name
|
||||||
|
return response
|
||||||
|
|
||||||
|
func printer_choies() -> Array[Dictionary]:
|
||||||
|
var printer_names : Array[Dictionary] = []
|
||||||
|
for printer : Printer in save.printers:
|
||||||
|
printer_names.append(ApplicationCommand.choice(printer.name, printer.name))
|
||||||
|
return printer_names
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ config_version=5
|
||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="FabsocBot"
|
config/name="FabsocBot"
|
||||||
run/main_scene="uid://dyob0p2l7g5fj"
|
run/main_scene="uid://cd60nfxe4lnq1"
|
||||||
config/features=PackedStringArray("4.5", "GL Compatibility")
|
config/features=PackedStringArray("4.5", "GL Compatibility")
|
||||||
config/icon="uid://dta0nr1cvl70v"
|
config/icon="uid://dta0nr1cvl70v"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue