Skip to content
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
88 changes: 88 additions & 0 deletions submacros/Status.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -2437,8 +2437,96 @@ nm_command(command)
discord.SendEmbed('**Debug Log**\nTo get help with debugging you can join [our discord](https:\/\/discord.gg\/invite\/xbkXjwWh8U) and ask for help here: https:\/\/discord.com\/channels\/1012610056921038868\/1073389106568122378', , str, , , id)
}
DetectHiddenWindows 0

case "preset":
loop 2
params[A_Index] := StrLower(params[A_Index])

if params.Has(3) {
PresetPath := A_WorkingDir "\settings\presets\" (InStr(params[3], ".nm") ? params[3] : params[3] ".nm")

if !FileExist(PresetPath) {
discord.SendEmbed("Preset does not exist! To see your presets, use ?preset list.", 16711731)
command_buffer.RemoveAt(1)
return
}
}

switch params[2] {
case "help":
postdata := '{"embeds":[{"title":"Preset Commands","color":"48128","fields":[{"name":"' commandPrefix 'preset delete [name]","value":"Deletes a preset (without extension)","inline":false},{"name":"' commandPrefix 'preset export [name]","value":"Sends the preset as an attachment (without extension)","inline":false},{"name":"' commandPrefix 'preset create [name]","value":"Creates a preset from current macro settings (without extension)","inline":false},{"name":"' commandPrefix 'preset list","value":"Returns a list of existing presets.","inline":false}],"footer":{"text":"A preset is a file which contains all of the macros settings."}}],"allowed_mentions":{"parse":[]},"message_reference":{"message_id":"' id '","fail_if_not_exists":false}}'
discord.SendMessageAPI(postdata, "application/json")

case "delete":
if !params.Has(3)
return discord.SendEmbed("Please specify a preset!", 16711731)
try FileDelete(PresetPath)
catch
discord.SendEmbed("An error occured. Preset may not exist or the macro might not have the privelleges to delete this file.", 16711731)
else
discord.SendEmbed("Preset deleted!", 48128)

case "export":
if !params.Has(3)
return discord.SendEmbed("Please specify a preset!", 16711731)
discord.SendFile(PresetPath, ID)

case "load":
if !params.Has(3) {
discord.SendEmbed("Please specify a preset!", 16711731)
command_buffer.RemoveAt(1)
return
}

PresetPos := 0

loop files A_WorkingDir "\settings\presets\*.nm", 'F' {
if (A_LoopFileName = InStr(params[3], ".nm") ? params[3] : params[3] ".nm") {
PresetPos := A_Index
break
}
}

DetectHiddenWindows 1

if PresetPos {
try SendMessage(0x5561, PresetPos, , , "natro_macro ahk_class AutoHotkey")
catch {
discord.SendEmbed("Error! SendMessage timeout.", 16711731)
command_buffer.RemoveAt(1)
return
}
discord.SendEmbed("Preset loaded!", 48128)
} else
discord.SendEmbed("i coouildnt find it", 16711731)

command_buffer.RemoveAt(1)

case "list":
fileList := "", fileCount := 0, totalSize := 0

loop files A_WorkingDir "\settings\presets\*.nm", 'F' {
fileList .= A_LoopFileName "`n"
fileCount++
totalSize += A_LoopFileSize
}

fileList := !fileList ? "No presets found" : Trim(fileList, "`n")
fileList := StrReplace(fileList, "`n", "\n")

sizeStr := totalSize < 1024 ? totalSize " bytes" : totalSize < 1048576 ? Round(totalSize / 1024, 2) "KB" : totalSize < 1073741824 ? Round(totalSize / 1048576, 2) "MB" : Round(totalSize / 1073741824, 2) "GB"

postdata := '{"embeds":[{"title":"Existing Presets","color":48128,"description":"````\n' fileList '\n````","fields":[{"name":"Total","value":"**' fileCount ' presets** (' sizeStr ')","inline":false}],"footer":{"text":"Your preset collection"}}],"allowed_mentions":{"parse":[]},"message_reference":{"message_id":"' id '","fail_if_not_exists":false}}'

discord.SendMessageAPI(postdata, "application/json")

;TODO//Change validation and use send_wm_copydata to make a create preset command
; not urgent so leave for now.

default:
discord.SendEmbed("``" commandPrefix name " " params[2] "``is not a valid subcommand!\nUse ``" commandPrefix "help preset`` for a list of preset commands.", 16711731, , , , id)

}
#Include "*i %A_ScriptDir%\..\settings\personal_commands.ahk"


Expand Down
Binary file removed submacros/file.png
Binary file not shown.
Loading