Skip to content

Commit

Permalink
Merge pull request #1 from Moonded/v2
Browse files Browse the repository at this point in the history
V2
  • Loading branch information
Moonded authored Sep 24, 2024
2 parents c9765f9 + 0f2db06 commit 43313c8
Show file tree
Hide file tree
Showing 35 changed files with 645 additions and 234 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ data/scannedUsers.json
.vscode/settings.json
env/bot.env

keys/
keys/
eng.traineddata
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ai",
"version": "1.5.0",
"version": "2.0.0",
"description": "lizzyfuzzy",
"main": "dist/index.js",
"private": true,
Expand Down
35 changes: 35 additions & 0 deletions src/commands/dev/authv2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { SlashCommandBuilder } from "discord.js";
import { command } from "utils";

const meta = new SlashCommandBuilder()
.setName("authnext")
.setDescription("dev");

export default command(meta, async ({ interaction }) => {
const body = {
username: interaction.user.username,
connections: [
{
service: "discord",
username: interaction.user.username,
serviceid: interaction.user.id,
},
],
};

const data = await fetch(process.env.API_ENDPOINT_NEXT + "/dev/user", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});

const returned = await data.json();

if (!returned) {
return await interaction.reply({ content: "Error!", ephemeral: true });
}

return await interaction.reply({ content: "Authed!", ephemeral: true });
});
2 changes: 1 addition & 1 deletion src/commands/dev/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default command(meta, async ({ interaction }) => {
});
}
} else {
const Users = await fetch(process.env.API_ENDPOINT + "/bot/dev/users", {
const Users = await fetch(process.env.API_ENDPOINT_V2 + "/bot/dev/users", {
method: "GET",
headers: {
"Content-Type": "application/json",
Expand Down
3 changes: 2 additions & 1 deletion src/commands/dev/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ import init from "./init";
import servers from "./servers";
import clear from "./clear";
import repeat from "./repeat";
import authv2 from "./authv2";

export default category("Dev", [dev, init, servers, clear, repeat]);
export default category("Dev", [dev, init, servers, clear, repeat, authv2]);
4 changes: 2 additions & 2 deletions src/commands/dev/repeat.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PermissionFlagsBits, SlashCommandBuilder } from "discord.js";
import { command, log } from "utils";
import { command } from "utils";

const meta = new SlashCommandBuilder()
.setName("repeat")
Expand All @@ -10,7 +10,7 @@ const meta = new SlashCommandBuilder()
.setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild);

export default command(meta, async ({ interaction, client }) => {
const text = interaction.options.getString("text")!.replace('\\n','\n');
const text = interaction.options.getString("text")!.replace("\\n", "\n");

return interaction.reply(text);
});
3 changes: 2 additions & 1 deletion src/commands/funny/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { category } from 'utils';
import respond from './respond';
import trivia from './trivia';

export default category('funny', [respond]);
export default category('funny', [respond, trivia]);
5 changes: 3 additions & 2 deletions src/commands/funny/respond.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PermissionFlagsBits, SlashCommandBuilder } from "discord.js";
import type { TextChannel } from "discord.js";
import { command } from "utils";
import { command, errorLog } from "utils";

const meta = new SlashCommandBuilder()
.setName("respond")
Expand All @@ -10,7 +10,7 @@ const meta = new SlashCommandBuilder()
export default command(meta, async ({ interaction, client }) => {
const user = interaction.member?.user.username;

const data = await fetch(process.env.API_ENDPOINT + "/endpoint/response", {
const data = await fetch(process.env.API_ENDPOINT_V2 + "/endpoint/response", {
method: "GET",
headers: {
"Content-Type": "application/json",
Expand Down Expand Up @@ -38,6 +38,7 @@ export default command(meta, async ({ interaction, client }) => {

await interaction.reply({ content: "Sent!", ephemeral: true });
} else {
errorLog("No responses found");
await interaction.reply({
embeds: [
{
Expand Down
4 changes: 3 additions & 1 deletion src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ import pub from "./public";
import team from "./team";
import dev from "./dev";

export default [misc, context, funny, pub, team];
export default process.env.NODE_ENV === "development"
? [misc, context, funny, pub, team, dev]
: [misc, context, funny, pub, team];
12 changes: 9 additions & 3 deletions src/commands/misc/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
PermissionFlagsBits,
SlashCommandBuilder,
EmbedBuilder,
version,
} from "discord.js";
import { command } from "utils";
import os from "os";
Expand Down Expand Up @@ -71,12 +72,12 @@ export default command(meta, async ({ interaction }) => {
},
{
name: "Bot Library",
value: "Discord.js@" + process.version,
value: "v" + version,
inline: true,
},
{
name: "Bot Version",
value: `1.0.0`,
value: "v" + process.env.npm_package_version?.toString() || "N/A",
inline: true,
},
{
Expand All @@ -86,13 +87,18 @@ export default command(meta, async ({ interaction }) => {
},
{
name: "CPU Usage",
value: `${Math.round(getAverageUsage() * 100)}% (average)` || "N/A",
value: `${(getAverageUsage() * 100).toFixed(2)}% (average)` || "N/A",
inline: true,
},
{
name: "Memory usage",
value: `RSS: ${memoryUsage.rss}\nHeap Total: ${memoryUsage.heapTotal}\nHeap Used:${memoryUsage.heapUsed}\nExternal:${memoryUsage.external}`,
inline: true,
},
{
name: "Stats",
value: `Servers: ${interaction.client.guilds.cache.size}\nChannels: ${interaction.client.channels.cache.size}\nUsers: ${interaction.client.users.cache.size}`,
inline: true,
}
)
.setFooter({
Expand Down
14 changes: 14 additions & 0 deletions src/commands/public/discord.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { SlashCommandBuilder, EmbedBuilder } from "discord.js";
import { command } from "utils";

const meta = new SlashCommandBuilder()
.setName("discord")
.setDescription("Send the Discord invite link via DM");

export default command(meta, async ({ interaction }) => {
const text =
"Cyberpunk 2077 Modding Discord: https://discord.gg/redmodding\nOfficial Test Server: https://discord.gg/BmqHtRFBxg";

await interaction.user.send(text);
return await interaction.reply("Send! Check your DMs!");
});
4 changes: 3 additions & 1 deletion src/commands/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ import core from "./core";
import social from "./social";
import wiki from "./wiki";
import suggestion from "./suggestion";
import discord from "./discord";
import remind from "./remind";

export default category("Public", [core, social, wiki, suggestion]);
export default category("Public", [core, social, wiki, suggestion, discord, remind]);
39 changes: 39 additions & 0 deletions src/commands/public/remind.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { SlashCommandBuilder } from "discord.js";
import { command } from "utils";

const meta = new SlashCommandBuilder()
.setName("reminder")
.addStringOption((option) =>
option
.setName("message")
.setDescription("The message to remind you about")
.setRequired(true)
)
.addNumberOption((option) =>
option
.setName("time")
.setDescription("The time in minutes to remind you")
.setRequired(true)
)
.setDescription("Reminder Function, works if the bot is online and hasn't restarted/crashed");

export default command(meta, async ({ interaction }) => {
const message = interaction.options.getString("message") || "No message provided";
const time = interaction.options.getNumber("time") || 0;
const channel = interaction.channel!;
const author = interaction.user!;

if(message.length > 1000) {
return interaction.reply({ content: "Message must be less than 1000 characters", ephemeral: true });
}

if (!message) {
return interaction.reply({ content: "No message provided", ephemeral: true });
}

setTimeout(() => {
channel.send({ content: `${author}\nReminder: ${message}` });
}, time * 60000);

return interaction.reply({ content: `Reminder set for ${time} minutes`, ephemeral: true });
});
10 changes: 10 additions & 0 deletions src/commands/team/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { SlashCommandBuilder } from "discord.js";
import { command } from "utils";

const meta = new SlashCommandBuilder()
.setName("auth")
.setDescription("Authenticates the user with the bot");

export default command(meta, async ({ interaction }) => {
return await interaction.reply("Send!");
});
4 changes: 2 additions & 2 deletions src/commands/team/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default command(meta, async ({ interaction }) => {
};

const data = await fetch(
process.env.API_ENDPOINT + "/bot/commands/trivia",
process.env.API_ENDPOINT_NEXT + "/bot/commands/trivia",
{
method: "POST",
headers: {
Expand Down Expand Up @@ -92,7 +92,7 @@ export default command(meta, async ({ interaction }) => {
};

const data = await fetch(
process.env.API_ENDPOINT + "/bot/commands/quotes",
process.env.API_ENDPOINT_NEXT + "/bot/commands/quotes",
{
method: "POST",
headers: {
Expand Down
16 changes: 12 additions & 4 deletions src/commands/team/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { category } from "utils";
import who from "./who";
import link from "./link";
// import link from "./link";
import create from "./create";
import update from "./update";
import pass from "./pass";
import sync from "./sync";
import linkv2 from "./linkv2";
import auth from "./auth";
import keys from "./keys";

export default category("Team", [who, link, create, pass, sync]);
export default category("Team", [
who,
create,
sync,
linkv2,
auth,
keys,
]);
Loading

0 comments on commit 43313c8

Please sign in to comment.