Skip to content
This repository was archived by the owner on Oct 21, 2021. It is now read-only.

Commit 8debe7a

Browse files
author
seen-idc
committed
updated more of reaction roles and implemented tag system
1 parent afe62a0 commit 8debe7a

18 files changed

+4156
-11
lines changed

.gitignore

+3-3
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ config.json
109109
config-dev.json
110110

111111
.yarn/*
112-
!.yarn/cache
113112
!.yarn/patches
114-
!.yarn/plugins
115113
!.yarn/releases
114+
!.yarn/plugins
116115
!.yarn/sdks
117-
!.yarn/versions
116+
!.yarn/versions
117+
.pnp.*

.vscode/extensions.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"arcanis.vscode-zipfs"
4+
]
5+
}

.vscode/settings.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
{
2-
"editor.tabSize": 2
3-
}
2+
"editor.tabSize": 2,
3+
"search.exclude": {
4+
"**/.yarn": true,
5+
"**/.pnp.*": true
6+
},
7+
"typescript.tsdk": ".yarn/sdks/typescript/lib",
8+
"typescript.enablePromptUseWorkspaceTsdk": true
9+
}

.yarn/releases/yarn-berry.cjs

+55
Large diffs are not rendered by default.

.yarn/sdks/integrations.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This file is automatically generated by PnPify.
2+
# Manual changes will be lost!
3+
4+
integrations:
5+
- vscode

.yarn/sdks/typescript/bin/tsc

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env node
2+
3+
const {existsSync} = require(`fs`);
4+
const {createRequire, createRequireFromPath} = require(`module`);
5+
const {resolve} = require(`path`);
6+
7+
const relPnpApiPath = "../../../../.pnp.js";
8+
9+
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
10+
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
11+
12+
if (existsSync(absPnpApiPath)) {
13+
if (!process.versions.pnp) {
14+
// Setup the environment to be able to require typescript/bin/tsc
15+
require(absPnpApiPath).setup();
16+
}
17+
}
18+
19+
// Defer to the real typescript/bin/tsc your application uses
20+
module.exports = absRequire(`typescript/bin/tsc`);

.yarn/sdks/typescript/bin/tsserver

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env node
2+
3+
const {existsSync} = require(`fs`);
4+
const {createRequire, createRequireFromPath} = require(`module`);
5+
const {resolve} = require(`path`);
6+
7+
const relPnpApiPath = "../../../../.pnp.js";
8+
9+
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
10+
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
11+
12+
if (existsSync(absPnpApiPath)) {
13+
if (!process.versions.pnp) {
14+
// Setup the environment to be able to require typescript/bin/tsserver
15+
require(absPnpApiPath).setup();
16+
}
17+
}
18+
19+
// Defer to the real typescript/bin/tsserver your application uses
20+
module.exports = absRequire(`typescript/bin/tsserver`);

.yarn/sdks/typescript/lib/tsc.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env node
2+
3+
const {existsSync} = require(`fs`);
4+
const {createRequire, createRequireFromPath} = require(`module`);
5+
const {resolve} = require(`path`);
6+
7+
const relPnpApiPath = "../../../../.pnp.js";
8+
9+
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
10+
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
11+
12+
if (existsSync(absPnpApiPath)) {
13+
if (!process.versions.pnp) {
14+
// Setup the environment to be able to require typescript/lib/tsc.js
15+
require(absPnpApiPath).setup();
16+
}
17+
}
18+
19+
// Defer to the real typescript/lib/tsc.js your application uses
20+
module.exports = absRequire(`typescript/lib/tsc.js`);

.yarn/sdks/typescript/lib/tsserver.js

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#!/usr/bin/env node
2+
3+
const {existsSync} = require(`fs`);
4+
const {createRequire, createRequireFromPath} = require(`module`);
5+
const {resolve} = require(`path`);
6+
7+
const relPnpApiPath = "../../../../.pnp.js";
8+
9+
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
10+
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
11+
12+
const moduleWrapper = tsserver => {
13+
const {isAbsolute} = require(`path`);
14+
const pnpApi = require(`pnpapi`);
15+
16+
const dependencyTreeRoots = new Set(pnpApi.getDependencyTreeRoots().map(locator => {
17+
return `${locator.name}@${locator.reference}`;
18+
}));
19+
20+
// VSCode sends the zip paths to TS using the "zip://" prefix, that TS
21+
// doesn't understand. This layer makes sure to remove the protocol
22+
// before forwarding it to TS, and to add it back on all returned paths.
23+
24+
function toEditorPath(str) {
25+
// We add the `zip:` prefix to both `.zip/` paths and virtual paths
26+
if (isAbsolute(str) && !str.match(/^\^zip:/) && (str.match(/\.zip\//) || str.match(/\$\$virtual\//))) {
27+
// We also take the opportunity to turn virtual paths into physical ones;
28+
// this makes is much easier to work with workspaces that list peer
29+
// dependencies, since otherwise Ctrl+Click would bring us to the virtual
30+
// file instances instead of the real ones.
31+
//
32+
// We only do this to modules owned by the the dependency tree roots.
33+
// This avoids breaking the resolution when jumping inside a vendor
34+
// with peer dep (otherwise jumping into react-dom would show resolution
35+
// errors on react).
36+
//
37+
const resolved = pnpApi.resolveVirtual(str);
38+
if (resolved) {
39+
const locator = pnpApi.findPackageLocator(resolved);
40+
if (locator && dependencyTreeRoots.has(`${locator.name}@${locator.reference}`)) {
41+
str = resolved;
42+
}
43+
}
44+
45+
str = str.replace(/\\/g, `/`)
46+
str = str.replace(/^\/?/, `/`);
47+
48+
// Absolute VSCode `Uri.fsPath`s need to start with a slash.
49+
// VSCode only adds it automatically for supported schemes,
50+
// so we have to do it manually for the `zip` scheme.
51+
// The path needs to start with a caret otherwise VSCode doesn't handle the protocol
52+
//
53+
// Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
54+
//
55+
if (str.match(/\.zip\//)) {
56+
str = `${isVSCode ? `^` : ``}zip:${str}`;
57+
}
58+
}
59+
60+
return str;
61+
}
62+
63+
function fromEditorPath(str) {
64+
return process.platform === `win32`
65+
? str.replace(/^\^?zip:\//, ``)
66+
: str.replace(/^\^?zip:/, ``);
67+
}
68+
69+
// And here is the point where we hijack the VSCode <-> TS communications
70+
// by adding ourselves in the middle. We locate everything that looks
71+
// like an absolute path of ours and normalize it.
72+
73+
const Session = tsserver.server.Session;
74+
const {onMessage: originalOnMessage, send: originalSend} = Session.prototype;
75+
let isVSCode = false;
76+
77+
return Object.assign(Session.prototype, {
78+
onMessage(/** @type {string} */ message) {
79+
const parsedMessage = JSON.parse(message)
80+
81+
if (
82+
parsedMessage != null &&
83+
typeof parsedMessage === `object` &&
84+
parsedMessage.arguments &&
85+
parsedMessage.arguments.hostInfo === `vscode`
86+
) {
87+
isVSCode = true;
88+
}
89+
90+
return originalOnMessage.call(this, JSON.stringify(parsedMessage, (key, value) => {
91+
return typeof value === `string` ? fromEditorPath(value) : value;
92+
}));
93+
},
94+
95+
send(/** @type {any} */ msg) {
96+
return originalSend.call(this, JSON.parse(JSON.stringify(msg, (key, value) => {
97+
return typeof value === `string` ? toEditorPath(value) : value;
98+
})));
99+
}
100+
});
101+
};
102+
103+
if (existsSync(absPnpApiPath)) {
104+
if (!process.versions.pnp) {
105+
// Setup the environment to be able to require typescript/lib/tsserver.js
106+
require(absPnpApiPath).setup();
107+
}
108+
}
109+
110+
// Defer to the real typescript/lib/tsserver.js your application uses
111+
module.exports = moduleWrapper(absRequire(`typescript/lib/tsserver.js`));
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env node
2+
3+
const {existsSync} = require(`fs`);
4+
const {createRequire, createRequireFromPath} = require(`module`);
5+
const {resolve} = require(`path`);
6+
7+
const relPnpApiPath = "../../../../.pnp.js";
8+
9+
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
10+
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
11+
12+
if (existsSync(absPnpApiPath)) {
13+
if (!process.versions.pnp) {
14+
// Setup the environment to be able to require typescript/lib/typescript.js
15+
require(absPnpApiPath).setup();
16+
}
17+
}
18+
19+
// Defer to the real typescript/lib/typescript.js your application uses
20+
module.exports = absRequire(`typescript/lib/typescript.js`);

.yarn/sdks/typescript/package.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "typescript",
3+
"version": "4.2.2-pnpify",
4+
"main": "./lib/typescript.js",
5+
"type": "commonjs"
6+
}

.yarnrc.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
yarnPath: ".yarn/releases/yarn-berry.cjs"

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"url": "https://github.com/seen-idc/polarisbot/issues"
1818
},
1919
"homepage": "https://github.com/seen-idc/polarisbot#readme",
20-
"devDependencies": {},
2120
"dependencies": {
2221
"@types/figlet": "^1.2.1",
2322
"@types/node": "^14.14.25",

src/commands/moderation/reaction-role.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ export async function run(client: Client, message: Message, args: Array<string>)
3838
if (!color?.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i)?.length) return message.channel.send(errorMessage('No color provided or invalid color'))
3939

4040

41-
message.channel.send('Provide Title')
41+
message.channel.send('Provide Title and description with `|` as the separator')
4242

4343
let titleMsg = await message.channel.awaitMessages(filter, {max: 1, time: 30000, errors: ['time'] })
4444
if (!titleMsg) return
4545

46-
let title = titleMsg.first()
47-
if (!title) return message.channel.send(errorMessage('No title provided'))
46+
let title = titleMsg.first()?.content.trim().split('|')
47+
if (!title?.length) return message.channel.send(errorMessage('Error'))
48+
if (title.length < 2) return message.channel.send(errorMessage('No title provided'))
4849

49-
50+
const actualTitle = title[0]
51+
const actualDesc = title[1]
5052
}

src/index.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Command, Commands, Config } from './types'
77
import db from 'quick.db'
88
import { create } from 'svg-captcha';
99
import { svg2png } from 'svg-png-converter';
10+
import { ReactionRoleMsgManager } from './rrManager';
1011

1112

1213
process.on('unhandledRejection', console.error)
@@ -20,7 +21,9 @@ console.log(process.env.NODE_ENV)
2021
// Parse configuration file
2122
const config = parseConfiguration()
2223

23-
const client = new Client()
24+
const client = new Client({
25+
partials: ['MESSAGE', 'CHANNEL', 'REACTION']
26+
})
2427
const botCache = new BotCache()
2528

2629
botCache.set('helpConfig', JSON.parse(readFileSync(`${__dirname}/../help.json`).toString()))
@@ -135,6 +138,19 @@ client.on('guildMemberAdd', async member => {
135138
})
136139

137140

141+
const rrMsg = new ReactionRoleMsgManager()
142+
143+
client.on('messageReactionAdd', async (reaction, user) => {
144+
if (reaction.message.partial) await reaction.message.fetch()
145+
if (reaction.partial) await reaction.fetch()
146+
if (user.bot) return
147+
if (!reaction.message.guild) return
148+
149+
if (rrMsg.exist(reaction.message.id)) {
150+
151+
}
152+
153+
})
138154

139155

140156
const commands: Commands = {}

0 commit comments

Comments
 (0)