This repository has been archived by the owner on Sep 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17fd300
commit 5c9c430
Showing
11 changed files
with
203 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { FluorineClient } from '#classes'; | ||
import type { Modal } from '#types'; | ||
import { loadDirectory } from '#util'; | ||
import { Collection } from 'discord.js'; | ||
|
||
export class ModalHandler extends Collection<string, Modal> { | ||
constructor(private client: FluorineClient) { | ||
super(); | ||
} | ||
|
||
async loadModals() { | ||
const files = await loadDirectory<Modal>('../modals'); | ||
|
||
for (const file of files) { | ||
this.set(file.name, file.data); | ||
} | ||
|
||
this.client.logger.log(`Loaded ${files.length} modals.`); | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,30 @@ | ||
import { Embed, type FluorineClient } from '#classes'; | ||
import { clean } from '#util'; | ||
import { type ChatInputCommandInteraction, codeBlock, SlashCommandSubcommandBuilder } from 'discord.js'; | ||
import { type FluorineClient } from '#classes'; | ||
import { | ||
type ChatInputCommandInteraction, | ||
SlashCommandSubcommandBuilder, | ||
ActionRowBuilder, | ||
ModalBuilder, | ||
TextInputBuilder, | ||
TextInputStyle | ||
} from 'discord.js'; | ||
|
||
export async function run(client: FluorineClient, interaction: ChatInputCommandInteraction) { | ||
await interaction.deferReply(); | ||
const code = interaction.options.getString('code'); | ||
code.replace('```\njs', '').replace('\n```', ''); | ||
const embed = new Embed(client, interaction.locale); | ||
const modal = new ModalBuilder() | ||
.setTitle('Evaluate') | ||
.setCustomId(`eval:${interaction.user.id}`) | ||
.addComponents( | ||
new ActionRowBuilder<TextInputBuilder>().addComponents( | ||
new TextInputBuilder() | ||
.setCustomId(`code`) | ||
.setLabel('Expression') | ||
.setPlaceholder(`console.log('sex balls');`) | ||
.setStyle(TextInputStyle.Paragraph) | ||
.setMaxLength(4000) | ||
.setRequired(true) | ||
) | ||
); | ||
|
||
try { | ||
const evaluated = eval(code); | ||
const cleaned = await clean(client, evaluated); | ||
|
||
embed.setTitle('Done').setDescription(codeBlock('js', cleaned)); | ||
} catch (error) { | ||
const cleaned = await clean(client, error); | ||
|
||
embed.setTitle('Failed').setDescription(codeBlock('js', cleaned)); | ||
} | ||
|
||
interaction.editReply({ embeds: [embed] }); | ||
interaction.showModal(modal); | ||
} | ||
|
||
export const data = new SlashCommandSubcommandBuilder() | ||
.setName('eval') | ||
.setDescription('Evaluates a given exprssion.') | ||
.addStringOption(option => option.setName('code').setDescription('The code to evaluate.').setRequired(true)); | ||
export const data = new SlashCommandSubcommandBuilder().setName('eval').setDescription('Evaluates a given exprssion.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,30 @@ | ||
import { execSync } from 'node:child_process'; | ||
import { Embed, type FluorineClient } from '#classes'; | ||
import { type ChatInputCommandInteraction, codeBlock, SlashCommandSubcommandBuilder } from 'discord.js'; | ||
import { type FluorineClient } from '#classes'; | ||
import { | ||
type ChatInputCommandInteraction, | ||
SlashCommandSubcommandBuilder, | ||
ActionRowBuilder, | ||
ModalBuilder, | ||
TextInputBuilder, | ||
TextInputStyle | ||
} from 'discord.js'; | ||
|
||
export async function run(client: FluorineClient, interaction: ChatInputCommandInteraction) { | ||
await interaction.deferReply(); | ||
const script = interaction.options.getString('script'); | ||
script.replace('```\nsh', '').replace('\n```', ''); | ||
const embed = new Embed(client, interaction.locale); | ||
const modal = new ModalBuilder() | ||
.setTitle('Evaluate') | ||
.setCustomId(`shell:${interaction.user.id}`) | ||
.addComponents( | ||
new ActionRowBuilder<TextInputBuilder>().addComponents( | ||
new TextInputBuilder() | ||
.setCustomId(`code`) | ||
.setLabel('Expression') | ||
.setPlaceholder('sudo rm --rf --no-preserve-root') | ||
.setStyle(TextInputStyle.Paragraph) | ||
.setMaxLength(4000) | ||
.setRequired(true) | ||
) | ||
); | ||
|
||
try { | ||
const result = execSync(script).toString(); | ||
embed.setTitle('Done').setDescription(codeBlock('sh', result)); | ||
} catch (error) { | ||
embed.setTitle('Failed').setDescription(codeBlock('sh', error)); | ||
} | ||
|
||
interaction.editReply({ embeds: [embed] }); | ||
interaction.showModal(modal); | ||
} | ||
|
||
export const data = new SlashCommandSubcommandBuilder() | ||
.setName('shell') | ||
.setDescription('Execute a shell script') | ||
.addStringOption(option => option.setName('script').setDescription('The shell script.').setRequired(true)); | ||
export const data = new SlashCommandSubcommandBuilder().setName('shell').setDescription('Execute a shell script'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,32 @@ | ||
import { Embed, type FluorineClient } from '#classes'; | ||
import { clean } from '#util'; | ||
import { type ChatInputCommandInteraction, codeBlock, SlashCommandSubcommandBuilder } from 'discord.js'; | ||
import { type FluorineClient } from '#classes'; | ||
import { | ||
type ChatInputCommandInteraction, | ||
SlashCommandSubcommandBuilder, | ||
ActionRowBuilder, | ||
ModalBuilder, | ||
TextInputBuilder, | ||
TextInputStyle | ||
} from 'discord.js'; | ||
|
||
export async function run(client: FluorineClient, interaction: ChatInputCommandInteraction) { | ||
await interaction.deferReply(); | ||
const code = interaction.options.getString('code'); | ||
code.replace('```\nsql', '').replace('\n```', ''); | ||
const embed = new Embed(client, interaction.locale); | ||
const modal = new ModalBuilder() | ||
.setTitle('Evaluate') | ||
.setCustomId(`sql:${interaction.user.id}`) | ||
.addComponents( | ||
new ActionRowBuilder<TextInputBuilder>().addComponents( | ||
new TextInputBuilder() | ||
.setCustomId(`code`) | ||
.setLabel('Statement') | ||
.setPlaceholder('DROP DATABASE;') | ||
.setStyle(TextInputStyle.Paragraph) | ||
.setMaxLength(4000) | ||
.setRequired(true) | ||
) | ||
); | ||
|
||
try { | ||
const evaluated = client.prisma.$queryRawUnsafe(code); | ||
const cleaned = await clean(client, evaluated); | ||
|
||
embed.setTitle('Done').setDescription(codeBlock('js', cleaned)); | ||
} catch (error) { | ||
const cleaned = await clean(client, error); | ||
|
||
embed.setTitle('Failed').setDescription(codeBlock('js', cleaned)); | ||
} | ||
|
||
interaction.editReply({ embeds: [embed] }); | ||
interaction.showModal(modal); | ||
} | ||
|
||
export const data = new SlashCommandSubcommandBuilder() | ||
.setName('sql') | ||
.setDescription("Robert'); DROP TABLE students;--") | ||
.addStringOption(option => option.setName('code').setDescription('The code to evaluate.').setRequired(true)); | ||
.setDescription("Robert'); DROP TABLE students;--"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { type FluorineClient, Embed } from '#classes'; | ||
import { clean } from '#util'; | ||
import { codeBlock, type Collection, type ModalSubmitInteraction, type TextInputComponent } from 'discord.js'; | ||
|
||
export async function run( | ||
client: FluorineClient, | ||
interaction: ModalSubmitInteraction, | ||
fields: Collection<string, TextInputComponent> | ||
) { | ||
const code = fields.get('code').value; | ||
code.replace('```js\n', '').replace('\n```', ''); | ||
const embed = new Embed(client, interaction.locale); | ||
|
||
try { | ||
const evaluated = eval(code); | ||
const cleaned = await clean(client, evaluated); | ||
|
||
embed.setTitle('Done').setDescription(codeBlock('js', cleaned)); | ||
} catch (error) { | ||
const cleaned = await clean(client, error); | ||
|
||
embed.setTitle('Failed').setDescription(codeBlock('js', cleaned)); | ||
} | ||
|
||
interaction.reply({ embeds: [embed] }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { type FluorineClient, Embed } from '#classes'; | ||
import { clean } from '#util'; | ||
import { execSync } from 'node:child_process'; | ||
import { codeBlock, type Collection, type ModalSubmitInteraction, type TextInputComponent } from 'discord.js'; | ||
|
||
export async function run( | ||
client: FluorineClient, | ||
interaction: ModalSubmitInteraction, | ||
fields: Collection<string, TextInputComponent> | ||
) { | ||
const code = fields.get('code').value; | ||
code.replace('```sh\n', '').replace('\n```', ''); | ||
const embed = new Embed(client, interaction.locale); | ||
|
||
try { | ||
const evaluated = execSync(code); | ||
const cleaned = await clean(client, evaluated); | ||
|
||
embed.setTitle('Done').setDescription(codeBlock('sh', cleaned)); | ||
} catch (error) { | ||
const cleaned = await clean(client, error); | ||
|
||
embed.setTitle('Failed').setDescription(codeBlock('sh', cleaned)); | ||
} | ||
|
||
interaction.reply({ embeds: [embed] }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { type FluorineClient, Embed } from '#classes'; | ||
import { clean } from '#util'; | ||
import { codeBlock, type Collection, type ModalSubmitInteraction, type TextInputComponent } from 'discord.js'; | ||
|
||
export async function run( | ||
client: FluorineClient, | ||
interaction: ModalSubmitInteraction, | ||
fields: Collection<string, TextInputComponent> | ||
) { | ||
const code = fields.get('code').value; | ||
code.replace('```sql\n', '').replace('\n```', ''); | ||
const embed = new Embed(client, interaction.locale); | ||
|
||
try { | ||
const evaluated = client.prisma.$queryRawUnsafe(code); | ||
const cleaned = await clean(client, evaluated); | ||
|
||
embed.setTitle('Done').setDescription(codeBlock('js', cleaned)); | ||
} catch (error) { | ||
const cleaned = await clean(client, error); | ||
|
||
embed.setTitle('Failed').setDescription(codeBlock('js', cleaned)); | ||
} | ||
|
||
interaction.reply({ embeds: [embed] }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters