Update to latest development (#23)

pull/38/head
Skyler 3 years ago committed by GitHub
commit 599501055f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,4 @@
if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs="
fi
use flake

@ -15,8 +15,12 @@ on:
jobs: jobs:
lint: lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-node@v3.6.0
with:
node-version: 19.x
- run: yarn install --immutable - run: yarn install --immutable
- name: Compile - name: Compile
run: yarn build run: yarn build

4
.gitignore vendored

@ -5,7 +5,7 @@ src/config/*
!src/config/*.d.ts !src/config/*.d.ts
!src/config/format.ts !src/config/format.ts
!src/config/default.json !src/config/default.ts
!src/config/emojis.json !src/config/emojis.json
src/config/main.ts src/config/main.ts
.vscode/ .vscode/
@ -19,3 +19,5 @@ src/utils/temp/*.jpg
ClicksMigratingProblems/oldData/ ClicksMigratingProblems/oldData/
ClicksMigratingProblems/oldData copy/ ClicksMigratingProblems/oldData copy/
.direnv/

@ -0,0 +1,43 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1676283394,
"narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1677852945,
"narHash": "sha256-liiVJjkBTuBTAkRW3hrI8MbPD2ImYzwUpa7kvteiKhM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

@ -0,0 +1,14 @@
{
description = "A basic flake with a shell";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
devShells.default = pkgs.mkShell {
packages = [ pkgs.yarn pkgs.nodejs-19_x pkgs.typescript pkgs.act ];
};
});
}

@ -2,7 +2,9 @@
"dependencies": { "dependencies": {
"@discordjs/rest": "^0.2.0-canary.0", "@discordjs/rest": "^0.2.0-canary.0",
"@hokify/agenda": "^6.2.12", "@hokify/agenda": "^6.2.12",
"@total-typescript/ts-reset": "^0.3.7",
"@tsconfig/node18-strictest-esm": "^1.0.0", "@tsconfig/node18-strictest-esm": "^1.0.0",
"@types/node": "^18.14.6",
"@ungap/structured-clone": "^1.0.1", "@ungap/structured-clone": "^1.0.1",
"agenda": "^4.3.0", "agenda": "^4.3.0",
"body-parser": "^1.20.0", "body-parser": "^1.20.0",
@ -18,7 +20,7 @@
"node-tesseract-ocr": "^2.2.1", "node-tesseract-ocr": "^2.2.1",
"structured-clone": "^0.2.2", "structured-clone": "^0.2.2",
"systeminformation": "^5.17.3" "systeminformation": "^5.17.3"
}, },
"resolutions": { "resolutions": {
"discord-api-types": "0.37.23" "discord-api-types": "0.37.23"
}, },

@ -874,6 +874,7 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
await i.deferUpdate(); await i.deferUpdate();
if(i.isButton()) { if(i.isButton()) {
await client.database.guilds.write(interaction.guild.id, {filters: config}); await client.database.guilds.write(interaction.guild.id, {filters: config});
await client.memory.forceUpdate(interaction.guild.id);
} else { } else {
switch(i.values[0]) { switch(i.values[0]) {
case "invites": { case "invites": {

@ -79,6 +79,7 @@ export const callback = async (interaction: CommandInteraction): Promise<void> =
await client.database.guilds.write(interaction.guild!.id, { "autoPublish": data }); await client.database.guilds.write(interaction.guild!.id, { "autoPublish": data });
config = await client.database.guilds.read(interaction.guild!.id); config = await client.database.guilds.read(interaction.guild!.id);
data = _.cloneDeep(config.autoPublish); data = _.cloneDeep(config.autoPublish);
await client.memory.forceUpdate(interaction.guild!.id);
break; break;
} }
} }

@ -93,6 +93,7 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
"logging.attachments.channel": channel "logging.attachments.channel": channel
}); });
data = await client.database.guilds.read(interaction.guild!.id); data = await client.database.guilds.read(interaction.guild!.id);
await client.memory.forceUpdate(interaction.guild!.id);
break; break;
} }
} }

@ -139,6 +139,7 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
await client.database.guilds.write(interaction.guild!.id, {"logging.logs": data}); await client.database.guilds.write(interaction.guild!.id, {"logging.logs": data});
config = await client.database.guilds.read(interaction.guild!.id); config = await client.database.guilds.read(interaction.guild!.id);
data = Object.assign({}, config.logging.logs); data = Object.assign({}, config.logging.logs);
await client.memory.forceUpdate(interaction.guild!.id)
break; break;
} }
case "remove": { case "remove": {

@ -81,6 +81,7 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
"logging.warnings.channel": channel "logging.warnings.channel": channel
}); });
data = await client.database.guilds.read(interaction.guild!.id); data = await client.database.guilds.read(interaction.guild!.id);
await client.memory.forceUpdate(interaction.guild!.id);
break; break;
} }
} }

@ -436,8 +436,9 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
break; break;
} }
case "save": { case "save": {
client.database.guilds.write(interaction.guild.id, {"roleMenu.options": currentObject}); await client.database.guilds.write(interaction.guild.id, {"roleMenu.options": currentObject});
modified = false; modified = false;
await client.memory.forceUpdate(interaction.guild.id);
break; break;
} }
} }

@ -378,9 +378,10 @@ const callback = async (interaction: CommandInteraction) => {
break; break;
} }
case "save": { case "save": {
client.database.guilds.write(interaction.guild.id, {stats: currentObject}); await client.database.guilds.write(interaction.guild.id, {stats: currentObject});
singleNotify("statsChannelDeleted", interaction.guild.id, true); singleNotify("statsChannelDeleted", interaction.guild.id, true);
modified = false; modified = false;
await client.memory.forceUpdate(interaction.guild.id);
break; break;
} }
} }

@ -135,6 +135,7 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
await i.deferUpdate(); await i.deferUpdate();
await client.database.guilds.write(interaction.guild.id, { tickets: ticketData }); await client.database.guilds.write(interaction.guild.id, { tickets: ticketData });
changesMade = false; changesMade = false;
await client.memory.forceUpdate(interaction.guild.id);
break; break;
} }
case "enabled": { case "enabled": {

@ -413,6 +413,7 @@ const callback = async (interaction: CommandInteraction) => {
case "save": { case "save": {
client.database.guilds.write(interaction.guild!.id, {tracks: tracks}); client.database.guilds.write(interaction.guild!.id, {tracks: tracks});
modified = false; modified = false;
await client.memory.forceUpdate(interaction.guild!.id);
break; break;
} }
} }

@ -88,6 +88,7 @@ const callback = async (interaction: CommandInteraction): Promise<unknown> => {
client.database.guilds.write(interaction.guild.id, {"verify": data} ) client.database.guilds.write(interaction.guild.id, {"verify": data} )
config = await client.database.guilds.read(interaction.guild.id); config = await client.database.guilds.read(interaction.guild.id);
data = Object.assign({}, config.verify); data = Object.assign({}, config.verify);
await client.memory.forceUpdate(interaction.guild.id);
break break
} }
case "switch": { case "switch": {

@ -223,6 +223,7 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
await client.database.guilds.write(interaction.guild!.id, {"welcome": data}); await client.database.guilds.write(interaction.guild!.id, {"welcome": data});
config = await client.database.guilds.read(interaction.guild!.id); config = await client.database.guilds.read(interaction.guild!.id);
data = Object.assign({}, config.welcome); data = Object.assign({}, config.welcome);
await client.memory.forceUpdate(interaction.guild!.id)
break; break;
} }
case "channelDM": { case "channelDM": {

@ -0,0 +1,133 @@
import type { GuildConfig } from "../utils/database.js";
export default {
id: "default",
version: 1,
singleEventNotifications: {
statsChannelDeleted: false
},
filters: {
images: {
NSFW: false,
size: false
},
malware: false,
wordFilter: {
enabled: false,
words: {
strict: [],
loose: []
},
allowed: {
users: [],
roles: [],
channels: []
}
},
invite: {
enabled: false,
allowed: {
users: [],
roles: [],
channels: []
}
},
pings: {
mass: 5,
everyone: true,
roles: true,
allowed: {
users: [],
roles: [],
channels: [],
rolesToMention: []
}
},
clean: {
channels: [],
allowed: {
users: [],
roles: []
}
}
},
welcome: {
enabled: false,
role: null,
ping: null,
channel: null,
message: null
},
stats: {},
logging: {
logs: {
enabled: true,
channel: null,
toLog: "3fffff"
},
staff: {
channel: null
},
attachments: {
channel: null,
saved: {}
}
},
verify: {
enabled: false,
role: null
},
tickets: {
enabled: false,
category: null,
types: "3f",
customTypes: null,
useCustom: false,
supportRole: null,
maxTickets: 5
},
moderation: {
mute: {
timeout: false,
role: null,
text: null,
link: null,
},
kick: {
text: null,
link: null,
},
ban: {
text: null,
link: null,
},
softban: {
text: null,
link: null,
},
warn: {
text: null,
link: null,
},
role: {
role: null,
text: null,
link: null,
},
nick: {
text: null,
link: null,
}
},
tracks: [],
roleMenu: {
enabled: false,
allowWebUI: false,
options: [],
},
tags: {},
autoPublish: {
enabled: false,
channels: []
}
} as GuildConfig;

@ -5,7 +5,7 @@ import { messageException } from "../utils/createTemporaryStorage.js";
import getEmojiByName from "../utils/getEmojiByName.js"; import getEmojiByName from "../utils/getEmojiByName.js";
import client from "../utils/client.js"; import client from "../utils/client.js";
import { callback as statsChannelUpdate } from "../reflex/statsChannelUpdate.js"; import { callback as statsChannelUpdate } from "../reflex/statsChannelUpdate.js";
import { Message, ThreadChannel } from "discord.js"; import { ChannelType, Message, ThreadChannel } from "discord.js";
export const event = "messageCreate"; export const event = "messageCreate";
@ -13,7 +13,11 @@ export async function callback(_client: NucleusClient, message: Message) {
if (!message.guild) return; if (!message.guild) return;
const config = await client.memory.readGuildInfo(message.guild.id); const config = await client.memory.readGuildInfo(message.guild.id);
if (config.autoPublish.enabled && config.autoPublish.channels.includes(message.channel.id)) { if (config.autoPublish.enabled
&& config.autoPublish.channels.includes(message.channel.id)
&& message.channel.type === ChannelType.GuildAnnouncement
&& message.reference === null
) {
await message.crosspost(); await message.crosspost();
} }

@ -1,3 +1,5 @@
import "@total-typescript/ts-reset";
import runServer from "./api/index.js"; import runServer from "./api/index.js";
import client from "./utils/client.js"; import client from "./utils/client.js";
import config from "./config/main.js"; import config from "./config/main.js";

@ -263,7 +263,7 @@ export class Transcript {
} }
} }
if(!data) return null; if(!data) return null;
doc = JSON.parse(Buffer.from(data).toString()); doc = JSON.parse(Buffer.from(data).toString()) as TranscriptSchema;
} }
if(!doc) return null; if(!doc) return null;
return doc; return doc;
@ -294,7 +294,7 @@ export class Transcript {
} }
} }
if(!data) return null; if(!data) return null;
doc = JSON.parse(Buffer.from(data).toString()); doc = JSON.parse(Buffer.from(data).toString()) as TranscriptSchema;
} }
if(!doc) return null; if(!doc) return null;
for(const message of doc.messages) { for(const message of doc.messages) {

Loading…
Cancel
Save