mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-02-24 23:38:32 +00:00
Fixed issues and added reset button
This commit is contained in:
parent
3dc2eb65a1
commit
88689b304a
3 changed files with 53 additions and 43 deletions
|
@ -1,8 +1 @@
|
||||||
### Create custom reasons to use in the Discord ban modal.
|
### Create custom reasons to use in the Discord ban modal.
|
||||||
|
|
||||||

|
|
||||||

|
|
||||||
|
|
||||||
I do not think that we're **easily** and **non-jankily** able to add the click functionality, so I didn't implement that. If anybody gets it working, shoot me a message on Discord.
|
|
||||||
|
|
||||||
[Original plugin request](https://github.com/Vencord/plugin-requests/issues/607)
|
|
||||||
|
|
|
@ -4,59 +4,69 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import "./styles.css";
|
||||||
|
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { Button, Forms, TextInput, useEffect, useState } from "@webpack/common";
|
import { Button, Forms, TextInput } from "@webpack/common";
|
||||||
|
|
||||||
|
const defaultReasons = [
|
||||||
|
"Suspicious or spam account",
|
||||||
|
"Compromised or spam account",
|
||||||
|
"Breaking server rules",
|
||||||
|
];
|
||||||
|
|
||||||
function ReasonsComponent() {
|
function ReasonsComponent() {
|
||||||
const { reasons } = settings.use(["reasons"]);
|
const { reasons } = settings.use(["reasons"]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Forms.FormSection title="Reasons">
|
<Forms.FormSection title="Reasons">
|
||||||
{reasons.map((reason, index) => (
|
{reasons.map((reason: string, index: number) => (
|
||||||
<div
|
<div
|
||||||
style={{
|
className="vc-bbr-reason-wrapper"
|
||||||
display: "grid",
|
|
||||||
padding: 0,
|
|
||||||
paddingBottom: "0.5rem",
|
|
||||||
gap: "0.5rem",
|
|
||||||
gridTemplateColumns: "6fr 1fr",
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={{ flex: 1 }}
|
|
||||||
type="text"
|
type="text"
|
||||||
key={index}
|
key={index}
|
||||||
value={reason}
|
value={reason}
|
||||||
onChange={(value: string) => {
|
onChange={(v: string) => {
|
||||||
reasons[index] = value;
|
reasons[index] = v;
|
||||||
setReasons([...reasons]);
|
settings.store.reasons = [...reasons];
|
||||||
}}
|
}}
|
||||||
placeholder="Reason"
|
placeholder="Reason"
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
color={Button.Colors.RED}
|
color={Button.Colors.RED}
|
||||||
style={{ height: "100%" }}
|
className="vc-bbr-remove-button"
|
||||||
size={Button.Sizes.MIN}
|
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
reasons.splice(index, 1);
|
reasons.splice(index, 1);
|
||||||
setReasons([...reasons]);
|
settings.store.reasons = [...reasons];
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Remove
|
Remove
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
<div
|
||||||
|
className="vc-bbr-reason-wrapper"
|
||||||
|
>
|
||||||
<Button
|
<Button
|
||||||
size={Button.Sizes.SMALL}
|
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
reasons.push("");
|
reasons.push("");
|
||||||
setReasons([...reasons]);
|
settings.store.reasons = [...reasons];
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Add new
|
Add new
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
color={Button.Colors.TRANSPARENT}
|
||||||
|
onClick={() => {
|
||||||
|
settings.store.reasons = defaultReasons;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Reset
|
||||||
|
</Button></div>
|
||||||
</Forms.FormSection>
|
</Forms.FormSection>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -65,11 +75,7 @@ const settings = definePluginSettings({
|
||||||
reasons: {
|
reasons: {
|
||||||
description: "Your custom reasons",
|
description: "Your custom reasons",
|
||||||
type: OptionType.COMPONENT,
|
type: OptionType.COMPONENT,
|
||||||
default: [
|
default: defaultReasons,
|
||||||
"Suspicious or spam account",
|
|
||||||
"Compromised or spam account",
|
|
||||||
"Breaking server rules",
|
|
||||||
],
|
|
||||||
component: ReasonsComponent,
|
component: ReasonsComponent,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -80,12 +86,12 @@ export default definePlugin({
|
||||||
authors: [Devs.Inbestigator],
|
authors: [Devs.Inbestigator],
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
find: 'username:"@".concat(_.default.getName',
|
find: "default.Messages.BAN_MULTIPLE_CONFIRM_TITLE",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /U=\[([\s\S]*?)\]/,
|
match: /=\[([^\\]*?)\]/,
|
||||||
replace: "U=$self.getReasons()",
|
replace: "=$self.getReasons()"
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
getReasons() {
|
getReasons() {
|
||||||
return settings.store.reasons.map(reason => (
|
return settings.store.reasons.map(reason => (
|
||||||
|
|
11
src/plugins/betterBanReasons/styles.css
Normal file
11
src/plugins/betterBanReasons/styles.css
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
.vc-bbr-reason-wrapper {
|
||||||
|
display: grid;
|
||||||
|
padding: 0;
|
||||||
|
padding-bottom: 0.5rem;
|
||||||
|
gap: 0.5rem;
|
||||||
|
grid-template-columns: 6fr 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-bbr-remove-button {
|
||||||
|
height: 100%;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue