Compare commits

..

24 commits

Author SHA1 Message Date
4bb26e5a60 Update dependency minimatch to v9.0.4
All checks were successful
Test / build (push) Successful in 6s
2024-04-28 23:03:06 +00:00
35646ef153 Update test script to use node
All checks were successful
Deploy To Production / build (push) Successful in 6s
Deploy To Stage / build (push) Successful in 6s
Deploy To Stage / deploy (push) Successful in 16s
Deploy To Production / deploy (push) Successful in 15s
2024-04-28 17:15:18 +01:00
16e0165922 Update stage script
All checks were successful
Deploy To Stage / build (push) Successful in 7s
Deploy To Stage / deploy (push) Successful in 16s
Deploy To Production / build (push) Successful in 7s
Deploy To Production / deploy (push) Successful in 13s
2024-04-28 17:09:57 +01:00
cb1b098daa Add stage script
Some checks failed
Deploy To Stage / build (push) Successful in 7s
Deploy To Stage / deploy (push) Failing after 5s
2024-04-28 17:07:25 +01:00
c33b4a8fdb Merge branch 'main' into develop 2024-04-28 17:05:53 +01:00
c6788370de Copy command
All checks were successful
Deploy To Production / build (push) Successful in 11s
Deploy To Production / deploy (push) Successful in 17s
2024-04-28 17:01:11 +01:00
a7bb5d995a Temp: ls
Some checks failed
Deploy To Production / build (push) Successful in 12s
Deploy To Production / deploy (push) Failing after 1s
2024-04-28 16:56:33 +01:00
00c90aec80 Source .sshrc
Some checks failed
Deploy To Production / build (push) Successful in 11s
Deploy To Production / deploy (push) Failing after 1s
2024-04-28 16:26:46 +01:00
13dd2558f2 Migrate to npm
Some checks failed
Deploy To Production / build (push) Successful in 37s
Deploy To Production / deploy (push) Failing after 14s
2024-04-28 16:19:16 +01:00
f7f304d1f4 Undo bash source
Some checks failed
Deploy To Production / build (push) Successful in 7s
Deploy To Production / deploy (push) Failing after 14s
2024-04-28 16:11:02 +01:00
344d6c01eb Cd first
Some checks failed
Deploy To Production / build (push) Successful in 9s
Deploy To Production / deploy (push) Failing after 14s
2024-04-28 16:09:18 +01:00
b62f799531 Use .bashrc
Some checks failed
Deploy To Production / build (push) Successful in 6s
Deploy To Production / deploy (push) Failing after 14s
2024-04-28 16:07:31 +01:00
0a340f36cf Use prod_
Some checks failed
Deploy To Production / build (push) Successful in 6s
Deploy To Production / deploy (push) Failing after 14s
2024-04-28 16:05:43 +01:00
9f7c622514 Runs on node
Some checks failed
Deploy To Production / build (push) Successful in 25s
Deploy To Production / deploy (push) Failing after 4s
2024-04-28 16:02:46 +01:00
ed3517ecda Use forgejo runner
Some checks failed
Deploy To Production / build (push) Failing after 13s
Deploy To Production / deploy (push) Has been skipped
2024-04-28 15:49:54 +01:00
c6cb35a12c Merge branch 'main' into develop
All checks were successful
continuous-integration/drone/push Build is passing
2024-04-19 18:24:57 +01:00
3b0586ddad v3.2.2
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2024-04-19 18:24:04 +01:00
1c430222aa Revert release bump 2024-04-19 18:24:00 +01:00
c9789a3c77 Update drone deployment
All checks were successful
continuous-integration/drone/push Build is passing
2024-04-19 18:20:01 +01:00
5678097aac v3.2.2
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is failing
2024-04-19 18:18:04 +01:00
d6330ae501 3.2.2
All checks were successful
continuous-integration/drone/push Build is passing
2024-04-19 18:16:45 +01:00
f3d67bb33a Update bunny command to defer reply until it finds an image 2024-04-19 18:16:25 +01:00
790afcca4a Update random-bunny to v2.1.6 2024-04-19 18:15:59 +01:00
2b04952d85 Update cache helper using the wrong symbol to measure interval
All checks were successful
continuous-integration/drone/push Build is passing
2024-03-30 16:15:53 +00:00
38 changed files with 9023 additions and 4962 deletions

View file

@ -7,7 +7,7 @@ steps:
- name: deploy - name: deploy
image: appleboy/drone-ssh image: appleboy/drone-ssh
settings: settings:
host: 192.168.68.120 host: 192.168.1.115
username: vylpes username: vylpes
password: password:
from_secret: ssh_password from_secret: ssh_password
@ -28,7 +28,7 @@ steps:
- name: stage - name: stage
image: appleboy/drone-ssh image: appleboy/drone-ssh
settings: settings:
host: 192.168.68.120 host: 192.168.1.115
username: vylpes username: vylpes
password: password:
from_secret: ssh_password from_secret: ssh_password

View file

@ -0,0 +1,67 @@
name: Deploy To Production
on:
push:
branches:
- main
jobs:
build:
environment: prod
runs-on: node
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 18.x
- run: npm ci
- run: npm run build
- run: npm test
- name: "Copy files over to location"
run: cp -r . ${{ secrets.PROD_REPO_PATH }}
deploy:
environment: prod
needs: build
runs-on: node
steps:
- uses: https://github.com/appleboy/ssh-action@v1.0.0
env:
DB_NAME: ${{ secrets.PROD_DB_NAME }}
DB_AUTH_USER: ${{ secrets.PROD_DB_AUTH_USER }}
DB_AUTH_PASS: ${{ secrets.PROD_DB_AUTH_PASS }}
DB_HOST: ${{ secrets.PROD_DB_HOST }}
DB_PORT: ${{ secrets.PROD_DB_PORT }}
DB_ROOT_HOST: ${{ secrets.PROD_DB_ROOT_HOST }}
DB_SYNC: ${{ secrets.PROD_DB_SYNC }}
DB_LOGGING: ${{ secrets.PROD_DB_LOGGING }}
DB_DATA_LOCATION: ${{ secrets.PROD_DB_DATA_LOCATION }}
SERVER_PATH: ${{ secrets.PROD_SSH_SERVER_PATH }}
BOT_TOKEN: ${{ secrets.PROD_BOT_TOKEN }}
BOT_VER: ${{ vars.PROD_BOT_VER }}
BOT_AUTHOR: ${{ vars.PROD_BOT_AUTHOR }}
BOT_OWNERID: ${{ vars.PROD_BOT_OWNERID }}
BOT_CLIENTID: ${{ vars.PROD_BOT_CLIENTID }}
ABOUT_FUNDING: ${{ vars.PROD_ABOUT_FUNDING }}
ABOUT_REPO: ${{ vars.PROD_ABOUT_REPO }}
CACHE_INTERVAL: ${{ vars.PROD_CACHE_INTERVAL }}
with:
host: ${{ secrets.PROD_SSH_HOST }}
username: ${{ secrets.PROD_SSH_USER }}
key: ${{ secrets.PROD_SSH_KEY }}
port: ${{ secrets.PROD_SSH_PORT }}
envs: DB_NAME,DB_AUTH_USER,DB_AUTH_PASS,DB_HOST,DB_PORT,DB_ROOT_HOST,DB_SYNC,DB_LOGGING,DB_DATA_LOCATION,BOT_TOKEN,BOT_VER,BOT_AUTHOR,BOT_OWNERID,BOT_CLIENTID,ABOUT_FUNDING,ABOUT_REPO,CACHE_INTERVAL
script: |
source .sshrc \
&& cd /home/vylpes/apps/vylbot/vylbot_prod \
&& docker compose down \
&& (pm2 stop vylbot_prod || true) \
&& (pm2 delete vylbot_prod || true) \
&& docker compose up -d \
&& sleep 10 \
&& npm run db:up \
&& pm2 start --name vylbot_prod dist/vylbot.js

View file

@ -0,0 +1,67 @@
name: Deploy To Stage
on:
push:
branches:
- develop
jobs:
build:
environment: prod
runs-on: node
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 18.x
- run: npm ci
- run: npm run build
- run: npm test
- name: "Copy files over to location"
run: cp -r . ${{ secrets.STAGE_REPO_PATH }}
deploy:
environment: prod
needs: build
runs-on: node
steps:
- uses: https://github.com/appleboy/ssh-action@v1.0.0
env:
DB_NAME: ${{ secrets.STAGE_DB_NAME }}
DB_AUTH_USER: ${{ secrets.STAGE_DB_AUTH_USER }}
DB_AUTH_PASS: ${{ secrets.STAGE_DB_AUTH_PASS }}
DB_HOST: ${{ secrets.STAGE_DB_HOST }}
DB_PORT: ${{ secrets.STAGE_DB_PORT }}
DB_ROOT_HOST: ${{ secrets.STAGE_DB_ROOT_HOST }}
DB_SYNC: ${{ secrets.STAGE_DB_SYNC }}
DB_LOGGING: ${{ secrets.STAGE_DB_LOGGING }}
DB_DATA_LOCATION: ${{ secrets.STAGE_DB_DATA_LOCATION }}
SERVER_PATH: ${{ secrets.STAGE_SSH_SERVER_PATH }}
BOT_TOKEN: ${{ secrets.STAGE_BOT_TOKEN }}
BOT_VER: ${{ vars.STAGE_BOT_VER }}
BOT_AUTHOR: ${{ vars.STAGE_BOT_AUTHOR }}
BOT_OWNERID: ${{ vars.STAGE_BOT_OWNERID }}
BOT_CLIENTID: ${{ vars.STAGE_BOT_CLIENTID }}
ABOUT_FUNDING: ${{ vars.STAGE_ABOUT_FUNDING }}
ABOUT_REPO: ${{ vars.STAGE_ABOUT_REPO }}
CACHE_INTERVAL: ${{ vars.STAGE_CACHE_INTERVAL }}
with:
host: ${{ secrets.STAGE_SSH_HOST }}
username: ${{ secrets.STAGE_SSH_USER }}
key: ${{ secrets.STAGE_SSH_KEY }}
port: ${{ secrets.STAGE_SSH_PORT }}
envs: DB_NAME,DB_AUTH_USER,DB_AUTH_PASS,DB_HOST,DB_PORT,DB_ROOT_HOST,DB_SYNC,DB_LOGGING,DB_DATA_LOCATION,BOT_TOKEN,BOT_VER,BOT_AUTHOR,BOT_OWNERID,BOT_CLIENTID,ABOUT_FUNDING,ABOUT_REPO,CACHE_INTERVAL
script: |
source .sshrc \
&& cd /home/vylpes/apps/vylbot/vylbot_stage \
&& docker compose down \
&& (pm2 stop vylbot_stage || true) \
&& (pm2 delete vylbot_stage || true) \
&& docker compose up -d \
&& sleep 10 \
&& npm run db:up \
&& pm2 start --name vylbot_stage dist/vylbot.js

View file

