Compare commits
19 commits
main
...
feature/19
Author | SHA1 | Date | |
---|---|---|---|
|
673b258fa9 | ||
|
6f4ff1df06 | ||
|
690b63470a | ||
|
7b620dfd90 | ||
|
50c237f6fa | ||
|
832f88fd85 | ||
|
2b35629506 | ||
|
0ce9ff5453 | ||
|
b1afc79dda | ||
|
7ccfa34562 | ||
|
f1c7cdc6d6 | ||
|
1371a30eee | ||
|
34398e5657 | ||
|
cd0737cf3b | ||
|
5f22a31398 | ||
|
932d3ac3d5 | ||
|
6412ad0ad4 | ||
|
f1c513bd16 | ||
|
942fea12bf |
|
@ -7,7 +7,7 @@
|
||||||
# any secret values.
|
# any secret values.
|
||||||
|
|
||||||
BOT_TOKEN=
|
BOT_TOKEN=
|
||||||
BOT_VER=3.2.1
|
BOT_VER=3.3.0
|
||||||
BOT_AUTHOR=Vylpes
|
BOT_AUTHOR=Vylpes
|
||||||
BOT_OWNERID=147392775707426816
|
BOT_OWNERID=147392775707426816
|
||||||
BOT_CLIENTID=682942374040961060
|
BOT_CLIENTID=682942374040961060
|
||||||
|
@ -23,4 +23,6 @@ DB_NAME=vylbot
|
||||||
DB_AUTH_USER=dev
|
DB_AUTH_USER=dev
|
||||||
DB_AUTH_PASS=dev
|
DB_AUTH_PASS=dev
|
||||||
DB_SYNC=true
|
DB_SYNC=true
|
||||||
DB_LOGGING=true
|
DB_LOGGING=true
|
||||||
|
DB_ROOT_HOST=0.0.0.0
|
||||||
|
DB_DATA_LOCATION=./.temp/database
|
||||||
|
|
|
@ -12,14 +12,14 @@ jobs:
|
||||||
runs-on: node
|
runs-on: node
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- name: Use Node.js
|
- name: Use Node.js
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 18.x
|
node-version: 18.x
|
||||||
- run: npm ci
|
- run: yarn install --frozen-lockfile
|
||||||
- run: npm run build
|
- run: yarn build
|
||||||
- run: npm test
|
- run: yarn test
|
||||||
|
|
||||||
- name: "Copy files over to location"
|
- name: "Copy files over to location"
|
||||||
run: cp -r . ${{ secrets.PROD_REPO_PATH }}
|
run: cp -r . ${{ secrets.PROD_REPO_PATH }}
|
||||||
|
@ -63,5 +63,5 @@ jobs:
|
||||||
&& (pm2 delete vylbot_prod || true) \
|
&& (pm2 delete vylbot_prod || true) \
|
||||||
&& docker compose up -d \
|
&& docker compose up -d \
|
||||||
&& sleep 10 \
|
&& sleep 10 \
|
||||||
&& npm run db:up \
|
&& yarn db:up \
|
||||||
&& pm2 start --name vylbot_prod dist/vylbot.js
|
&& pm2 start --name vylbot_prod dist/vylbot.js
|
||||||
|
|
|
@ -12,14 +12,14 @@ jobs:
|
||||||
runs-on: node
|
runs-on: node
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- name: Use Node.js
|
- name: Use Node.js
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 18.x
|
node-version: 18.x
|
||||||
- run: npm ci
|
- run: yarn install --frozen-lockfile
|
||||||
- run: npm run build
|
- run: yarn build
|
||||||
- run: npm test
|
- run: yarn test
|
||||||
|
|
||||||
- name: "Copy files over to location"
|
- name: "Copy files over to location"
|
||||||
run: cp -r . ${{ secrets.STAGE_REPO_PATH }}
|
run: cp -r . ${{ secrets.STAGE_REPO_PATH }}
|
||||||
|
@ -63,5 +63,5 @@ jobs:
|
||||||
&& (pm2 delete vylbot_stage || true) \
|
&& (pm2 delete vylbot_stage || true) \
|
||||||
&& docker compose up -d \
|
&& docker compose up -d \
|
||||||
&& sleep 10 \
|
&& sleep 10 \
|
||||||
&& npm run db:up \
|
&& yarn db:up \
|
||||||
&& pm2 start --name vylbot_stage dist/vylbot.js
|
&& pm2 start --name vylbot_stage dist/vylbot.js
|
||||||
|
|
|
@ -14,11 +14,11 @@ jobs:
|
||||||
runs-on: node
|
runs-on: node
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- name: Use Node.js
|
- name: Use Node.js
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 18.x
|
node-version: 18.x
|
||||||
- run: npm ci
|
- run: yarn install --frozen-lockfile
|
||||||
- run: npm run build
|
- run: yarn build
|
||||||
- run: npm test
|
- run: yarn test
|
||||||
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -105,4 +105,5 @@ dist
|
||||||
|
|
||||||
config.json
|
config.json
|
||||||
.DS_Store
|
.DS_Store
|
||||||
ormconfig.json
|
ormconfig.json
|
||||||
|
.temp/
|
||||||
|
|
9
database/3.3.0/1719856023429-CreateMoon/Up/01-Moon.sql
Normal file
9
database/3.3.0/1719856023429-CreateMoon/Up/01-Moon.sql
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
CREATE TABLE `moon` (
|
||||||
|
`Id` varchar(255) NOT NULL,
|
||||||
|
`WhenCreated` datetime NOT NULL,
|
||||||
|
`WhenUpdated` datetime NOT NULL,
|
||||||
|
`MoonNumber` int NOT NULL,
|
||||||
|
`UserId` varchar(255) NOT NULL,
|
||||||
|
`Description` varchar(255) NOT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||||
|
|
8815
package-lock.json
generated
8815
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -29,13 +29,13 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/rest": "^2.0.0",
|
"@discordjs/rest": "^2.0.0",
|
||||||
"@types/jest": "^29.0.0",
|
"@types/jest": "^29.0.0",
|
||||||
"@types/uuid": "^9.0.0",
|
"@types/uuid": "^10.0.0",
|
||||||
"discord.js": "^14.3.0",
|
"discord.js": "^14.3.0",
|
||||||
"dotenv": "^16.0.0",
|
"dotenv": "^16.0.0",
|
||||||
"emoji-regex": "^10.0.0",
|
"emoji-regex": "^10.0.0",
|
||||||
"jest": "^29.0.0",
|
"jest": "^29.0.0",
|
||||||
"jest-mock-extended": "^3.0.0",
|
"jest-mock-extended": "^3.0.0",
|
||||||
"minimatch": "9.0.3",
|
"minimatch": "9.0.5",
|
||||||
"mysql": "^2.18.1",
|
"mysql": "^2.18.1",
|
||||||
"random-bunny": "^2.1.6",
|
"random-bunny": "^2.1.6",
|
||||||
"ts-jest": "^29.0.0",
|
"ts-jest": "^29.0.0",
|
||||||
|
|
35
src/commands/304276391837302787/moons.ts
Normal file
35
src/commands/304276391837302787/moons.ts
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
import { Command } from "../../type/command";
|
||||||
|
import { CommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||||
|
import ListMoons from "./moons/list";
|
||||||
|
|
||||||
|
export default class Moons extends Command {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.CommandBuilder = new SlashCommandBuilder()
|
||||||
|
.setName("moons")
|
||||||
|
.setDescription("View and create moons")
|
||||||
|
.addSubcommand(subcommand =>
|
||||||
|
subcommand
|
||||||
|
.setName('list')
|
||||||
|
.setDescription('List moons you have obtained')
|
||||||
|
.addUserOption(option =>
|
||||||
|
option
|
||||||
|
.setName("user")
|
||||||
|
.setDescription("The user to view (Defaults to yourself)"))
|
||||||
|
.addNumberOption(option =>
|
||||||
|
option
|
||||||
|
.setName("page")
|
||||||
|
.setDescription("The page to start with")));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async execute(interaction: CommandInteraction) {
|
||||||
|
if (!interaction.isChatInputCommand()) return;
|
||||||
|
|
||||||
|
switch (interaction.options.getSubcommand()) {
|
||||||
|
case "list":
|
||||||
|
await ListMoons(interaction);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
44
src/commands/304276391837302787/moons/list.ts
Normal file
44
src/commands/304276391837302787/moons/list.ts
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
import {ActionRowBuilder, ButtonBuilder, ButtonStyle, CommandInteraction, EmbedBuilder} from "discord.js";
|
||||||
|
import Moon from "../../../database/entities/Moon";
|
||||||
|
import EmbedColours from "../../../constants/EmbedColours";
|
||||||
|
import MoonValues from "../../../constants/MoonValues";
|
||||||
|
|
||||||
|
export default async function ListMoons(interaction: CommandInteraction) {
|
||||||
|
const user = interaction.options.get("user")?.user ?? interaction.user;
|
||||||
|
const page = interaction.options.get("page")?.value as number ?? 0;
|
||||||
|
|
||||||
|
const moons = await Moon.FetchPaginatedMoonsByUserId(user.id, page);
|
||||||
|
|
||||||
|
if (!moons || moons[0].length == 0) {
|
||||||
|
await interaction.reply(`${user.username} does not have any moons or page is invalid.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const totalPages = Math.ceil(moons[1] / MoonValues.ListPageLength);
|
||||||
|
|
||||||
|
const description = moons[0].flatMap(x => `${x.MoonNumber}. ${x.Description.slice(0, 15)}`);
|
||||||
|
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setTitle(`${user.username}'s Moons`)
|
||||||
|
.setColor(EmbedColours.Ok)
|
||||||
|
.setDescription(description.join("\n"))
|
||||||
|
.setFooter({ text: `${moons.length} moons` });
|
||||||
|
|
||||||
|
const row = new ActionRowBuilder<ButtonBuilder>()
|
||||||
|
.addComponents(
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setCustomId(`moons ${user} ${page - 1}`)
|
||||||
|
.setLabel("Previous")
|
||||||
|
.setStyle(ButtonStyle.Primary)
|
||||||
|
.setDisabled(page == 0),
|
||||||
|
new ButtonBuilder()
|
||||||
|
.setCustomId(`moons ${user.id} ${page + 1}`)
|
||||||
|
.setLabel("Next")
|
||||||
|
.setStyle(ButtonStyle.Primary)
|
||||||
|
.setDisabled(page + 1 == totalPages));
|
||||||
|
|
||||||
|
await interaction.reply({
|
||||||
|
embeds: [ embed ],
|
||||||
|
components: [ row ],
|
||||||
|
});
|
||||||
|
}
|
|
@ -93,7 +93,7 @@ export default class Audits extends Command {
|
||||||
private async SendAuditForUser(interaction: CommandInteraction) {
|
private async SendAuditForUser(interaction: CommandInteraction) {
|
||||||
if (!interaction.guildId) return;
|
if (!interaction.guildId) return;
|
||||||
|
|
||||||
const user = interaction.options.getUser('target');
|
const user = interaction.options.get('target', true).user!;
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
await interaction.reply("User not found.");
|
await interaction.reply("User not found.");
|
||||||
|
@ -191,7 +191,7 @@ export default class Audits extends Command {
|
||||||
private async AddAudit(interaction: CommandInteraction) {
|
private async AddAudit(interaction: CommandInteraction) {
|
||||||
if (!interaction.guildId) return;
|
if (!interaction.guildId) return;
|
||||||
|
|
||||||
const user = interaction.options.getUser('target');
|
const user = interaction.options.get('target', true).user!;
|
||||||
const auditType = interaction.options.get('type');
|
const auditType = interaction.options.get('type');
|
||||||
const reasonInput = interaction.options.get('reason');
|
const reasonInput = interaction.options.get('reason');
|
||||||
|
|
||||||
|
@ -209,4 +209,4 @@ export default class Audits extends Command {
|
||||||
|
|
||||||
await interaction.reply(`Created new audit with ID \`${audit.AuditId}\``);
|
await interaction.reply(`Created new audit with ID \`${audit.AuditId}\``);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
24
src/commands/say.ts
Normal file
24
src/commands/say.ts
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, CommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js";
|
||||||
|
import EmbedColours from "../constants/EmbedColours";
|
||||||
|
import { Command } from "../type/command";
|
||||||
|
|
||||||
|
export default class Say extends Command {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.CommandBuilder = new SlashCommandBuilder()
|
||||||
|
.setName('say')
|
||||||
|
.setDescription('Have the bot reply with your message')
|
||||||
|
.addStringOption(x =>
|
||||||
|
x
|
||||||
|
.setName("message")
|
||||||
|
.setDescription("The message to repeat")
|
||||||
|
.setRequired(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async execute(interaction: CommandInteraction) {
|
||||||
|
const message = interaction.options.get("message", true);
|
||||||
|
|
||||||
|
await interaction.reply(message.value as string);
|
||||||
|
}
|
||||||
|
}
|
3
src/constants/MoonValues.ts
Normal file
3
src/constants/MoonValues.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export default class MoonValues {
|
||||||
|
public static readonly ListPageLength = 10;
|
||||||
|
}
|
47
src/database/entities/Moon.ts
Normal file
47
src/database/entities/Moon.ts
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
import { Column, Entity } from "typeorm";
|
||||||
|
import BaseEntity from "../../contracts/BaseEntity";
|
||||||
|
import AppDataSource from "../dataSources/appDataSource";
|
||||||
|
import MoonValues from "../../constants/MoonValues";
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export default class Moon extends BaseEntity {
|
||||||
|
constructor(moonNumber: number, description: string, userId: string) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.MoonNumber = moonNumber;
|
||||||
|
this.Description = description;
|
||||||
|
this.UserId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
MoonNumber: number;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
Description: string;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
UserId: string;
|
||||||
|
|
||||||
|
public static async FetchMoonsByUserId(userId: string): Promise<Moon[] | null> {
|
||||||
|
const repository = AppDataSource.getRepository(Moon);
|
||||||
|
|
||||||
|
const all = await repository.find({ where: { UserId: userId } });
|
||||||
|
|
||||||
|
return all;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async FetchPaginatedMoonsByUserId(userId: string, page: number): Promise<[ Moon[], number ]> {
|
||||||
|
const rangeStart = page * MoonValues.ListPageLength;
|
||||||
|
|
||||||
|
const repository = AppDataSource.getRepository(Moon);
|
||||||
|
|
||||||
|
const moons = await repository.findAndCount({
|
||||||
|
where: { UserId: userId },
|
||||||
|
order: { MoonNumber: "ASC" },
|
||||||
|
skip: rangeStart,
|
||||||
|
take: MoonValues.ListPageLength,
|
||||||
|
});
|
||||||
|
|
||||||
|
return moons;
|
||||||
|
}
|
||||||
|
}
|
15
src/database/migrations/3.3/1719856023429-CreateMoon.ts
Normal file
15
src/database/migrations/3.3/1719856023429-CreateMoon.ts
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm"
|
||||||
|
import MigrationHelper from "../../../helpers/MigrationHelper"
|
||||||
|
|
||||||
|
export class CreateMoon1719856023429 implements MigrationInterface {
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
MigrationHelper.Up('1719856023429-CreateMoon', '3.3.0', [
|
||||||
|
"01-Moon",
|
||||||
|
], queryRunner);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -17,6 +17,7 @@ import Poll from "./commands/poll";
|
||||||
import Role from "./commands/Role/role";
|
import Role from "./commands/Role/role";
|
||||||
import ConfigRole from "./commands/Role/config";
|
import ConfigRole from "./commands/Role/config";
|
||||||
import Rules from "./commands/rules";
|
import Rules from "./commands/rules";
|
||||||
|
import Say from "./commands/say";
|
||||||
import Setup from "./commands/setup";
|
import Setup from "./commands/setup";
|
||||||
import Timeout from "./commands/timeout";
|
import Timeout from "./commands/timeout";
|
||||||
import Unmute from "./commands/unmute";
|
import Unmute from "./commands/unmute";
|
||||||
|
@ -29,6 +30,9 @@ import AddLobby from "./commands/501231711271780357/Lobby/add";
|
||||||
import RemoveLobby from "./commands/501231711271780357/Lobby/remove";
|
import RemoveLobby from "./commands/501231711271780357/Lobby/remove";
|
||||||
import ListLobby from "./commands/501231711271780357/Lobby/list";
|
import ListLobby from "./commands/501231711271780357/Lobby/list";
|
||||||
|
|
||||||
|
// Command Imports: Potato Talk
|
||||||
|
import Moons from "./commands/304276391837302787/moons";
|
||||||
|
|
||||||
// Event Imports
|
// Event Imports
|
||||||
import GuildMemberAdd from "./events/MemberEvents/GuildMemberAdd";
|
import GuildMemberAdd from "./events/MemberEvents/GuildMemberAdd";
|
||||||
import GuildMemberRemove from "./events/MemberEvents/GuildMemberRemove";
|
import GuildMemberRemove from "./events/MemberEvents/GuildMemberRemove";
|
||||||
|
@ -55,6 +59,7 @@ export default class Registry {
|
||||||
CoreClient.RegisterCommand("mute", new Mute());
|
CoreClient.RegisterCommand("mute", new Mute());
|
||||||
CoreClient.RegisterCommand("poll", new Poll());
|
CoreClient.RegisterCommand("poll", new Poll());
|
||||||
CoreClient.RegisterCommand("rules", new Rules());
|
CoreClient.RegisterCommand("rules", new Rules());
|
||||||
|
CoreClient.RegisterCommand("say", new Say());
|
||||||
CoreClient.RegisterCommand("setup", new Setup());
|
CoreClient.RegisterCommand("setup", new Setup());
|
||||||
CoreClient.RegisterCommand("timeout", new Timeout());
|
CoreClient.RegisterCommand("timeout", new Timeout());
|
||||||
CoreClient.RegisterCommand("unmute", new Unmute());
|
CoreClient.RegisterCommand("unmute", new Unmute());
|
||||||
|
@ -70,12 +75,16 @@ export default class Registry {
|
||||||
CoreClient.RegisterCommand("listlobby", new ListLobby(), "501231711271780357");
|
CoreClient.RegisterCommand("listlobby", new ListLobby(), "501231711271780357");
|
||||||
CoreClient.RegisterCommand("entry", new Entry(), "501231711271780357");
|
CoreClient.RegisterCommand("entry", new Entry(), "501231711271780357");
|
||||||
|
|
||||||
|
// Exclusive Commands: Potato Talk
|
||||||
|
CoreClient.RegisterCommand("moons", new Moons(), "304276391837302787");
|
||||||
|
|
||||||
// Add Exclusive Commands to Test Server
|
// Add Exclusive Commands to Test Server
|
||||||
CoreClient.RegisterCommand("lobby", new Lobby(), "442730357897429002");
|
CoreClient.RegisterCommand("lobby", new Lobby(), "442730357897429002");
|
||||||
CoreClient.RegisterCommand("addlobby", new AddLobby(), "442730357897429002");
|
CoreClient.RegisterCommand("addlobby", new AddLobby(), "442730357897429002");
|
||||||
CoreClient.RegisterCommand("removelobby", new RemoveLobby(), "442730357897429002");
|
CoreClient.RegisterCommand("removelobby", new RemoveLobby(), "442730357897429002");
|
||||||
CoreClient.RegisterCommand("listlobby", new ListLobby(), "442730357897429002");
|
CoreClient.RegisterCommand("listlobby", new ListLobby(), "442730357897429002");
|
||||||
CoreClient.RegisterCommand("entry", new Entry(), "442730357897429002");
|
CoreClient.RegisterCommand("entry", new Entry(), "442730357897429002");
|
||||||
|
CoreClient.RegisterCommand("moons", new Moons(), "442730357897429002");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RegisterEvents() {
|
public static RegisterEvents() {
|
||||||
|
@ -91,4 +100,4 @@ export default class Registry {
|
||||||
public static RegisterButtonEvents() {
|
public static RegisterButtonEvents() {
|
||||||
CoreClient.RegisterButtonEvent("verify", new Verify());
|
CoreClient.RegisterButtonEvent("verify", new Verify());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue