From 3a4d5f8fae414a148e2d3f8952ef77cd03368eb5 Mon Sep 17 00:00:00 2001 From: Anthony Correa Date: Sun, 23 Jun 2024 17:41:43 -0500 Subject: [PATCH] add setting for list role --- src/lang/en.json | 2 ++ src/scripts/main.js | 29 ++++++++++++++++++----------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/lang/en.json b/src/lang/en.json index 5fa2aa1..0534959 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -1,4 +1,6 @@ { + "SESSION_TITLE_SUGGESTIONS.SETTING_ROLE_HINT": "Select the minimum role required to use the /titles command.", + "SESSION_TITLE_SUGGESTIONS.SETTING_ROLE_NAME": "List Titles Command Required Role", "SESSION_TITLE_SUGGESTIONS.INVALID_DATE": "Invalid date provided.", "SESSION_TITLE_SUGGESTIONS.SUGGESTION_AUTOCOMPLETE_MESSAGE": "Enter your session title suggestion.", "SESSION_TITLE_SUGGESTIONS.SUGGESTION_LIST_COMMAND_DESCRIPTION": "List all title suggestions for the provided date", diff --git a/src/scripts/main.js b/src/scripts/main.js index 51917e4..c145084 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -51,7 +51,7 @@ function registerCustomChatCommands() { aliases: ["/ts"], description: game.i18n.localize("SESSION_TITLE_SUGGESTIONS.SUGGESTION_LIST_COMMAND_DESCRIPTION"), icon: '', - requiredRole: "TRUSTED", + requiredRole: game.settings.get("asc-session-title-suggestions", "titleListCommandRole"), callback: async (chat, parameters, messageData) => { const newMessageData = {} const suggestions = game.messages.filter(m => { @@ -98,16 +98,23 @@ function registerCustomChatCommands() { Hooks.on("init", function() { //This code runs once the Foundry VTT software begins its initialization workflow registerClipboardCopyButton(); - loadTemplates(flavor_template_path) - Object.values(TEMPLATES.suggestion).forEach((template_path)=>{ - loadTemplates(template_path) - } - ) - Object.values(TEMPLATES.suggestionList).forEach((template_path)=>{ - loadTemplates(template_path) - } - ) - + Object.values(TEMPLATES.suggestion).forEach((template_path)=>loadTemplates(template_path)) + Object.values(TEMPLATES.suggestionList).forEach((template_path)=>loadTemplates(template_path)) + game.settings.register("asc-session-title-suggestions", "titleListCommandRole", { + name: game.i18n.localize("SESSION_TITLE_SUGGESTIONS.SETTING_ROLE_NAME"), + scope: "world", + config: true, + type: String, + default: "TRUSTED", + requiresReload: true, + choices: { + "PLAYER": game.i18n.localize("USER.RolePlayer"), + "TRUSTED": game.i18n.localize("USER.RoleTrusted"), + "ASSISTANT": game.i18n.localize("USER.RoleAssistant"), + "GAMEMASTER": game.i18n.localize("USER.RoleGamemaster") + }, + hint: game.i18n.localize("SESSION_TITLE_SUGGESTIONS.SETTING_ROLE_HINT") + }); }); Hooks.on("ready", function() {