@ -0,0 +1,24 @@
name: Test
on:
push:
branches:
- feature/*
- hotfix/*
- renovate/*
jobs:
build:
environment: stage
runs-on: node
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 18.x
- run: npm ci
- run: npm run build
- run: npm test

View file

@ -1,26 +0,0 @@
# Security Warning! Do not commit this file to any VCS!
# This is a local file to speed up development process,
# so you don't have to change your environment variables.
#
# This is not applied to `.env.template`!
# Template files must be committed to the VCS, but must not contain
# any secret values.
BOT_TOKEN=
BOT_VER=3.2.1
BOT_AUTHOR=Vylpes
BOT_OWNERID=147392775707426816
BOT_CLIENTID=680083120896081954
ABOUT_FUNDING=https://ko-fi.com/vylpes
ABOUT_REPO=https://gitea.vylpes.xyz/RabbitLabs/vylbot-app
CACHE_INTERVAL=1800000 # 30 minutes
DB_HOST=127.0.0.1
DB_PORT=3121
DB_NAME=vylbot
DB_AUTH_USER=prod
DB_AUTH_PASS=prod
DB_SYNC=false
DB_LOGGING=false

View file

@ -1,26 +0,0 @@
# Security Warning! Do not commit this file to any VCS!
# This is a local file to speed up development process,
# so you don't have to change your environment variables.
#
# This is not applied to `.env.template`!
# Template files must be committed to the VCS, but must not contain
# any secret values.
BOT_TOKEN=
BOT_VER=3.2.1
BOT_AUTHOR=Vylpes
BOT_OWNERID=147392775707426816
BOT_CLIENTID=1016767908740857949
ABOUT_FUNDING=https://ko-fi.com/vylpes
ABOUT_REPO=https://gitea.vylpes.xyz/RabbitLabs/vylbot-app
CACHE_INTERVAL=1800000 # 30 minutes
DB_HOST=127.0.0.1
DB_PORT=3111
DB_NAME=vylbot
DB_AUTH_USER=stage
DB_AUTH_PASS=stage
DB_SYNC=false
DB_LOGGING=false

View file

@ -1,31 +0,0 @@
version: "3.9"
volumes:
prod_database_data:
services:
# discord:
# build: .
database:
image: mysql/mysql-server
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
- MYSQL_DATABASE=vylbot
- MYSQL_USER=prod
- MYSQL_PASSWORD=prod
- MYSQL_ROOT_PASSWORD=root
- MYSQL_ROOT_HOST=0.0.0.0
ports:
- "3121:3306"
volumes:
- prod_database_data:/var/lib/mysql
phpmyadmin:
image: phpmyadmin
restart: always
ports:
- "3122:80"
environment:
- PMA_ARBITRARY=1

View file

@ -1,31 +0,0 @@
version: "3.9"
volumes:
stage_database_data:
services:
# discord:
# build: .
database:
image: mysql/mysql-server
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
- MYSQL_DATABASE=vylbot
- MYSQL_USER=stage
- MYSQL_PASSWORD=stage
- MYSQL_ROOT_PASSWORD=root
- MYSQL_ROOT_HOST=0.0.0.0
ports:
- "3111:3306"
volumes:
- stage_database_data:/var/lib/mysql
phpmyadmin:
image: phpmyadmin
restart: always
ports:
- "3112:80"
environment:
- PMA_ARBITRARY=1

View file

@ -1,31 +1,17 @@
version: "3.9" version: "3.9"
volumes:
dev_database_data:
services: services:
# discord:
# build: .
database: database:
image: mysql/mysql-server image: mysql/mysql-server
command: --default-authentication-plugin=mysql_native_password command: --default-authentication-plugin=mysql_native_password
restart: always restart: always
environment: environment:
- MYSQL_DATABASE=vylbot - MYSQL_DATABASE=$DB_NAME
- MYSQL_USER=dev - MYSQL_USER=$DB_AUTH_USER
- MYSQL_PASSWORD=dev - MYSQL_PASSWORD=$DB_AUTH_PASS
- MYSQL_ROOT_PASSWORD=root - MYSQL_ROOT_PASSWORD=$DB_AUTH_PASS
- MYSQL_ROOT_HOST=0.0.0.0 - MYSQL_ROOT_HOST=$DB_ROOT_HOST
ports: ports:
- "3101:3306" - "$DB_PORT:3306"
volumes: volumes:
- dev_database_data:/var/lib/mysql - $DB_DATA_LOCATION:/var/lib/mysql
phpmyadmin:
image: phpmyadmin
restart: always
ports:
- "3102:80"
environment:
- PMA_ARBITRARY=1

8815
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{ {
"name": "vylbot-app", "name": "vylbot-app",
"version": "3.2.1", "version": "3.2.2",
"description": "A discord bot made for Vylpes' Den", "description": "A discord bot made for Vylpes' Den",
"main": "./dist/vylbot", "main": "./dist/vylbot",
"typings": "./dist", "typings": "./dist",
@ -37,7 +37,7 @@
"jest-mock-extended": "^3.0.0", "jest-mock-extended": "^3.0.0",
"minimatch": "9.0.4", "minimatch": "9.0.4",
"mysql": "^2.18.1", "mysql": "^2.18.1",
"random-bunny": "^2.0.5", "random-bunny": "^2.1.6",
"ts-jest": "^29.0.0", "ts-jest": "^29.0.0",
"typeorm": "0.3.20" "typeorm": "0.3.20"
}, },

View file

@ -6,7 +6,7 @@ export default class AddRole extends Command {
constructor() { constructor() {
super(); super();
super.CommandBuilder = new SlashCommandBuilder() this.CommandBuilder = new SlashCommandBuilder()
.setName('addlobby') .setName('addlobby')
.setDescription('Add lobby channel') .setDescription('Add lobby channel')
.setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers) .setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers)

View file

@ -7,7 +7,7 @@ export default class ListLobby extends Command {
constructor() { constructor() {
super(); super();
super.CommandBuilder = new SlashCommandBuilder() this.CommandBuilder = new SlashCommandBuilder()
.setName('listlobby') .setName('listlobby')
.setDescription('Lists all channels set up as lobbies') .setDescription('Lists all channels set up as lobbies')
.setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers); .setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers);

View file

@ -6,7 +6,7 @@ export default class Lobby extends Command {
constructor() { constructor() {
super(); super();
super.CommandBuilder = new SlashCommandBuilder() this.CommandBuilder = new SlashCommandBuilder()
.setName('lobby') .setName('lobby')
.setDescription('Attempt to organise a lobby'); .setDescription('Attempt to organise a lobby');
} }

View file

@ -7,7 +7,7 @@ export default class RemoveLobby extends Command {
constructor() { constructor() {
super(); super();
super.CommandBuilder = new SlashCommandBuilder() this.CommandBuilder = new SlashCommandBuilder()
.setName('removelobby') .setName('removelobby')
.setDescription('Remove a lobby channel') .setDescription('Remove a lobby channel')
.setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers) .setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers)

View file

@ -7,7 +7,7 @@ export default class Entry extends Command {
constructor() { constructor() {
super(); super();
super.CommandBuilder = new SlashCommandBuilder() this.CommandBuilder = new SlashCommandBuilder()
.setName('entry') .setName('entry')
.setDescription('Sends the entry embed') .setDescription('Sends the entry embed')
.setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers); .setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers);

View file

@ -7,7 +7,7 @@ export default class ConfigRole extends Command {
constructor() { constructor() {
super(); super();
super.CommandBuilder = new SlashCommandBuilder() this.CommandBuilder = new SlashCommandBuilder()
.setName('configrole') .setName('configrole')
.setDescription('Toggle your roles') .setDescription('Toggle your roles')
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageRoles) .setDefaultMemberPermissions(PermissionsBitField.Flags.ManageRoles)

View file

@ -7,7 +7,7 @@ export default class Role extends Command {
constructor() { constructor() {
super(); super();
super.CommandBuilder = new SlashCommandBuilder() this.CommandBuilder = new SlashCommandBuilder()
.setName('role') .setName('role')
.setDescription('Toggle your roles') .setDescription('Toggle your roles')
.addSubcommand(subcommand => .addSubcommand(subcommand =>

View file

@ -6,7 +6,7 @@ export default class About extends Command {
constructor() { constructor() {
super(); super();
super.CommandBuilder = new SlashCommandBuilder() this.CommandBuilder = new SlashCommandBuilder()
.setName('about') .setName('about')
.setDescription('About VylBot'); .setDescription('About VylBot');
} }

View file

@ -9,7 +9,7 @@ export default class Audits extends Command {
constructor() { constructor() {
super(); super();
super.CommandBuilder = new SlashCommandBuilder() this.CommandBuilder = new SlashCommandBuilder()
.setName("audits") .setName("audits")
.setDescription("View audits of a particular user in the server") .setDescription("View audits of a particular user in the server")
.setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers) .setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers)

View file

@ -9,7 +9,7 @@ export default class Ban extends Command {
constructor() { constructor() {
super(); super();
super.CommandBuilder = new SlashCommandBuilder() this.CommandBuilder = new SlashCommandBuilder()
.setName("ban") .setName("ban")
.setDescription("Ban a member from the server with an optional reason") .setDescription("Ban a member from the server with an optional reason")
.setDefaultMemberPermissions(PermissionsBitField.Flags.BanMembers) .setDefaultMemberPermissions(PermissionsBitField.Flags.BanMembers)

View file

@ -7,7 +7,7 @@ export default class Bunny extends Command {
constructor() { constructor() {
super(); super();
super.CommandBuilder = new SlashCommandBuilder() this.CommandBuilder = new SlashCommandBuilder()
.setName("bunny") .setName("bunny")
.setDescription("Get a random picture of a rabbit."); .setDescription("Get a random picture of a rabbit.");
} }
@ -15,6 +15,8 @@ export default class Bunny extends Command {
public override async execute(interaction: CommandInteraction) { public override async execute(interaction: CommandInteraction) {
if (!interaction.isChatInputCommand()) return; if (!interaction.isChatInputCommand()) return;
await interaction.deferReply();
const subreddits = [ const subreddits = [
'rabbits', 'rabbits',
'bunnieswithhats', 'bunnieswithhats',
@ -37,9 +39,9 @@ export default class Bunny extends Command {
.setURL(`https://reddit.com${result.Result!.Permalink}`) .setURL(`https://reddit.com${result.Result!.Permalink}`)
.setFooter({ text: `r/${selectedSubreddit} · ${result.Result!.Ups} upvotes`}); .setFooter({ text: `r/${selectedSubreddit} · ${result.Result!.Ups} upvotes`});
await interaction.reply({ embeds: [ embed ]}); await interaction.editReply({ embeds: [ embed ]});
} else { } else {
await interaction.reply("There was an error running this command."); await interaction.editReply("There was an error running this command.");
} }
} }
} }

View file

@ -5,7 +5,7 @@ export default class Clear extends Command {
constructor() { constructor() {
super(); super();
super.CommandBuilder = new SlashCommandBuilder() this.CommandBuilder = new SlashCommandBuilder()
.setName("clear") .setName("clear")
.setDescription("Clears the channel of messages") .setDescription("Clears the channel of messages")
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageMessages) .setDefaultMemberPermissions(PermissionsBitField.Flags.ManageMessages)

View file

@ -7,7 +7,7 @@ export default class Code extends Command {
constructor() { constructor() {
super(); super();
super.CommandBuilder = new SlashCommandBuilder() this.CommandBuilder = new SlashCommandBuilder()
.setName('code') .setName('code')
.setDescription('Manage the verification code of the server') .setDescription('Manage the verification code of the server')
.setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers) .setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers)

View file

@ -10,7 +10,7 @@ export default class Config extends Command {
constructor() { constructor() {
super(); super();
super.CommandBuilder = new SlashCommandBuilder() this.CommandBuilder = new SlashCommandBuilder()
.setName('config') .setName('config')
.setDescription('Configure the current server') .setDescription('Configure the current server')
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator) .setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator)

View file

@ -6,7 +6,7 @@ export default class Disable extends Command {
constructor() { constructor() {
super(); super();
super.CommandBuilder = new SlashCommandBuilder() this.CommandBuilder = new SlashCommandBuilder()
.setName('disable') .setName('disable')
.setDescription('Disables a command') .setDescription('Disables a command')
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator) .setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator)

View file

@ -6,7 +6,7 @@ export default class Ignore extends Command {
constructor() { constructor() {
super(); super();
super.CommandBuilder = new SlashCommandBuilder() this.CommandBuilder = new SlashCommandBuilder()
.setName('ignore') .setName('ignore')
.setDescription('Ignore events in this channel') .setDescription('Ignore events in this channel')
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator); .setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator);

View file

@ -9,7 +9,7 @@ export default class Kick extends Command {
constructor() { constructor() {
super(); super();
super.CommandBuilder = new SlashCommandBuilder() this.CommandBuilder = new SlashCommandBuilder()
.setName("kick") .setName("kick")
.setDescription("Kick a member from the server with an optional reason") .setDescription("Kick a member from the server with an optional reason")
.setDefaultMemberPermissions(PermissionsBitField.Flags.KickMembers) .setDefaultMemberPermissions(PermissionsBitField.Flags.KickMembers)

View file

@ -9,7 +9,7 @@ export default class Mute extends Command {
constructor() { constructor() {
super(); super();
super.CommandBuilder = new SlashCommandBuilder() this.CommandBuilder = new SlashCommandBuilder()
.setName("mute") .setName("mute")
.setDescription("(DEPRECATED) Mute a member in the server with an optional reason") .setDescription("(DEPRECATED) Mute a member in the server with an optional reason")
.setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers) .setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers)

View file

@ -7,7 +7,7 @@ export default class Poll extends Command {
constructor() { constructor() {
super(); super();
super.CommandBuilder = new SlashCommandBuilder() this.CommandBuilder = new SlashCommandBuilder()
.setName('poll') .setName('poll')
.setDescription('Run a poll, automatically adding reaction emojis as options') .setDescription('Run a poll, automatically adding reaction emojis as options')
.addStringOption(option => .addStringOption(option =>

View file

@ -6,7 +6,7 @@ export default class Setup extends Command {
constructor() { constructor() {
super(); super();
super.CommandBuilder = new SlashCommandBuilder() this.CommandBuilder = new SlashCommandBuilder()
.setName('setup') .setName('setup')
.setDescription('Makes the server ready to be configured') .setDescription('Makes the server ready to be configured')
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator); .setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator);

View file

@ -10,7 +10,7 @@ export default class Timeout extends Command {
constructor() { constructor() {
super(); super();
super.CommandBuilder = new SlashCommandBuilder() this.CommandBuilder = new SlashCommandBuilder()
.setName("timeout") .setName("timeout")
.setDescription("Timeouts a user out, sending them a DM with the reason if possible") .setDescription("Timeouts a user out, sending them a DM with the reason if possible")
.setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers) .setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers)

View file

@ -7,7 +7,7 @@ export default class Unmute extends Command {
constructor() { constructor() {
super(); super();
super.CommandBuilder = new SlashCommandBuilder() this.CommandBuilder = new SlashCommandBuilder()
.setName("unmute") .setName("unmute")
.setDescription("(DEPRECATED) Unmute a member in the server with an optional reason") .setDescription("(DEPRECATED) Unmute a member in the server with an optional reason")
.setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers) .setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers)

View file

@ -9,7 +9,7 @@ export default class Warn extends Command {
constructor() { constructor() {
super(); super();
super.CommandBuilder = new SlashCommandBuilder() this.CommandBuilder = new SlashCommandBuilder()
.setName("warn") .setName("warn")
.setDescription("Warns a member in the server with an optional reason") .setDescription("Warns a member in the server with an optional reason")
.setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers) .setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers)

View file

@ -3,7 +3,9 @@ import NicknameChanged from "./GuildMemberUpdate/NicknameChanged";
import CacheHelper from "../../helpers/CacheHelper"; import CacheHelper from "../../helpers/CacheHelper";
export default async function GuildMemberUpdate(oldMember: GuildMember, newMember: GuildMember) { export default async function GuildMemberUpdate(oldMember: GuildMember, newMember: GuildMember) {
await CacheHelper.UpdateServerCache(newMember.guild); const updatedFromCache = await CacheHelper.UpdateServerCache(newMember.guild);
if (updatedFromCache) return;
if (oldMember.nickname !== newMember.nickname) { // Nickname change if (oldMember.nickname !== newMember.nickname) { // Nickname change
await NicknameChanged(oldMember, newMember); await NicknameChanged(oldMember, newMember);

View file

@ -2,10 +2,10 @@ import { Guild } from "discord.js";
import Server from "../database/entities/Server"; import Server from "../database/entities/Server";
export default class CacheHelper { export default class CacheHelper {
public static async UpdateServerCache(guild: Guild) { public static async UpdateServerCache(guild: Guild): Promise<boolean> {
const cacheInterval = process.env.CACHE_INTERVAL; const cacheInterval = process.env.CACHE_INTERVAL;
if (!cacheInterval) return; if (!cacheInterval) return false;
let server = await Server.FetchOneById(Server, guild.id); let server = await Server.FetchOneById(Server, guild.id);
@ -14,9 +14,15 @@ export default class CacheHelper {
await server.Save(Server, server); await server.Save(Server, server);
await CacheHelper.UpdateCache(guild); await CacheHelper.UpdateCache(guild);
} else if (server.LastCached.getTime() + Number(cacheInterval) < Date.now()) {
return true;
} else if (server.LastCached.getTime() + Number(cacheInterval) > Date.now()) {
await CacheHelper.UpdateCache(guild); await CacheHelper.UpdateCache(guild);
return true;
} }
return false;
} }
private static async UpdateCache(guild: Guild) { private static async UpdateCache(guild: Guild) {

4794
yarn.lock

File diff suppressed because it is too large Load diff