SupportHelper: improve snippet functionality (#4282)
This commit is contained in:
parent
0dd5b29c14
commit
91fef8f622
2 changed files with 22 additions and 22 deletions
|
|
@ -46,7 +46,7 @@ import SettingsPlugin from "./settings";
|
|||
const CodeBlockRe = /```js\n(.+?)```/s;
|
||||
|
||||
const AdditionalAllowedChannelIds = [
|
||||
"1024286218801926184", // Vencord > #bot-spam
|
||||
"1024286218801926184", // Vencord > #bot-commands
|
||||
];
|
||||
|
||||
const TrustedRolesIds = [
|
||||
|
|
@ -315,27 +315,27 @@ export default definePlugin({
|
|||
</Button>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (props.message.author.id === VENBOT_USER_ID) {
|
||||
const match = CodeBlockRe.exec(props.message.content || props.message.embeds[0]?.rawDescription || "");
|
||||
if (match) {
|
||||
buttons.push(
|
||||
<Button
|
||||
key="vc-run-snippet"
|
||||
onClick={async () => {
|
||||
try {
|
||||
await AsyncFunction(match[1])();
|
||||
showToast("Success!", Toasts.Type.SUCCESS);
|
||||
} catch (e) {
|
||||
new Logger(this.name).error("Error while running snippet:", e);
|
||||
showToast("Failed to run snippet :(", Toasts.Type.FAILURE);
|
||||
}
|
||||
}}
|
||||
>
|
||||
Run Snippet
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
if (props.message.author.id === VENBOT_USER_ID && (props.channel.parent_id === KNOWN_ISSUES_CHANNEL_ID || props.channel.parent_id === SUPPORT_CATEGORY_ID)) {
|
||||
const match = CodeBlockRe.exec(props.message.content || props.message.embeds[0]?.rawDescription || "");
|
||||
if (match) {
|
||||
buttons.push(
|
||||
<Button
|
||||
key="vc-run-snippet"
|
||||
onClick={async () => {
|
||||
try {
|
||||
await AsyncFunction(match[1])();
|
||||
showToast("Success!", Toasts.Type.SUCCESS);
|
||||
} catch (e) {
|
||||
new Logger(this.name).error("Error while running snippet:", e);
|
||||
showToast("Failed to run snippet :(", Toasts.Type.FAILURE);
|
||||
}
|
||||
}}
|
||||
>
|
||||
Run Snippet
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ export const CONTRIB_ROLE_ID = "1026534353167208489";
|
|||
export const REGULAR_ROLE_ID = "1026504932959977532";
|
||||
export const SUPPORT_CHANNEL_ID = "1026515880080842772";
|
||||
export const SUPPORT_CATEGORY_ID = "1108135649699180705";
|
||||
export const KNOWN_ISSUES_CHANNEL_ID = "1222936386626129920";
|
||||
export const KNOWN_ISSUES_CHANNEL_ID = "1257025907625951423";
|
||||
|
||||
const platform = navigator.platform.toLowerCase();
|
||||
export const IS_WINDOWS = platform.startsWith("win");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue