fixed various bugs with the role menu

This commit is contained in:
MathMan05 2025-03-10 12:28:17 -05:00
parent b527d46fc1
commit 683cc1488b

View file

@ -207,12 +207,22 @@ class RoleList extends Buttons {
option.addButtonInput("", I18n.getTranslation("role.displaySettings"), () => { option.addButtonInput("", I18n.getTranslation("role.displaySettings"), () => {
const role = this.guild.roleids.get(this.curid as string); const role = this.guild.roleids.get(this.curid as string);
if (!role) return; if (!role) return;
const form = option.addSubForm(I18n.getTranslation("role.displaySettings"), () => {}, { const form = option.addSubForm(
fetchURL: this.info.api + "/guilds/" + this.guild.id + "/roles/" + this.curid, I18n.getTranslation("role.displaySettings"),
method: "PATCH", (e) => {
headers: this.headers, if ("name" in e && typeof e.name === "string") {
traditionalSubmit: true, option.name = e.name;
}); }
option.subOptions = undefined;
option.genTop();
},
{
fetchURL: this.info.api + "/guilds/" + this.guild.id + "/roles/" + this.curid,
method: "PATCH",
headers: this.headers,
traditionalSubmit: true,
},
);
form.addTextInput(I18n.getTranslation("role.name"), "name", { form.addTextInput(I18n.getTranslation("role.name"), "name", {
initText: role.name, initText: role.name,
}); });
@ -223,11 +233,12 @@ class RoleList extends Buttons {
initState: role.mentionable, initState: role.mentionable,
}); });
const color = "#" + role.color.toString(16).padStart(6, "0"); const color = "#" + role.color.toString(16).padStart(6, "0");
form.addColorInput(I18n.getTranslation("role.color"), "color", { const colorI = form.addColorInput(I18n.getTranslation("role.color"), "color", {
initColor: color, initColor: color,
}); });
form.addPreprocessor((obj: any) => { form.addPreprocessor((obj: any) => {
obj.color = Number("0x" + obj.color.substring(1)); obj.color = Number("0x" + colorI.colorContent.substring(1));
console.log(obj.color); console.log(obj.color);
}); });
}); });
@ -423,9 +434,11 @@ class RoleList extends Buttons {
this.options.haschanged = false; this.options.haschanged = false;
} }
} }
this.options.subOptions = undefined;
return this.options.generateHTML(); return this.options.generateHTML();
} }
save() { save() {
if (this.options.subOptions) return;
this.onchange(this.curid, this.permission); this.onchange(this.curid, this.permission);
} }
} }