diff --git a/bun.lockb b/bun.lockb index 53338fa..da2d631 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 569d77e..5237e5d 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "dependencies": { "@discordeno/bot": "^19.0.0-next.d81b28a", "@discordeno/rest": "^19.0.0-next.d81b28a", - "ollama": "^0.5.0" + "ollama": "^0.5.0", + "soap": "^1.1.4" }, "scripts": { "dev": "bun run --watch src/index.ts", diff --git a/src/interactions/mass.ts b/src/interactions/mass.ts new file mode 100644 index 0000000..cf79734 --- /dev/null +++ b/src/interactions/mass.ts @@ -0,0 +1,118 @@ +import type { Command } from "../lib/types/command"; +import { + ApplicationCommandOptionTypes, + BitwisePermissionFlags, + InteractionResponseTypes, + Permissions, + type Interaction, +} from "@discordeno/bot"; +import SlashCommand from "../lib/classes/SlashCommand"; + +const actions: { + name: string; + description: string; + type: ApplicationCommandOptionTypes; + permissions?: BitwisePermissionFlags; + options: { + type: ApplicationCommandOptionTypes; + name: string; + description: string; + required: boolean; + max_length?: number; + }[]; +}[] = [ + { + name: "ban", + description: "Ban every user from the guild.", + type: ApplicationCommandOptionTypes.SubCommand, + permissions: BitwisePermissionFlags.BAN_MEMBERS, + options: [], + }, + { + name: "kick", + description: "Kick every user from the guild.", + type: ApplicationCommandOptionTypes.SubCommand, + permissions: BitwisePermissionFlags.KICK_MEMBERS, + options: [], + }, + { + name: "nickname", + description: "Change every user's nickname.", + type: ApplicationCommandOptionTypes.SubCommand, + permissions: BitwisePermissionFlags.MANAGE_NICKNAMES, + options: [ + { + type: ApplicationCommandOptionTypes.String, + name: "nickname", + description: "The nickname to set.", + required: true, + max_length: 32, + }, + ], + }, + { + name: "roleadd", + description: "Add a role to every user.", + type: ApplicationCommandOptionTypes.SubCommand, + permissions: BitwisePermissionFlags.MANAGE_ROLES, + options: [ + { + type: ApplicationCommandOptionTypes.Role, + name: "role", + description: "The role to give.", + required: true, + }, + ], + }, + { + name: "roleremove", + description: "Remove a role from every user.", + type: ApplicationCommandOptionTypes.SubCommand, + permissions: BitwisePermissionFlags.MANAGE_ROLES, + options: [ + { + type: ApplicationCommandOptionTypes.Role, + name: "role", + description: "The role to remove.", + required: true, + }, + ], + }, + { + name: "dm", + description: "Mass-DM users of the guild.", + type: ApplicationCommandOptionTypes.SubCommand, + permissions: BitwisePermissionFlags.MANAGE_GUILD, + options: [ + { + type: ApplicationCommandOptionTypes.String, + name: "content", + description: "The content of the direct message.", + required: true, + max_length: 4000, + }, + ], + }, +]; + +export default class extends SlashCommand implements Command { + name = "mass"; + description = "Perform an action on a large amount of users."; + options = actions.map((_) => { + delete _.permissions; + return _; + }) as unknown; + + constructor() { + super(); + } + + async run(interaction: Interaction) { + console.log(interaction); + + return { + type: InteractionResponseTypes.ChannelMessageWithSource, + data: { content: "You do not have access to this command.", flags: 64 }, + }; + } +} diff --git a/src/interactions/rccexec.ts b/src/interactions/rccexec.ts new file mode 100644 index 0000000..b764562 --- /dev/null +++ b/src/interactions/rccexec.ts @@ -0,0 +1,46 @@ +import type { Command } from "../lib/types/command"; +import { InteractionResponseTypes, type Interaction } from "@discordeno/bot"; +import SlashCommand from "../lib/classes/SlashCommand"; +import { createClientAsync } from "soap"; +import { randomUUID } from "node:crypto"; + +export default class extends SlashCommand implements Command { + name = "rccexec"; + description = "Mess with RCCService."; + options = [ + { type: 3, name: "host", description: "Where to contact RCCService.", required: true }, + { type: 3, name: "script", description: "The script to run.", required: true }, + ]; + + constructor() { + super(); + } + + async run(interaction: Interaction) { + const host = interaction.data?.options?.find((_) => _.name === "host")?.value as string; + const script = interaction.data?.options?.find((_) => _.name === "script")?.value as string; + const client = await createClientAsync("./src/lib/RCCService.wsdl", {}, host); + + console.log((await client.GetStatusAsync({}))[0]); + const job = await client.OpenJobAsync({ + job: { + id: randomUUID(), + expirationInSeconds: 60, + category: "", + cores: 0, + }, + script: { + name: randomUUID(), + script, + arguments: [], + }, + }); + + console.log(job); + + return { + type: InteractionResponseTypes.ChannelMessageWithSource, + data: { content: "Executed?" }, + }; + } +} diff --git a/src/lib/RCCService.wsdl b/src/lib/RCCService.wsdl new file mode 100644 index 0000000..b58c3f0 --- /dev/null +++ b/src/lib/RCCService.wsdl @@ -0,0 +1,811 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file