refactoring and stuff
This commit is contained in:
parent
03e0f0d5a8
commit
9dc18b86a2
16 changed files with 260 additions and 115 deletions
77
application_cmds/spool-edit.gd
Normal file
77
application_cmds/spool-edit.gd
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
extends RefCounted
|
||||
|
||||
|
||||
#func on_ready(main, bot: DiscordBot) -> void:
|
||||
#pass
|
||||
#
|
||||
func on_autocomplete(main, bot: DiscordBot, interaction: DiscordInteraction, options: Array) -> void:
|
||||
#print(options)
|
||||
#interaction.respond_autocomplete(Library.printer_choies())
|
||||
|
||||
# The part of string which the user is typing
|
||||
var part = options[0].value
|
||||
AutocompleteTools.spool_autocomplete(part, interaction)
|
||||
pass
|
||||
|
||||
func execute(main, bot: DiscordBot, interaction: DiscordInteraction, options: Array) -> void:
|
||||
if not Tools.check_perms(interaction): #limit access to technicians only
|
||||
return
|
||||
|
||||
print(options)
|
||||
var spool_name : String = options[0].value
|
||||
var new_name : String = options[1].value
|
||||
var new_link : String
|
||||
if options.size() > 2:
|
||||
new_link = options[2].value
|
||||
|
||||
var spool_exists : bool = false
|
||||
|
||||
|
||||
for spool : Spool in Library.save.spools:
|
||||
if spool.name == spool_name:
|
||||
spool_exists = true
|
||||
if new_name != "0":
|
||||
spool.name = new_name
|
||||
if new_link:
|
||||
spool.link = new_link
|
||||
#Library.save.printers.erase(printer)
|
||||
|
||||
Library.save_data()
|
||||
|
||||
if not spool_exists:
|
||||
interaction.reply({
|
||||
"content" : "unable to find " + spool_name
|
||||
})
|
||||
return
|
||||
|
||||
var response : String = "finished editing `" + new_name + "`\n"
|
||||
var embed = Embed.new().set_description(Library.list_spools(new_name))
|
||||
|
||||
|
||||
interaction.reply({
|
||||
"content": response,
|
||||
"embeds":[embed],
|
||||
})
|
||||
pass
|
||||
|
||||
|
||||
var data = ApplicationCommand.new()\
|
||||
.set_name("spool-edit")\
|
||||
.set_description("edit a spool (IN THE LIBRARY)")\
|
||||
.add_option(ApplicationCommand.string_option("spool_name", "the spools name (MUST BE UNLOADED)",
|
||||
{
|
||||
"required":true,
|
||||
"autocomplete":true,
|
||||
#"choices" : Library.printer_choies()
|
||||
}))\
|
||||
.add_option(ApplicationCommand.string_option("new_name","new name for the spool (type '0' to keep as is)",
|
||||
{
|
||||
"required" : true,
|
||||
}))\
|
||||
.add_option(ApplicationCommand.string_option("new_link","new link for the spool",
|
||||
{
|
||||
"required" : false,
|
||||
}))\
|
||||
|
||||
|
||||
## lesson learnt: option name must not have spaces
|
||||
Loading…
Add table
Add a link
Reference in a new issue