Compare commits
121 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
bf34b2ae43 | ||
|
cb5f23d9b5 | ||
|
cd2cbfa0ef | ||
|
232e340fab | ||
|
8027daa2b0 | ||
|
0f7b9f588e | ||
|
93482ac2a5 | ||
|
994c3b3c92 | ||
|
c696c186e8 | ||
|
30d5e2108f | ||
|
1eabd1b701 | ||
|
1cbf2b43e1 | ||
|
4c197d5d51 | ||
|
f89027f46a | ||
|
07a0ebb1d2 | ||
|
f09b44b0d5 | ||
|
b607eebcb7 | ||
|
0936ca2985 | ||
|
13bde79ec8 | ||
|
b592defaaf | ||
|
73354973a3 | ||
|
e12c0e546c | ||
|
088a8bd1b6 | ||
|
51adb26d01 | ||
|
cb980a1cad | ||
|
69b10c1f07 | ||
|
8e9ba7c7ee | ||
|
12e3c9234d | ||
|
1d8dcef394 | ||
|
4fe2845234 | ||
|
5e71ed286e | ||
|
5edbd2391d | ||
|
8472c3823e | ||
|
2103e52115 | ||
|
afbfb641e8 | ||
|
d7ac418e05 | ||
|
214c101740 | ||
|
5a0e501829 | ||
|
92113da7c0 | ||
|
96f30a5359 | ||
|
ceb1f15188 | ||
|
626eb3613e | ||
|
3020fcc9bb | ||
|
bc0de3926c | ||
|
9820b79dfe | ||
|
ab811470fc | ||
|
e4162e7bd5 | ||
|
7e8397a4da | ||
|
555cf64080 | ||
|
2039e10fd5 | ||
|
e8d90d2b45 | ||
|
55af40ee74 | ||
|
a1fabcdf0a | ||
|
eaeb60308e | ||
|
662c0227eb | ||
|
543fdf4943 | ||
|
1225383723 | ||
|
07a9adbce2 | ||
|
42d8211871 | ||
|
ab3e993274 | ||
|
386dfe363a | ||
|
a4191c9f6c | ||
|
f1349a2787 | ||
|
3680c26f72 | ||
|
683c92f904 | ||
|
3410ed024f | ||
|
dbad10984a | ||
|
55543d8640 | ||
|
263fbc377e | ||
|
c9c0ab5aca | ||
|
7b2bf08b8f | ||
|
43011825af | ||
|
4abcea61f8 | ||
|
cba810cab5 | ||
|
5938c7d67c | ||
|
99d8b8b75f | ||
|
503d49d295 | ||
|
137b79d95b | ||
|
3c02d6e1b4 | ||
|
a2a33ca62d | ||
|
d8cd557fb2 | ||
|
7568bbaed0 | ||
|
9023d45d9e | ||
|
bee70390a9 | ||
|
3e3d05fc26 | ||
|
6300198a54 | ||
|
458c7ed4c5 | ||
|
d888a0a291 | ||
|
a94787a9f3 | ||
|
368d2bcdbb | ||
|
bc46bfa467 | ||
|
dab48288a8 | ||
|
9aef97c771 | ||
|
9d62dec6b9 | ||
|
6bf6583e7d | ||
|
5219fb700f | ||
|
184c03b28e | ||
|
ec091a7959 | ||
|
89a6c575c9 | ||
|
60325c6aa5 | ||
|
c2a1c4cbf6 | ||
|
1d6b78f6c6 | ||
|
341151a718 | ||
|
f6fd7cf37a | ||
|
d53476a32a | ||
|
fc943b7778 | ||
|
3f2bcd2cab | ||
|
235000cf41 | ||
|
263884cbd8 | ||
|
bb83c0b672 | ||
|
2815509c00 | ||
|
53ff2532f4 | ||
|
64b38348d4 | ||
|
9c1b3a9afd | ||
|
caf77a3d7f | ||
|
7a27de8927 | ||
|
1bc0678422 | ||
|
cd53cf38fe | ||
|
f13f9e80a9 | ||
|
c062f9bdeb | ||
|
f2ef96a420 |
40
.github/workflows/build.yml
vendored
40
.github/workflows/build.yml
vendored
@ -42,37 +42,39 @@ jobs:
|
|||||||
|
|
||||||
- name: Clean up obsolete files
|
- name: Clean up obsolete files
|
||||||
run: |
|
run: |
|
||||||
rm -rf dist/*-unpacked Vencord.user.css vencordDesktopRenderer.css vencordDesktopRenderer.css.map
|
rm -rf dist/*-unpacked Vencord.user.css vencordDesktopRenderer.css vencordDesktopRenderer.css.map
|
||||||
|
|
||||||
- name: Get some values needed for the release
|
- name: Get some values needed for the release
|
||||||
id: release_values
|
id: release_values
|
||||||
run: |
|
run: |
|
||||||
echo "release_tag=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
|
echo "release_tag=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Upload DevBuild as release
|
- name: Upload DevBuild as release
|
||||||
|
if: github.repository == 'Vendicated/Vencord'
|
||||||
run: |
|
run: |
|
||||||
gh release upload devbuild --clobber dist/*
|
gh release upload devbuild --clobber dist/*
|
||||||
gh release edit devbuild --title "DevBuild $RELEASE_TAG"
|
gh release edit devbuild --title "DevBuild $RELEASE_TAG"
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
RELEASE_TAG: ${{ env.release_tag }}
|
RELEASE_TAG: ${{ env.release_tag }}
|
||||||
|
|
||||||
- name: Upload DevBuild to builds repo
|
- name: Upload DevBuild to builds repo
|
||||||
|
if: github.repository == 'Vendicated/Vencord'
|
||||||
run: |
|
run: |
|
||||||
git config --global user.name "$USERNAME"
|
git config --global user.name "$USERNAME"
|
||||||
git config --global user.email actions@github.com
|
git config --global user.email actions@github.com
|
||||||
|
|
||||||
git clone https://$USERNAME:$API_TOKEN@github.com/$GH_REPO.git upload
|
git clone https://$USERNAME:$API_TOKEN@github.com/$GH_REPO.git upload
|
||||||
cd upload
|
cd upload
|
||||||
|
|
||||||
GLOBIGNORE=.git:.gitignore:README.md:LICENSE
|
GLOBIGNORE=.git:.gitignore:README.md:LICENSE
|
||||||
rm -rf *
|
rm -rf *
|
||||||
cp -r ../dist/* .
|
cp -r ../dist/* .
|
||||||
|
|
||||||
git add -A
|
git add -A
|
||||||
git commit -m "Builds for https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA"
|
git commit -m "Builds for https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA"
|
||||||
git push --force https://$USERNAME:$API_TOKEN@github.com/$GH_REPO.git
|
git push --force https://$USERNAME:$API_TOKEN@github.com/$GH_REPO.git
|
||||||
env:
|
env:
|
||||||
API_TOKEN: ${{ secrets.BUILDS_TOKEN }}
|
API_TOKEN: ${{ secrets.BUILDS_TOKEN }}
|
||||||
GH_REPO: Vencord/builds
|
GH_REPO: Vencord/builds
|
||||||
USERNAME: GitHub-Actions
|
USERNAME: GitHub-Actions
|
||||||
|
22
.github/workflows/codeberg-mirror.yml
vendored
Normal file
22
.github/workflows/codeberg-mirror.yml
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
name: Sync to Codeberg
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
workflow_dispatch:
|
||||||
|
schedule:
|
||||||
|
- cron: "0 */6 * * *"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
codeberg:
|
||||||
|
if: github.repository == 'Vendicated/Vencord'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- uses: pixta-dev/repository-mirroring-action@674e65a7d483ca28dafaacba0d07351bdcc8bd75 # v1.1.1
|
||||||
|
with:
|
||||||
|
target_repo_url: "git@codeberg.org:Ven/cord.git"
|
||||||
|
ssh_private_key: ${{ secrets.CODEBERG_SSH_PRIVATE_KEY }}
|
47
.github/workflows/publish.yml
vendored
47
.github/workflows/publish.yml
vendored
@ -6,6 +6,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
Publish:
|
Publish:
|
||||||
|
if: github.repository == 'Vendicated/Vencord'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@ -13,11 +14,11 @@ jobs:
|
|||||||
|
|
||||||
- name: check that tag matches package.json version
|
- name: check that tag matches package.json version
|
||||||
run: |
|
run: |
|
||||||
pkg_version="v$(jq -r .version < package.json)"
|
pkg_version="v$(jq -r .version < package.json)"
|
||||||
if [[ "${{ github.ref_name }}" != "$pkg_version" ]]; then
|
if [[ "${{ github.ref_name }}" != "$pkg_version" ]]; then
|
||||||
echo "Tag ${{ github.ref_name }} does not match package.json version $pkg_version" >&2
|
echo "Tag ${{ github.ref_name }} does not match package.json version $pkg_version" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v2 # Install pnpm using packageManager key in package.json
|
- uses: pnpm/action-setup@v2 # Install pnpm using packageManager key in package.json
|
||||||
|
|
||||||
@ -35,26 +36,26 @@ jobs:
|
|||||||
|
|
||||||
- name: Publish extension
|
- name: Publish extension
|
||||||
run: |
|
run: |
|
||||||
# Do not fail so that even if chrome fails, firefox gets a shot. But also store exit code to fail workflow later
|
# Do not fail so that even if chrome fails, firefox gets a shot. But also store exit code to fail workflow later
|
||||||
EXIT_CODE=0
|
EXIT_CODE=0
|
||||||
|
|
||||||
# Chrome
|
# Chrome
|
||||||
cd dist/chromium-unpacked
|
cd dist/chromium-unpacked
|
||||||
pnpx chrome-webstore-upload-cli@2.1.0 upload --auto-publish || EXIT_CODE=$?
|
pnpx chrome-webstore-upload-cli@2.1.0 upload --auto-publish || EXIT_CODE=$?
|
||||||
|
|
||||||
# Firefox
|
# Firefox
|
||||||
cd ../firefox-unpacked
|
cd ../firefox-unpacked
|
||||||
npm i -g web-ext@7.4.0 web-ext-submit@7.4.0
|
npm i -g web-ext@7.4.0 web-ext-submit@7.4.0
|
||||||
web-ext-submit || EXIT_CODE=$?
|
web-ext-submit || EXIT_CODE=$?
|
||||||
|
|
||||||
exit $EXIT_CODE
|
exit $EXIT_CODE
|
||||||
env:
|
env:
|
||||||
# Chrome
|
# Chrome
|
||||||
EXTENSION_ID: ${{ secrets.CHROME_EXTENSION_ID }}
|
EXTENSION_ID: ${{ secrets.CHROME_EXTENSION_ID }}
|
||||||
CLIENT_ID: ${{ secrets.CHROME_CLIENT_ID }}
|
CLIENT_ID: ${{ secrets.CHROME_CLIENT_ID }}
|
||||||
CLIENT_SECRET: ${{ secrets.CHROME_CLIENT_SECRET }}
|
CLIENT_SECRET: ${{ secrets.CHROME_CLIENT_SECRET }}
|
||||||
REFRESH_TOKEN: ${{ secrets.CHROME_REFRESH_TOKEN }}
|
REFRESH_TOKEN: ${{ secrets.CHROME_REFRESH_TOKEN }}
|
||||||
|
|
||||||
# Firefox
|
# Firefox
|
||||||
WEB_EXT_API_KEY: ${{ secrets.WEBEXT_USER }}
|
WEB_EXT_API_KEY: ${{ secrets.WEBEXT_USER }}
|
||||||
WEB_EXT_API_SECRET: ${{ secrets.WEBEXT_SECRET }}
|
WEB_EXT_API_SECRET: ${{ secrets.WEBEXT_SECRET }}
|
||||||
|
37
.github/workflows/reportBrokenPlugins.yml
vendored
37
.github/workflows/reportBrokenPlugins.yml
vendored
@ -2,11 +2,12 @@ name: Test Patches
|
|||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
schedule:
|
schedule:
|
||||||
# Every day at midnight
|
# Every day at midnight
|
||||||
- cron: 0 0 * * *
|
- cron: 0 0 * * *
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
TestPlugins:
|
TestPlugins:
|
||||||
|
if: github.repository == 'Vendicated/Vencord'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@ -22,10 +23,10 @@ jobs:
|
|||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
pnpm install --frozen-lockfile
|
pnpm install --frozen-lockfile
|
||||||
pnpm add puppeteer
|
pnpm add puppeteer
|
||||||
|
|
||||||
sudo apt-get install -y chromium-browser
|
sudo apt-get install -y chromium-browser
|
||||||
|
|
||||||
- name: Build web
|
- name: Build web
|
||||||
run: pnpm buildWeb --standalone
|
run: pnpm buildWeb --standalone
|
||||||
@ -33,25 +34,25 @@ jobs:
|
|||||||
- name: Create Report
|
- name: Create Report
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
run: |
|
run: |
|
||||||
export PATH="$PWD/node_modules/.bin:$PATH"
|
export PATH="$PWD/node_modules/.bin:$PATH"
|
||||||
export CHROMIUM_BIN=$(which chromium-browser)
|
export CHROMIUM_BIN=$(which chromium-browser)
|
||||||
|
|
||||||
esbuild scripts/generateReport.ts > dist/report.mjs
|
esbuild scripts/generateReport.ts > dist/report.mjs
|
||||||
node dist/report.mjs >> $GITHUB_STEP_SUMMARY
|
node dist/report.mjs >> $GITHUB_STEP_SUMMARY
|
||||||
env:
|
env:
|
||||||
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
|
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
|
||||||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
||||||
|
|
||||||
- name: Create Report (Canary)
|
- name: Create Report (Canary)
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
if: success() || failure() # even run if previous one failed
|
if: success() || failure() # even run if previous one failed
|
||||||
run: |
|
run: |
|
||||||
export PATH="$PWD/node_modules/.bin:$PATH"
|
export PATH="$PWD/node_modules/.bin:$PATH"
|
||||||
export CHROMIUM_BIN=$(which chromium-browser)
|
export CHROMIUM_BIN=$(which chromium-browser)
|
||||||
export USE_CANARY=true
|
export USE_CANARY=true
|
||||||
|
|
||||||
esbuild scripts/generateReport.ts > dist/report.mjs
|
esbuild scripts/generateReport.ts > dist/report.mjs
|
||||||
node dist/report.mjs >> $GITHUB_STEP_SUMMARY
|
node dist/report.mjs >> $GITHUB_STEP_SUMMARY
|
||||||
env:
|
env:
|
||||||
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
|
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
|
||||||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
||||||
|
9
.vscode/settings.json
vendored
9
.vscode/settings.json
vendored
@ -12,5 +12,12 @@
|
|||||||
"javascript.format.semicolons": "insert",
|
"javascript.format.semicolons": "insert",
|
||||||
"typescript.format.semicolons": "insert",
|
"typescript.format.semicolons": "insert",
|
||||||
"typescript.preferences.quoteStyle": "double",
|
"typescript.preferences.quoteStyle": "double",
|
||||||
"javascript.preferences.quoteStyle": "double"
|
"javascript.preferences.quoteStyle": "double",
|
||||||
|
|
||||||
|
"gitlens.remotes": [
|
||||||
|
{
|
||||||
|
"domain": "codeberg.org",
|
||||||
|
"type": "Gitea"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
25
.vscode/tasks.json
vendored
Normal file
25
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||||
|
// for the documentation about the tasks.json format
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "Build",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "pnpm build",
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Watch",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "pnpm watch",
|
||||||
|
"problemMatcher": [],
|
||||||
|
"group": {
|
||||||
|
"kind": "build"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
19
README.md
19
README.md
@ -1,7 +1,8 @@
|
|||||||
# Vencord
|
# Vencord
|
||||||
|
|
||||||
The cutest Discord client mod
|
[![Codeberg Mirror](https://img.shields.io/static/v1?style=for-the-badge&label=Codeberg%20Mirror&message=codeberg.org/Ven/cord&color=2185D0&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0QA/wD/AP+gvaeTAAAKbUlEQVR4nNVae3AV5RX/nW/3Pva+b24e5HHzIICQKGoiYiW8NFBFgohaa6ctglpbFSujSGurzUinohWsOij/gGX6R2fqOK0d1FYTEZXaTrWCBbEikJCEyCvkeXNvkrunf+zdkJDkPnex/c3cmd29+53v/M6e73znnF2Cydj4Tntldzi6qrN/qKqzf2jy6b7BnL4B1dI7oMp9AyoRAIdVsNMqhlxWMZjtspzyK/Jhr036OMsm//bh2vzPzNSPzBD6xFutd7R0Dq758ky4orkjYuc05RCAkixbeEq2/UCJ1/LczxcX/c5IPfU5DMHmxpbCpu7o1k/b+xc1n43YjJI7EqV+W2RmvuPt0oDjB2vn5bQbITNjAzzdeKK8qTO0bU9T77zucNQUjzofHrvENWWu3aUBZfW6+ZOOZiIrbYXrmUXo9daX3v6i667O/iGRiRLpwqtIvKDc+0efJ3hb/UIaSkdGWgZ4sqGt9r2m3lc/P9HvSWe80ZiRp3TPL/UsX1+bvyvVsSkb4NE3WjbuPNj5SM8Fcvdk4bAKrqvwv7DxhuCPUxmXNIn6XSy3nWr6R8OhrqrU1btwqJ3m/bgwu/SqZJdEUgbYsuuka09b9/4Pm3tLMlPvwuAbpe6m+RcplfdcURBKdG9CA2zZddLV2Nx1+JO2vlxj1LswqCpynlxc6SxLZIS40bueWfy9vXvv/xt5APhXa1/u7v+EPqvfxXK8++IaoO2Vpn9+cLS33FjVLhw+bOotOX7q6N/i3TOhAX7y+rHN/+sBLxm8fah71k93tjw/0f/jGuDJxtZrdh7setA8tS4sdn7eef+v3mmfP95/Ywxw6x9Yev9I35/6Iubv83WVfl5a6Uu3VkoavZEo7TnS/Vo98xi+Yy6UKC3bDp7sd5ut1OWFDjyzNMib6oq5Oug0ezp8dqLfG3r92Nbzr48ywNONJ8obDnV/z2xlAk4ZW1aUqhaJIAvCb5YVqwFn3GBtCBoO9dz5TOPxUbnMKAM0dYa2d5lc2AgCNi8r5klui3aBgWynjE11QZbI3FV3NjQkjnYNbB+lj36wubGlcE9T71xTNQDw0Px8nlvmHl73GmfCrKCL19Tkmh4P9jT1LHz2vVP5+vmwAZq71a1m1/PXTPXwD68eS5KIEVUZd1yZwwumeEw1Qld/lJrPhF7Sz4cNsO+rUK2ZExd6rfj10iCPZ2GJCCoAZuCJxQUc9FvNVAX72kPX6ccC0Hp4zR0Ru1kT2mTCSzeXqn5l/EAniMAqoDLDYZWwqa5EVSzmhaKmsxHbLxvbbgdiBmjpHFxj2mwANlxXxBdPUib8nwgQgqAyEFUZxT4L1i/MN3UpHDsTWQvEDHDoTLjCrIluuyzAt8zMSkhGFhp5hrYUFk3z8IqZftOMcKRj4GIAEM80tFccM8n9Z+Qq+MXigqRIWCQCMzQvYIbKwH1X53FFnjkr88iZsLKpoXWa6BiIrjbDzF67hK23lKp2Obm1LAstPEZVjTwDkAio/2ZQ9dolw/VjAB0DfKfoCg9WGy2cADy1NMhBX2rR3CIRGICq8rAhAg4Jj9UWsDBhg+4MR6vF2VC0zGjB99fk8eJp3pQdyyrRMHF9KURVxswCB6+alWO4o3b2RyeLU32D2UYKnVPm5gfm5qWlrF0Wo4hzbCmoDNw0089XlboNNcLpvsFc0RtRDXuNle+x4Lkbi9PO6WWJIBFGEY+qjGjswtq5eVzosRilLnoiUavoH1INiTCyIDy/vETNcmRW1dl0L4gRVxmx3YFhlwnrry1QrZIxASE0yJIIDaiGSHt8UQFXF2Ve1zusYgzxkXGhyGvFvePUE+mgfyAqhGqAqKWVPv5udbYhSjmtkpYWq6OJqzFjqCpjTpmbl1Rk3klSGRBWmTISNC3Hjo1LgoYFJ0GA1aIVR+cTVxlQoS2Pb18a4PLszMKXzSJYuCySmq4Al03CiytKVYfBhYvLKk1IXE+XLRLhwZp81WlNf26HTFHhd0jhdAYTgKduCPLkgPHfQjitYkLiAIEZBDBlu2R6aF7euCV2Mgg45bDw2qWOdAavnp3D109PPdlJBvpTnYg4kVY3MDMuylVw62WJi63x4LHLZ0TAIR9OdWBVodPUclUQwWmT4hLXfgCIUDfDi6oiR8rzBJzyl8LnkD9KZVCOU8aLN5eoshnJ+Qh4bFJC4gztmEjgrtk5anaKnWWfXfpIuBTLjmSpSILw/E0laq7LuGxsIngVCYmIa96hLRG3TaZ1C/KTfjAEQLFIO8TPFk7aH/RZI8kMWrdgEs8udqXLKSUoMkEW4ETEQTRsoHyPlVZfmVw+Uuy3hR9bVHBQAMD0XPu/Ew24dqqH777K/La1DiKCxyYlRRzQymgG4+oyDxZOTdxZnp5r3wvEWmJ5btuL8W4uzbJh87LitLebdOFVpKSJx4IlwIzbL81CcYLO8iSX/IImGQCYae6Wg/2tXQNjNnW7LPDKyilqZd7ETU2zEBlifNTSS4i9PNFIx44x4jh2nZlBsUr0dN8QP/6XVhEaHJvnlfhtkXd/NF0BUextKRFXFznfGk+JDdcX8tdBHtDa6YpFsB4I9ac88omf8wbEgqa2XAIOme6bM35foqrQ+QZIKwGG80ifVbrXZZNGDfhOVYBvviS9JMMoaP3AEcQpPnHdOxiMGXkKbrx4dGfZY5c4T8H9+vmwAeqXFLXOKXW9r59fWuDA44sKv1byAOBzyCkTH+kdS2f4MLPgXJI0p9T17vrFxcf181GVxEUB+0qfIqt+RcKWFSWGNR4ygd4RTpW4HiCJgFWzstmnSPA7ZLU827pypPwxDB/687GXl1X6Vs6bbGz/LRN80hZCT+yLFZ0cgHED4egACeiXm89GsP9EePuzy4rvGil7jAGYmQDsBjDHUBYZ4GhHBMfORigd4rpnyIS9u6d4rqgnGrUtjCmmSYuOqwB0GcwjbWh9xviurpNnxnDA1IspMPe6bOL755MHJvhKjIgOA7jbJD4pw22Thj+kSIW47h2KRaydVezeP57sCdspRPQqgGeNJJIuBAE+ReJUiOv32mXaXjPZs21C2QnmXgdghyEsMoRfkVMiDgCywF/by9z3xJMb1wCxeHAPgDczZpAh/Iq+HSYmDjCsstgThmf5t4ii8eQm7CgS0SCA5QBezoRApnBaBSyCEhIHCLJEb4ZUd+2SqZSwzE+qpUpEQ9CC4qb01M8cRIQsh8zxiKsMtsn08nvlnrpkyAPj5AGJwMw3AtgGwJ/q2ExxvHsQB74KxfKBMblAyGmTHq4pc4/5GjQeUm6qE9FrAK4E8H6ie41GlkN/jTk6F5Ak2ueUpNmpkgfSMAAAENERAAsB3AHgZDoy0oFdFnBYpXPEBfU4beLRD6Z4qmumug+kIzPjaoeZfQDWAHgAQFam8hLh4MkwWjsHemyS2OF08IYrCjynzZ4zKTCzi5nXMvOnzBw16bevIxR95JOj7DNKb1PqXWa+HMDtAGoBXII0lxq0N2OfAmgA8Hsi2muMhudgesHPzNkA5gKoADADwFRoS8UHQO+x9wLoBNAB4AsAnwM4AOADIjLVxf8L9kdXUOE0IskAAAAASUVORK5CYII=)](https://codeberg.org/Ven/cord)
|
||||||
|
|
||||||
|
The cutest Discord client mod
|
||||||
|
|
||||||
![](https://user-images.githubusercontent.com/45497981/235015332-0453d3eb-1da6-4601-963e-ef5e454123a1.png)
|
![](https://user-images.githubusercontent.com/45497981/235015332-0453d3eb-1da6-4601-963e-ef5e454123a1.png)
|
||||||
*A screenshot of Vencord featuring the [ClearVision-v6 theme](https://github.com/ClearVision/ClearVision-v6) (Vencord does not come with it pre-installed, it is only an example)*
|
*A screenshot of Vencord featuring the [ClearVision-v6 theme](https://github.com/ClearVision/ClearVision-v6) (Vencord does not come with it pre-installed, it is only an example)*
|
||||||
@ -10,7 +11,7 @@ The cutest Discord client mod
|
|||||||
|
|
||||||
- Super easy to install (Download Installer, open, click install button, done)
|
- Super easy to install (Download Installer, open, click install button, done)
|
||||||
- 100+ plugins built in: [See a list](https://vencord.dev/plugins)
|
- 100+ plugins built in: [See a list](https://vencord.dev/plugins)
|
||||||
- Some highlights: SpotifyControls, MessageLogger, Experiments, GameActivityToggle, Translate, NoTrack, QuickReply, Free Emotes/Stickers, CustomCommands, ShowHiddenChannels, PronounDB
|
- Some highlights: SpotifyControls, MessageLogger, Experiments, GameActivityToggle, Translate, NoTrack, QuickReply, Free Emotes/Stickers, PermissionsViewer, CustomCommands, ShowHiddenChannels, PronounDB
|
||||||
- Fairly lightweight despite the many inbuilt plugins
|
- Fairly lightweight despite the many inbuilt plugins
|
||||||
- Excellent Browser Support: Run Vencord in your Browser via extension or UserScript
|
- Excellent Browser Support: Run Vencord in your Browser via extension or UserScript
|
||||||
- Works on any Discord branch: Stable, Canary or PTB all work (though for the best experience I recommend stable!)
|
- Works on any Discord branch: Stable, Canary or PTB all work (though for the best experience I recommend stable!)
|
||||||
@ -32,15 +33,23 @@ Click the below button to install Vencord to the Discord Desktop app
|
|||||||
|
|
||||||
Or use the [UserScript](https://raw.githubusercontent.com/Vencord/builds/main/Vencord.user.js) - Please note that the CSS Editor, Themes loaded from remote sources and co. will not work in the UserScript. Use the extension if you need any of those
|
Or use the [UserScript](https://raw.githubusercontent.com/Vencord/builds/main/Vencord.user.js) - Please note that the CSS Editor, Themes loaded from remote sources and co. will not work in the UserScript. Use the extension if you need any of those
|
||||||
|
|
||||||
## Installing our Desktop App
|
<details>
|
||||||
|
<summary>Alternative Downloads</summary>
|
||||||
|
|
||||||
As an alternative to the Discord Desktop app, Vencord also has its own standalone Desktop app that is snappier and lighter than Discord's official Desktop app. It is currently in beta and we have yet to implement some features like screensharing, but you can try the beta nonetheless
|
## Vencord Desktop
|
||||||
|
|
||||||
|
> **Warning**
|
||||||
|
> This is an alternative app. It currently doesn't support keybinds and possibly some more features. If you just want to install to the normal Discord Desktop app, scroll up
|
||||||
|
|
||||||
|
As an alternative to the Discord Desktop app, Vencord also has its own standalone Desktop app that is snappier and lighter than Discord's official Desktop app
|
||||||
|
|
||||||
[![Download Vencord Desktop](https://img.shields.io/github/v/release/Vencord/Desktop?label=Download%20Vencord%20Desktop&style=for-the-badge)](https://github.com/Vencord/Desktop#vencord-desktop)
|
[![Download Vencord Desktop](https://img.shields.io/github/v/release/Vencord/Desktop?label=Download%20Vencord%20Desktop&style=for-the-badge)](https://github.com/Vencord/Desktop#vencord-desktop)
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
## Join our Support/Community Server
|
## Join our Support/Community Server
|
||||||
|
|
||||||
[![Vencord Discord Server](https://invidget.switchblade.xyz/D9uwnFnqmd?theme=dark)](https://discord.gg/D9uwnFnqmd)
|
https://discord.gg/D9uwnFnqmd
|
||||||
|
|
||||||
## Disclaimer
|
## Disclaimer
|
||||||
|
|
||||||
|
@ -16,20 +16,6 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function fetchOptions(url) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const opt = {
|
|
||||||
method: "OPTIONS",
|
|
||||||
url: url,
|
|
||||||
};
|
|
||||||
opt.onload = resp => resolve(resp.responseHeaders);
|
|
||||||
opt.ontimeout = () => reject("fetch timeout");
|
|
||||||
opt.onerror = () => reject("fetch error");
|
|
||||||
opt.onabort = () => reject("fetch abort");
|
|
||||||
GM_xmlhttpRequest(opt);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseHeaders(headers) {
|
function parseHeaders(headers) {
|
||||||
if (!headers)
|
if (!headers)
|
||||||
return {};
|
return {};
|
||||||
@ -52,21 +38,6 @@ function parseHeaders(headers) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns true if CORS permits request
|
|
||||||
async function checkCors(url, method) {
|
|
||||||
const headers = parseHeaders(await fetchOptions(url));
|
|
||||||
|
|
||||||
const origin = headers["access-control-allow-origin"];
|
|
||||||
if (origin !== "*" && origin !== window.location.origin) return false;
|
|
||||||
|
|
||||||
const methods = headers["access-control-allow-methods"]?.toLowerCase()
|
|
||||||
.split(",")
|
|
||||||
.map(s => s.trim());
|
|
||||||
if (methods && !methods.includes(method.toLowerCase())) return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function blobTo(to, blob) {
|
function blobTo(to, blob) {
|
||||||
if (to === "arrayBuffer" && blob.arrayBuffer) return blob.arrayBuffer();
|
if (to === "arrayBuffer" && blob.arrayBuffer) return blob.arrayBuffer();
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -80,31 +51,25 @@ function blobTo(to, blob) {
|
|||||||
|
|
||||||
function GM_fetch(url, opt) {
|
function GM_fetch(url, opt) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
checkCors(url, opt?.method || "GET")
|
// https://www.tampermonkey.net/documentation.php?ext=dhdg#GM_xmlhttpRequest
|
||||||
.then(can => {
|
const options = opt || {};
|
||||||
if (can) {
|
options.url = url;
|
||||||
// https://www.tampermonkey.net/documentation.php?ext=dhdg#GM_xmlhttpRequest
|
options.data = options.body;
|
||||||
const options = opt || {};
|
options.responseType = "blob";
|
||||||
options.url = url;
|
options.onload = resp => {
|
||||||
options.data = options.body;
|
var blob = resp.response;
|
||||||
options.responseType = "blob";
|
resp.blob = () => Promise.resolve(blob);
|
||||||
options.onload = resp => {
|
resp.arrayBuffer = () => blobTo("arrayBuffer", blob);
|
||||||
var blob = resp.response;
|
resp.text = () => blobTo("text", blob);
|
||||||
resp.blob = () => Promise.resolve(blob);
|
resp.json = async () => JSON.parse(await blobTo("text", blob));
|
||||||
resp.arrayBuffer = () => blobTo("arrayBuffer", blob);
|
resp.headers = new Headers(parseHeaders(resp.responseHeaders));
|
||||||
resp.text = () => blobTo("text", blob);
|
resp.ok = resp.status >= 200 && resp.status < 300;
|
||||||
resp.json = async () => JSON.parse(await blobTo("text", blob));
|
resolve(resp);
|
||||||
resp.headers = new Headers(parseHeaders(resp.responseHeaders));
|
};
|
||||||
resolve(resp);
|
options.ontimeout = () => reject("fetch timeout");
|
||||||
};
|
options.onerror = () => reject("fetch error");
|
||||||
options.ontimeout = () => reject("fetch timeout");
|
options.onabort = () => reject("fetch abort");
|
||||||
options.onerror = () => reject("fetch error");
|
GM_xmlhttpRequest(options);
|
||||||
options.onabort = () => reject("fetch abort");
|
|
||||||
GM_xmlhttpRequest(options);
|
|
||||||
} else {
|
|
||||||
reject("CORS issue");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
export const fetch = GM_fetch;
|
export const fetch = GM_fetch;
|
||||||
|
@ -41,12 +41,5 @@
|
|||||||
"path": "modifyResponseHeaders.json"
|
"path": "modifyResponseHeaders.json"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
|
||||||
|
|
||||||
"browser_specific_settings": {
|
|
||||||
"gecko": {
|
|
||||||
"id": "vencord-firefox@vendicated.dev",
|
|
||||||
"strict_min_version": "109.0"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "vencord",
|
"name": "vencord",
|
||||||
"private": "true",
|
"private": "true",
|
||||||
"version": "1.2.2",
|
"version": "1.3.3",
|
||||||
"description": "The cutest Discord client mod",
|
"description": "The cutest Discord client mod",
|
||||||
"homepage": "https://github.com/Vendicated/Vencord#readme",
|
"homepage": "https://github.com/Vendicated/Vencord#readme",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
@ -24,7 +24,7 @@
|
|||||||
"lint": "eslint . --ext .js,.jsx,.ts,.tsx --ignore-pattern src/userplugins",
|
"lint": "eslint . --ext .js,.jsx,.ts,.tsx --ignore-pattern src/userplugins",
|
||||||
"lint-styles": "stylelint \"src/**/*.css\" --ignore-pattern src/userplugins",
|
"lint-styles": "stylelint \"src/**/*.css\" --ignore-pattern src/userplugins",
|
||||||
"lint:fix": "pnpm lint --fix",
|
"lint:fix": "pnpm lint --fix",
|
||||||
"test": "pnpm build && pnpm lint && pnpm lint-styles && pnpm testTsc",
|
"test": "pnpm build && pnpm lint && pnpm lint-styles && pnpm testTsc && pnpm generatePluginJson",
|
||||||
"testWeb": "pnpm lint && pnpm buildWeb && pnpm testTsc",
|
"testWeb": "pnpm lint && pnpm buildWeb && pnpm testTsc",
|
||||||
"testTsc": "tsc --noEmit",
|
"testTsc": "tsc --noEmit",
|
||||||
"uninject": "node scripts/runInstaller.mjs",
|
"uninject": "node scripts/runInstaller.mjs",
|
||||||
|
@ -19,11 +19,13 @@
|
|||||||
|
|
||||||
import esbuild from "esbuild";
|
import esbuild from "esbuild";
|
||||||
|
|
||||||
import { commonOpts, globPlugins, isStandalone, watch } from "./common.mjs";
|
import { commonOpts, globPlugins, isStandalone, VERSION, watch } from "./common.mjs";
|
||||||
|
|
||||||
const defines = {
|
const defines = {
|
||||||
IS_STANDALONE: isStandalone,
|
IS_STANDALONE: isStandalone,
|
||||||
IS_DEV: JSON.stringify(watch)
|
IS_DEV: JSON.stringify(watch),
|
||||||
|
VERSION: JSON.stringify(VERSION),
|
||||||
|
BUILD_TIMESTAMP: Date.now(),
|
||||||
};
|
};
|
||||||
if (defines.IS_STANDALONE === "false")
|
if (defines.IS_STANDALONE === "false")
|
||||||
// If this is a local build (not standalone), optimise
|
// If this is a local build (not standalone), optimise
|
||||||
|
@ -24,9 +24,7 @@ import { readFileSync } from "fs";
|
|||||||
import { appendFile, mkdir, readFile, rm, writeFile } from "fs/promises";
|
import { appendFile, mkdir, readFile, rm, writeFile } from "fs/promises";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
|
|
||||||
// wtf is this assert syntax
|
import { commonOpts, globPlugins, VERSION, watch } from "./common.mjs";
|
||||||
import PackageJSON from "../../package.json" assert { type: "json" };
|
|
||||||
import { commonOpts, globPlugins, watch } from "./common.mjs";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {esbuild.BuildOptions}
|
* @type {esbuild.BuildOptions}
|
||||||
@ -47,7 +45,9 @@ const commonOptions = {
|
|||||||
IS_STANDALONE: "true",
|
IS_STANDALONE: "true",
|
||||||
IS_DEV: JSON.stringify(watch),
|
IS_DEV: JSON.stringify(watch),
|
||||||
IS_DISCORD_DESKTOP: "false",
|
IS_DISCORD_DESKTOP: "false",
|
||||||
IS_VENCORD_DESKTOP: "false"
|
IS_VENCORD_DESKTOP: "false",
|
||||||
|
VERSION: JSON.stringify(VERSION),
|
||||||
|
BUILD_TIMESTAMP: Date.now(),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ await Promise.all(
|
|||||||
},
|
},
|
||||||
outfile: "dist/Vencord.user.js",
|
outfile: "dist/Vencord.user.js",
|
||||||
banner: {
|
banner: {
|
||||||
js: readFileSync("browser/userscript.meta.js", "utf-8").replace("%version%", `${PackageJSON.version}.${new Date().getTime()}`)
|
js: readFileSync("browser/userscript.meta.js", "utf-8").replace("%version%", `${VERSION}.${new Date().getTime()}`)
|
||||||
},
|
},
|
||||||
footer: {
|
footer: {
|
||||||
// UserScripts get wrapped in an iife, so define Vencord prop on window that returns our local
|
// UserScripts get wrapped in an iife, so define Vencord prop on window that returns our local
|
||||||
@ -88,7 +88,7 @@ async function buildPluginZip(target, files, shouldZip) {
|
|||||||
let content = await readFile(join("browser", f));
|
let content = await readFile(join("browser", f));
|
||||||
if (f.startsWith("manifest")) {
|
if (f.startsWith("manifest")) {
|
||||||
const json = JSON.parse(content.toString("utf-8"));
|
const json = JSON.parse(content.toString("utf-8"));
|
||||||
json.version = PackageJSON.version;
|
json.version = VERSION;
|
||||||
content = new TextEncoder().encode(JSON.stringify(json));
|
content = new TextEncoder().encode(JSON.stringify(json));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,12 +16,20 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import "../suppressExperimentalWarnings.js";
|
||||||
|
import "../checkNodeVersion.js";
|
||||||
|
|
||||||
import { exec, execSync } from "child_process";
|
import { exec, execSync } from "child_process";
|
||||||
import { existsSync, readFileSync } from "fs";
|
import { existsSync, readFileSync } from "fs";
|
||||||
import { readdir, readFile } from "fs/promises";
|
import { readdir, readFile } from "fs/promises";
|
||||||
import { join, relative } from "path";
|
import { join, relative } from "path";
|
||||||
import { promisify } from "util";
|
import { promisify } from "util";
|
||||||
|
|
||||||
|
// wtf is this assert syntax
|
||||||
|
import PackageJSON from "../../package.json" assert { type: "json" };
|
||||||
|
|
||||||
|
export const VERSION = PackageJSON.version;
|
||||||
|
export const BUILD_TIMESTAMP = Date.now();
|
||||||
export const watch = process.argv.includes("--watch");
|
export const watch = process.argv.includes("--watch");
|
||||||
export const isStandalone = JSON.stringify(process.argv.includes("--standalone"));
|
export const isStandalone = JSON.stringify(process.argv.includes("--standalone"));
|
||||||
export const gitHash = execSync("git rev-parse --short HEAD", { encoding: "utf-8" }).trim();
|
export const gitHash = execSync("git rev-parse --short HEAD", { encoding: "utf-8" }).trim();
|
||||||
@ -62,7 +70,7 @@ export const globPlugins = kind => ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
build.onLoad({ filter, namespace: "import-plugins" }, async () => {
|
build.onLoad({ filter, namespace: "import-plugins" }, async () => {
|
||||||
const pluginDirs = ["plugins", "userplugins"];
|
const pluginDirs = ["plugins/_api", "plugins/_core", "plugins", "userplugins"];
|
||||||
let code = "";
|
let code = "";
|
||||||
let plugins = "\n";
|
let plugins = "\n";
|
||||||
let i = 0;
|
let i = 0;
|
||||||
@ -70,8 +78,9 @@ export const globPlugins = kind => ({
|
|||||||
if (!existsSync(`./src/${dir}`)) continue;
|
if (!existsSync(`./src/${dir}`)) continue;
|
||||||
const files = await readdir(`./src/${dir}`);
|
const files = await readdir(`./src/${dir}`);
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
if (file.startsWith(".")) continue;
|
if (file.startsWith("_") || file.startsWith(".")) continue;
|
||||||
if (file === "index.ts") continue;
|
if (file === "index.ts") continue;
|
||||||
|
|
||||||
const fileBits = file.split(".");
|
const fileBits = file.split(".");
|
||||||
if (fileBits.length > 2 && ["ts", "tsx"].includes(fileBits.at(-1))) {
|
if (fileBits.length > 2 && ["ts", "tsx"].includes(fileBits.at(-1))) {
|
||||||
const mod = fileBits.at(-2);
|
const mod = fileBits.at(-2);
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* Vencord, a modification for Discord's desktop app
|
|
||||||
* Copyright (c) 2022 Vendicated and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// A script to automatically generate a list of all plugins.
|
|
||||||
// Just copy paste the entire file into a running Vencord install and it will prompt you
|
|
||||||
// to save the file
|
|
||||||
|
|
||||||
// eslint-disable-next-line spaced-comment
|
|
||||||
/// <reference types="../src/modules"/>
|
|
||||||
|
|
||||||
(() => {
|
|
||||||
/**
|
|
||||||
* @type {typeof import("~plugins").default}
|
|
||||||
*/
|
|
||||||
const Plugins = Vencord.Plugins.plugins;
|
|
||||||
|
|
||||||
const header = `
|
|
||||||
<!-- This file is auto generated, do not edit -->
|
|
||||||
|
|
||||||
# Vencord Plugins
|
|
||||||
`;
|
|
||||||
|
|
||||||
let tableOfContents = "\n\n";
|
|
||||||
|
|
||||||
let list = "\n\n";
|
|
||||||
|
|
||||||
for (const p of Object.values(Plugins).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
||||||
tableOfContents += `- [${p.name}](#${p.name.replaceAll(" ", "-")})\n`;
|
|
||||||
|
|
||||||
list += `## ${p.name}
|
|
||||||
|
|
||||||
${p.description}
|
|
||||||
|
|
||||||
**Authors**: ${p.authors.map(a => a.name).join(", ")}
|
|
||||||
`;
|
|
||||||
|
|
||||||
if (p.commands?.length) {
|
|
||||||
list += "\n\n#### Commands\n";
|
|
||||||
for (const cmd of p.commands) {
|
|
||||||
list += `${cmd.name} - ${cmd.description}\n\n`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
list += "\n\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
copy(header + tableOfContents + list);
|
|
||||||
})();
|
|
@ -19,7 +19,7 @@
|
|||||||
import { Dirent, readdirSync, readFileSync, writeFileSync } from "fs";
|
import { Dirent, readdirSync, readFileSync, writeFileSync } from "fs";
|
||||||
import { access, readFile } from "fs/promises";
|
import { access, readFile } from "fs/promises";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import { BigIntLiteral, createSourceFile, Identifier, isArrayLiteralExpression, isCallExpression, isExportAssignment, isIdentifier, isObjectLiteralExpression, isPropertyAccessExpression, isPropertyAssignment, isStringLiteral, isVariableStatement, NamedDeclaration, NodeArray, ObjectLiteralExpression, ScriptTarget, StringLiteral, SyntaxKind } from "typescript";
|
import { BigIntLiteral, createSourceFile, Identifier, isArrayLiteralExpression, isCallExpression, isExportAssignment, isIdentifier, isObjectLiteralExpression, isPropertyAccessExpression, isPropertyAssignment, isSatisfiesExpression, isStringLiteral, isVariableStatement, NamedDeclaration, NodeArray, ObjectLiteralExpression, ScriptTarget, StringLiteral, SyntaxKind } from "typescript";
|
||||||
|
|
||||||
interface Dev {
|
interface Dev {
|
||||||
name: string;
|
name: string;
|
||||||
@ -66,9 +66,9 @@ function parseDevs() {
|
|||||||
|
|
||||||
const value = devsDeclaration.initializer.arguments[0];
|
const value = devsDeclaration.initializer.arguments[0];
|
||||||
|
|
||||||
if (!isObjectLiteralExpression(value)) return;
|
if (!isSatisfiesExpression(value) || !isObjectLiteralExpression(value.expression)) throw new Error("Failed to parse devs: not an object literal");
|
||||||
|
|
||||||
for (const prop of value.properties) {
|
for (const prop of value.expression.properties) {
|
||||||
const name = (prop.name as Identifier).text;
|
const name = (prop.name as Identifier).text;
|
||||||
const value = isPropertyAssignment(prop) ? prop.initializer : prop;
|
const value = isPropertyAssignment(prop) ? prop.initializer : prop;
|
||||||
|
|
||||||
@ -130,7 +130,9 @@ async function parseFile(fileName: string) {
|
|||||||
if (!isArrayLiteralExpression(value)) throw fail("authors is not an array literal");
|
if (!isArrayLiteralExpression(value)) throw fail("authors is not an array literal");
|
||||||
data.authors = value.elements.map(e => {
|
data.authors = value.elements.map(e => {
|
||||||
if (!isPropertyAccessExpression(e)) throw fail("authors array contains non-property access expressions");
|
if (!isPropertyAccessExpression(e)) throw fail("authors array contains non-property access expressions");
|
||||||
return devs[getName(e)!];
|
const d = devs[getName(e)!];
|
||||||
|
if (!d) throw fail(`couldn't look up author ${getName(e)}`);
|
||||||
|
return d;
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "tags":
|
case "tags":
|
||||||
@ -149,7 +151,6 @@ async function parseFile(fileName: string) {
|
|||||||
case "required":
|
case "required":
|
||||||
case "enabledByDefault":
|
case "enabledByDefault":
|
||||||
data[key] = value.kind === SyntaxKind.TrueKeyword;
|
data[key] = value.kind === SyntaxKind.TrueKeyword;
|
||||||
if (!data[key] && value.kind !== SyntaxKind.FalseKeyword) throw fail(`${key} is not a boolean literal`);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -169,8 +170,8 @@ async function parseFile(fileName: string) {
|
|||||||
throw fail("no default export called 'definePlugin' found");
|
throw fail("no default export called 'definePlugin' found");
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getEntryPoint(dirent: Dirent) {
|
async function getEntryPoint(dir: string, dirent: Dirent) {
|
||||||
const base = join("./src/plugins", dirent.name);
|
const base = join(dir, dirent.name);
|
||||||
if (!dirent.isDirectory()) return base;
|
if (!dirent.isDirectory()) return base;
|
||||||
|
|
||||||
for (const name of ["index.ts", "index.tsx"]) {
|
for (const name of ["index.ts", "index.tsx"]) {
|
||||||
@ -184,13 +185,23 @@ async function getEntryPoint(dirent: Dirent) {
|
|||||||
throw new Error(`${dirent.name}: Couldn't find entry point`);
|
throw new Error(`${dirent.name}: Couldn't find entry point`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isPluginFile({ name }: { name: string; }) {
|
||||||
|
if (name === "index.ts") return false;
|
||||||
|
return !name.startsWith("_") && !name.startsWith(".");
|
||||||
|
}
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
parseDevs();
|
parseDevs();
|
||||||
const plugins = readdirSync("./src/plugins", { withFileTypes: true }).filter(d => d.name !== "index.ts");
|
|
||||||
|
|
||||||
const promises = plugins.map(async dirent => parseFile(await getEntryPoint(dirent)));
|
const plugins = ["src/plugins", "src/plugins/_core"].flatMap(dir =>
|
||||||
|
readdirSync(dir, { withFileTypes: true })
|
||||||
|
.filter(isPluginFile)
|
||||||
|
.map(async dirent =>
|
||||||
|
parseFile(await getEntryPoint(dir, dirent))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
const data = JSON.stringify(await Promise.all(promises));
|
const data = JSON.stringify(await Promise.all(plugins));
|
||||||
|
|
||||||
if (process.argv.length > 2) {
|
if (process.argv.length > 2) {
|
||||||
writeFileSync(process.argv[2], data);
|
writeFileSync(process.argv[2], data);
|
||||||
|
@ -58,4 +58,10 @@ export default {
|
|||||||
getVersions: () => process.versions as Partial<NodeJS.ProcessVersions>,
|
getVersions: () => process.versions as Partial<NodeJS.ProcessVersions>,
|
||||||
openExternal: (url: string) => invoke<void>(IpcEvents.OPEN_EXTERNAL, url)
|
openExternal: (url: string) => invoke<void>(IpcEvents.OPEN_EXTERNAL, url)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
pluginHelpers: {
|
||||||
|
OpenInApp: {
|
||||||
|
resolveRedirect: (url: string) => invoke<string>(IpcEvents.OPEN_IN_APP__RESOLVE_REDIRECT, url),
|
||||||
|
},
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -22,7 +22,7 @@ import { ComponentType, HTMLProps } from "react";
|
|||||||
|
|
||||||
import Plugins from "~plugins";
|
import Plugins from "~plugins";
|
||||||
|
|
||||||
export enum BadgePosition {
|
export const enum BadgePosition {
|
||||||
START,
|
START,
|
||||||
END
|
END
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ export function _getBadges(args: BadgeUserArgs) {
|
|||||||
: badges.push({ ...badge, ...args });
|
: badges.push({ ...badge, ...args });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const donorBadges = (Plugins.BadgeAPI as unknown as typeof import("../plugins/apiBadges").default).getDonorBadges(args.user.id);
|
const donorBadges = (Plugins.BadgeAPI as unknown as typeof import("../plugins/_api/badges").default).getDonorBadges(args.user.id);
|
||||||
if (donorBadges) badges.unshift(...donorBadges);
|
if (donorBadges) badges.unshift(...donorBadges);
|
||||||
|
|
||||||
return badges;
|
return badges;
|
||||||
|
@ -24,7 +24,7 @@ export interface CommandContext {
|
|||||||
guild?: Guild;
|
guild?: Guild;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ApplicationCommandOptionType {
|
export const enum ApplicationCommandOptionType {
|
||||||
SUB_COMMAND = 1,
|
SUB_COMMAND = 1,
|
||||||
SUB_COMMAND_GROUP = 2,
|
SUB_COMMAND_GROUP = 2,
|
||||||
STRING = 3,
|
STRING = 3,
|
||||||
@ -38,7 +38,7 @@ export enum ApplicationCommandOptionType {
|
|||||||
ATTACHMENT = 11,
|
ATTACHMENT = 11,
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ApplicationCommandInputType {
|
export const enum ApplicationCommandInputType {
|
||||||
BUILT_IN = 0,
|
BUILT_IN = 0,
|
||||||
BUILT_IN_TEXT = 1,
|
BUILT_IN_TEXT = 1,
|
||||||
BUILT_IN_INTEGRATION = 2,
|
BUILT_IN_INTEGRATION = 2,
|
||||||
@ -64,7 +64,7 @@ export interface ChoicesOption {
|
|||||||
displayName?: string;
|
displayName?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ApplicationCommandType {
|
export const enum ApplicationCommandType {
|
||||||
CHAT_INPUT = 1,
|
CHAT_INPUT = 1,
|
||||||
USER = 2,
|
USER = 2,
|
||||||
MESSAGE = 3,
|
MESSAGE = 3,
|
||||||
|
@ -25,14 +25,14 @@ type ContextMenuPatchCallbackReturn = (() => void) | void;
|
|||||||
* @param args Any arguments passed into making the context menu, like the guild, channel, user or message for example
|
* @param args Any arguments passed into making the context menu, like the guild, channel, user or message for example
|
||||||
* @returns A callback which is only ran once used to modify the context menu elements (Use to avoid duplicates)
|
* @returns A callback which is only ran once used to modify the context menu elements (Use to avoid duplicates)
|
||||||
*/
|
*/
|
||||||
export type NavContextMenuPatchCallback = (children: Array<React.ReactElement>, ...args: Array<any>) => ContextMenuPatchCallbackReturn;
|
export type NavContextMenuPatchCallback = (children: Array<ReactElement | null>, ...args: Array<any>) => ContextMenuPatchCallbackReturn;
|
||||||
/**
|
/**
|
||||||
* @param navId The navId of the context menu being patched
|
* @param navId The navId of the context menu being patched
|
||||||
* @param children The rendered context menu elements
|
* @param children The rendered context menu elements
|
||||||
* @param args Any arguments passed into making the context menu, like the guild, channel, user or message for example
|
* @param args Any arguments passed into making the context menu, like the guild, channel, user or message for example
|
||||||
* @returns A callback which is only ran once used to modify the context menu elements (Use to avoid duplicates)
|
* @returns A callback which is only ran once used to modify the context menu elements (Use to avoid duplicates)
|
||||||
*/
|
*/
|
||||||
export type GlobalContextMenuPatchCallback = (navId: string, children: Array<React.ReactElement>, ...args: Array<any>) => ContextMenuPatchCallbackReturn;
|
export type GlobalContextMenuPatchCallback = (navId: string, children: Array<ReactElement | null>, ...args: Array<any>) => ContextMenuPatchCallbackReturn;
|
||||||
|
|
||||||
const ContextMenuLogger = new Logger("ContextMenu");
|
const ContextMenuLogger = new Logger("ContextMenu");
|
||||||
|
|
||||||
@ -89,15 +89,18 @@ export function removeGlobalContextMenuPatch(patch: GlobalContextMenuPatchCallba
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A helper function for finding the children array of a group nested inside a context menu based on the id of one of its childs
|
* A helper function for finding the children array of a group nested inside a context menu based on the id(s) of its children
|
||||||
* @param id The id of the child
|
* @param id The id of the child. If an array is specified, all ids will be tried
|
||||||
* @param children The context menu children
|
* @param children The context menu children
|
||||||
*/
|
*/
|
||||||
export function findGroupChildrenByChildId(id: string, children: Array<React.ReactElement>, _itemsArray?: Array<React.ReactElement>): Array<React.ReactElement> | null {
|
export function findGroupChildrenByChildId(id: string | string[], children: Array<ReactElement | null>, _itemsArray?: Array<ReactElement | null>): Array<ReactElement | null> | null {
|
||||||
for (const child of children) {
|
for (const child of children) {
|
||||||
if (child == null) continue;
|
if (child == null) continue;
|
||||||
|
|
||||||
if (child.props?.id === id) return _itemsArray ?? null;
|
if (
|
||||||
|
(Array.isArray(id) && id.some(id => child.props?.id === id))
|
||||||
|
|| child.props?.id === id
|
||||||
|
) return _itemsArray ?? null;
|
||||||
|
|
||||||
let nextChildren = child.props?.children;
|
let nextChildren = child.props?.children;
|
||||||
if (nextChildren) {
|
if (nextChildren) {
|
||||||
@ -117,7 +120,7 @@ export function findGroupChildrenByChildId(id: string, children: Array<React.Rea
|
|||||||
interface ContextMenuProps {
|
interface ContextMenuProps {
|
||||||
contextMenuApiArguments?: Array<any>;
|
contextMenuApiArguments?: Array<any>;
|
||||||
navId: string;
|
navId: string;
|
||||||
children: Array<ReactElement>;
|
children: Array<ReactElement | null>;
|
||||||
"aria-label": string;
|
"aria-label": string;
|
||||||
onSelect: (() => void) | undefined;
|
onSelect: (() => void) | undefined;
|
||||||
onClose: (callback: (...args: Array<any>) => any) => void;
|
onClose: (callback: (...args: Array<any>) => any) => void;
|
||||||
|
@ -18,24 +18,15 @@
|
|||||||
|
|
||||||
import { Logger } from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import { MessageStore } from "@webpack/common";
|
import { MessageStore } from "@webpack/common";
|
||||||
|
import { CustomEmoji } from "@webpack/types";
|
||||||
import type { Channel, Message } from "discord-types/general";
|
import type { Channel, Message } from "discord-types/general";
|
||||||
import type { Promisable } from "type-fest";
|
import type { Promisable } from "type-fest";
|
||||||
|
|
||||||
const MessageEventsLogger = new Logger("MessageEvents", "#e5c890");
|
const MessageEventsLogger = new Logger("MessageEvents", "#e5c890");
|
||||||
|
|
||||||
export interface Emoji {
|
|
||||||
require_colons: boolean,
|
|
||||||
originalName: string,
|
|
||||||
animated: boolean;
|
|
||||||
guildId: string,
|
|
||||||
name: string,
|
|
||||||
url: string,
|
|
||||||
id: string,
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MessageObject {
|
export interface MessageObject {
|
||||||
content: string,
|
content: string,
|
||||||
validNonShortcutEmojis: Emoji[];
|
validNonShortcutEmojis: CustomEmoji[];
|
||||||
invalidEmojis: any[];
|
invalidEmojis: any[];
|
||||||
tts: boolean;
|
tts: boolean;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ import { Logger } from "@utils/Logger";
|
|||||||
|
|
||||||
const logger = new Logger("ServerListAPI");
|
const logger = new Logger("ServerListAPI");
|
||||||
|
|
||||||
export enum ServerListRenderPosition {
|
export const enum ServerListRenderPosition {
|
||||||
Above,
|
Above,
|
||||||
In,
|
In,
|
||||||
}
|
}
|
||||||
|
@ -254,8 +254,12 @@ export function migratePluginSettings(name: string, ...oldNames: string[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function definePluginSettings<D extends SettingsDefinition, C extends SettingsChecks<D>>(def: D, checks?: C) {
|
export function definePluginSettings<
|
||||||
const definedSettings: DefinedSettings<D> = {
|
Def extends SettingsDefinition,
|
||||||
|
Checks extends SettingsChecks<Def>,
|
||||||
|
PrivateSettings extends object = {}
|
||||||
|
>(def: Def, checks?: Checks) {
|
||||||
|
const definedSettings: DefinedSettings<Def, Checks, PrivateSettings> = {
|
||||||
get store() {
|
get store() {
|
||||||
if (!definedSettings.pluginName) throw new Error("Cannot access settings before plugin is initialized");
|
if (!definedSettings.pluginName) throw new Error("Cannot access settings before plugin is initialized");
|
||||||
return Settings.plugins[definedSettings.pluginName] as any;
|
return Settings.plugins[definedSettings.pluginName] as any;
|
||||||
@ -264,9 +268,14 @@ export function definePluginSettings<D extends SettingsDefinition, C extends Set
|
|||||||
settings?.map(name => `plugins.${definedSettings.pluginName}.${name}`) as UseSettings<Settings>[]
|
settings?.map(name => `plugins.${definedSettings.pluginName}.${name}`) as UseSettings<Settings>[]
|
||||||
).plugins[definedSettings.pluginName] as any,
|
).plugins[definedSettings.pluginName] as any,
|
||||||
def,
|
def,
|
||||||
checks: checks ?? {},
|
checks: checks ?? {} as any,
|
||||||
pluginName: "",
|
pluginName: "",
|
||||||
|
|
||||||
|
withPrivateSettings<T extends object>() {
|
||||||
|
return this as DefinedSettings<Def, Checks, T>;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return definedSettings;
|
return definedSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
src/components/ExpandableHeader.css
Normal file
12
src/components/ExpandableHeader.css
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
.vc-expandableheader-center-flex {
|
||||||
|
display: flex;
|
||||||
|
justify-items: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-expandableheader-btn {
|
||||||
|
all: unset;
|
||||||
|
cursor: pointer;
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
}
|
108
src/components/ExpandableHeader.tsx
Normal file
108
src/components/ExpandableHeader.tsx
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
* Vencord, a modification for Discord's desktop app
|
||||||
|
* Copyright (c) 2023 Vendicated and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { classNameFactory } from "@api/Styles";
|
||||||
|
import { Text, Tooltip, useState } from "@webpack/common";
|
||||||
|
export const cl = classNameFactory("vc-expandableheader-");
|
||||||
|
import "./ExpandableHeader.css";
|
||||||
|
|
||||||
|
export interface ExpandableHeaderProps {
|
||||||
|
onMoreClick?: () => void;
|
||||||
|
moreTooltipText?: string;
|
||||||
|
onDropDownClick?: (state: boolean) => void;
|
||||||
|
defaultState?: boolean;
|
||||||
|
headerText: string;
|
||||||
|
children: React.ReactNode;
|
||||||
|
buttons?: React.ReactNode[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function ExpandableHeader({ children, onMoreClick, buttons, moreTooltipText, defaultState = false, onDropDownClick, headerText }: ExpandableHeaderProps) {
|
||||||
|
const [showContent, setShowContent] = useState(defaultState);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div style={{
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
alignItems: "center",
|
||||||
|
marginBottom: "8px"
|
||||||
|
}}>
|
||||||
|
<Text
|
||||||
|
tag="h2"
|
||||||
|
variant="eyebrow"
|
||||||
|
style={{
|
||||||
|
color: "var(--header-primary)",
|
||||||
|
display: "inline"
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{headerText}
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<div className={cl("center-flex")}>
|
||||||
|
{
|
||||||
|
buttons ?? null
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
onMoreClick && // only show more button if callback is provided
|
||||||
|
<Tooltip text={moreTooltipText}>
|
||||||
|
{tooltipProps => (
|
||||||
|
<button
|
||||||
|
{...tooltipProps}
|
||||||
|
className={cl("btn")}
|
||||||
|
onClick={onMoreClick}>
|
||||||
|
<svg
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<path fill="var(--text-normal)" d="M7 12.001C7 10.8964 6.10457 10.001 5 10.001C3.89543 10.001 3 10.8964 3 12.001C3 13.1055 3.89543 14.001 5 14.001C6.10457 14.001 7 13.1055 7 12.001ZM14 12.001C14 10.8964 13.1046 10.001 12 10.001C10.8954 10.001 10 10.8964 10 12.001C10 13.1055 10.8954 14.001 12 14.001C13.1046 14.001 14 13.1055 14 12.001ZM19 10.001C20.1046 10.001 21 10.8964 21 12.001C21 13.1055 20.1046 14.001 19 14.001C17.8954 14.001 17 13.1055 17 12.001C17 10.8964 17.8954 10.001 19 10.001Z" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</Tooltip>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
<Tooltip text={showContent ? "Hide " + headerText : "Show " + headerText}>
|
||||||
|
{tooltipProps => (
|
||||||
|
<button
|
||||||
|
{...tooltipProps}
|
||||||
|
className={cl("btn")}
|
||||||
|
onClick={() => {
|
||||||
|
setShowContent(v => !v);
|
||||||
|
onDropDownClick?.(showContent);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
transform={showContent ? "scale(1 -1)" : "scale(1 1)"}
|
||||||
|
>
|
||||||
|
<path fill="var(--text-normal)" d="M16.59 8.59003L12 13.17L7.41 8.59003L6 10L12 16L18 10L16.59 8.59003Z" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{showContent && children}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
@ -16,28 +16,31 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import "./iconStyles.css";
|
||||||
|
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import type { PropsWithChildren } from "react";
|
import { i18n } from "@webpack/common";
|
||||||
|
import type { PropsWithChildren, SVGProps } from "react";
|
||||||
|
|
||||||
interface BaseIconProps extends IconProps {
|
interface BaseIconProps extends IconProps {
|
||||||
viewBox: string;
|
viewBox: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IconProps {
|
interface IconProps extends SVGProps<SVGSVGElement> {
|
||||||
className?: string;
|
className?: string;
|
||||||
height?: number;
|
height?: number;
|
||||||
width?: number;
|
width?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
function Icon({ height = 24, width = 24, className, children, viewBox }: PropsWithChildren<BaseIconProps>) {
|
function Icon({ height = 24, width = 24, className, children, viewBox, ...svgProps }: PropsWithChildren<BaseIconProps>) {
|
||||||
return (
|
return (
|
||||||
<svg
|
<svg
|
||||||
className={classes(className, "vc-icon")}
|
className={classes(className, "vc-icon")}
|
||||||
aria-hidden="true"
|
|
||||||
role="img"
|
role="img"
|
||||||
width={width}
|
width={width}
|
||||||
height={height}
|
height={height}
|
||||||
viewBox={viewBox}
|
viewBox={viewBox}
|
||||||
|
{...svgProps}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</svg>
|
</svg>
|
||||||
@ -81,3 +84,109 @@ export function CopyIcon(props: IconProps) {
|
|||||||
</Icon>
|
</Icon>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Discord's open external icon, as seen in the user profile connections
|
||||||
|
*/
|
||||||
|
export function OpenExternalIcon(props: IconProps) {
|
||||||
|
return (
|
||||||
|
<Icon
|
||||||
|
{...props}
|
||||||
|
className={classes(props.className, "vc-open-external-icon")}
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<polygon
|
||||||
|
fill="currentColor"
|
||||||
|
fill-rule="nonzero"
|
||||||
|
points="13 20 11 20 11 8 5.5 13.5 4.08 12.08 12 4.16 19.92 12.08 18.5 13.5 13 8"
|
||||||
|
/>
|
||||||
|
</Icon>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ImageIcon(props: IconProps) {
|
||||||
|
return (
|
||||||
|
<Icon
|
||||||
|
{...props}
|
||||||
|
className={classes(props.className, "vc-image-icon")}
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<path fill="currentColor" d="M21,19V5c0,-1.1 -0.9,-2 -2,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2zM8.5,13.5l2.5,3.01L14.5,12l4.5,6H5l3.5,-4.5z" />
|
||||||
|
</Icon>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function InfoIcon(props: IconProps) {
|
||||||
|
return (
|
||||||
|
<Icon
|
||||||
|
{...props}
|
||||||
|
className={classes(props.className, "vc-info-icon")}
|
||||||
|
viewBox="0 0 12 12"
|
||||||
|
>
|
||||||
|
<path fill="currentColor" d="M6 1C3.243 1 1 3.244 1 6c0 2.758 2.243 5 5 5s5-2.242 5-5c0-2.756-2.243-5-5-5zm0 2.376a.625.625 0 110 1.25.625.625 0 010-1.25zM7.5 8.5h-3v-1h1V6H5V5h1a.5.5 0 01.5.5v2h1v1z" />
|
||||||
|
</Icon>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function OwnerCrownIcon(props: IconProps) {
|
||||||
|
return (
|
||||||
|
<Icon
|
||||||
|
aria-label={i18n.Messages.GUILD_OWNER}
|
||||||
|
{...props}
|
||||||
|
className={classes(props.className, "vc-owner-crown-icon")}
|
||||||
|
role="img"
|
||||||
|
viewBox="0 0 16 16"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
fill="currentColor"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
clip-rule="evenodd"
|
||||||
|
d="M13.6572 5.42868C13.8879 5.29002 14.1806 5.30402 14.3973 5.46468C14.6133 5.62602 14.7119 5.90068 14.6473 6.16202L13.3139 11.4954C13.2393 11.7927 12.9726 12.0007 12.6666 12.0007H3.33325C3.02725 12.0007 2.76058 11.792 2.68592 11.4954L1.35258 6.16202C1.28792 5.90068 1.38658 5.62602 1.60258 5.46468C1.81992 5.30468 2.11192 5.29068 2.34325 5.42868L5.13192 7.10202L7.44592 3.63068C7.46173 3.60697 7.48377 3.5913 7.50588 3.57559C7.5192 3.56612 7.53255 3.55663 7.54458 3.54535L6.90258 2.90268C6.77325 2.77335 6.77325 2.56068 6.90258 2.43135L7.76458 1.56935C7.89392 1.44002 8.10658 1.44002 8.23592 1.56935L9.09792 2.43135C9.22725 2.56068 9.22725 2.77335 9.09792 2.90268L8.45592 3.54535C8.46794 3.55686 8.48154 3.56651 8.49516 3.57618C8.51703 3.5917 8.53897 3.60727 8.55458 3.63068L10.8686 7.10202L13.6572 5.42868ZM2.66667 12.6673H13.3333V14.0007H2.66667V12.6673Z"
|
||||||
|
/>
|
||||||
|
</Icon>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Discord's screenshare icon, as seen in the connection panel
|
||||||
|
*/
|
||||||
|
export function ScreenshareIcon(props: IconProps) {
|
||||||
|
return (
|
||||||
|
<Icon
|
||||||
|
{...props}
|
||||||
|
className={classes(props.className, "vc-screenshare-icon")}
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
fill="currentColor"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
clip-rule="evenodd"
|
||||||
|
d="M2 4.5C2 3.397 2.897 2.5 4 2.5H20C21.103 2.5 22 3.397 22 4.5V15.5C22 16.604 21.103 17.5 20 17.5H13V19.5H17V21.5H7V19.5H11V17.5H4C2.897 17.5 2 16.604 2 15.5V4.5ZM13.2 14.3375V11.6C9.864 11.6 7.668 12.6625 6 15C6.672 11.6625 8.532 8.3375 13.2 7.6625V5L18 9.6625L13.2 14.3375Z"
|
||||||
|
/>
|
||||||
|
</Icon>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ImageVisible(props: IconProps) {
|
||||||
|
return (
|
||||||
|
<Icon
|
||||||
|
{...props}
|
||||||
|
className={classes(props.className, "vc-image-visible")}
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<path fill="currentColor" d="M5 21q-.825 0-1.413-.587Q3 19.825 3 19V5q0-.825.587-1.413Q4.175 3 5 3h14q.825 0 1.413.587Q21 4.175 21 5v14q0 .825-.587 1.413Q19.825 21 19 21Zm0-2h14V5H5v14Zm1-2h12l-3.75-5-3 4L9 13Zm-1 2V5v14Z" />
|
||||||
|
</Icon>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ImageInvisible(props: IconProps) {
|
||||||
|
return (
|
||||||
|
<Icon
|
||||||
|
{...props}
|
||||||
|
className={classes(props.className, "vc-image-invisible")}
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<path fill="currentColor" d="m21 18.15-2-2V5H7.85l-2-2H19q.825 0 1.413.587Q21 4.175 21 5Zm-1.2 4.45L18.2 21H5q-.825 0-1.413-.587Q3 19.825 3 19V5.8L1.4 4.2l1.4-1.4 18.4 18.4ZM6 17l3-4 2.25 3 .825-1.1L5 7.825V19h11.175l-2-2Zm7.425-6.425ZM10.6 13.4Z" />
|
||||||
|
</Icon>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
import { generateId } from "@api/Commands";
|
import { generateId } from "@api/Commands";
|
||||||
import { useSettings } from "@api/Settings";
|
import { useSettings } from "@api/Settings";
|
||||||
|
import { disableStyle, enableStyle } from "@api/Styles";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Flex } from "@components/Flex";
|
import { Flex } from "@components/Flex";
|
||||||
import { proxyLazy } from "@utils/lazy";
|
import { proxyLazy } from "@utils/lazy";
|
||||||
@ -40,6 +41,7 @@ import {
|
|||||||
SettingSliderComponent,
|
SettingSliderComponent,
|
||||||
SettingTextComponent
|
SettingTextComponent
|
||||||
} from "./components";
|
} from "./components";
|
||||||
|
import hideBotTagStyle from "./userPopoutHideBotTag.css?managed";
|
||||||
|
|
||||||
const UserSummaryItem = LazyComponent(() => findByCode("defaultRenderUser", "showDefaultAvatarsForNullUsers"));
|
const UserSummaryItem = LazyComponent(() => findByCode("defaultRenderUser", "showDefaultAvatarsForNullUsers"));
|
||||||
const AvatarStyles = findByPropsLazy("moreUsers", "emptyUser", "avatarContainer", "clickableAvatar");
|
const AvatarStyles = findByPropsLazy("moreUsers", "emptyUser", "avatarContainer", "clickableAvatar");
|
||||||
@ -50,11 +52,12 @@ interface PluginModalProps extends ModalProps {
|
|||||||
onRestartNeeded(): void;
|
onRestartNeeded(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** To stop discord making unwanted requests... */
|
function makeDummyUser(user: { username: string; id?: string; avatar?: string; }) {
|
||||||
function makeDummyUser(user: { name: string, id: BigInt; }) {
|
|
||||||
const newUser = new UserRecord({
|
const newUser = new UserRecord({
|
||||||
username: user.name,
|
username: user.username,
|
||||||
id: generateId(),
|
id: user.id ?? generateId(),
|
||||||
|
avatar: user.avatar,
|
||||||
|
/** To stop discord making unwanted requests... */
|
||||||
bot: true,
|
bot: true,
|
||||||
});
|
});
|
||||||
FluxDispatcher.dispatch({
|
FluxDispatcher.dispatch({
|
||||||
@ -89,14 +92,27 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti
|
|||||||
const hasSettings = Boolean(pluginSettings && plugin.options);
|
const hasSettings = Boolean(pluginSettings && plugin.options);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
enableStyle(hideBotTagStyle);
|
||||||
|
|
||||||
|
let originalUser: User;
|
||||||
(async () => {
|
(async () => {
|
||||||
for (const user of plugin.authors.slice(0, 6)) {
|
for (const user of plugin.authors.slice(0, 6)) {
|
||||||
const author = user.id
|
const author = user.id
|
||||||
? await UserUtils.fetchUser(`${user.id}`).catch(() => makeDummyUser(user))
|
? await UserUtils.fetchUser(`${user.id}`)
|
||||||
: makeDummyUser(user);
|
// only show name & pfp and no actions so users cannot harass plugin devs for support (send dms, add as friend, etc)
|
||||||
|
.then(u => (originalUser = u, makeDummyUser(u)))
|
||||||
|
.catch(() => makeDummyUser({ username: user.name }))
|
||||||
|
: makeDummyUser({ username: user.name });
|
||||||
|
|
||||||
setAuthors(a => [...a, author]);
|
setAuthors(a => [...a, author]);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
disableStyle(hideBotTagStyle);
|
||||||
|
if (originalUser)
|
||||||
|
FluxDispatcher.dispatch({ type: "USER_UPDATE", user: originalUser });
|
||||||
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
async function saveAndClose() {
|
async function saveAndClose() {
|
||||||
|
@ -138,11 +138,13 @@ function PluginCard({ plugin, disabled, onRestartNeeded, onMouseEnter, onMouseLe
|
|||||||
}
|
}
|
||||||
|
|
||||||
const result = wasEnabled ? stopPlugin(plugin) : startPlugin(plugin);
|
const result = wasEnabled ? stopPlugin(plugin) : startPlugin(plugin);
|
||||||
const action = wasEnabled ? "stop" : "start";
|
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
logger.error(`Failed to ${action} plugin ${plugin.name}`);
|
settings.enabled = false;
|
||||||
showErrorToast(`Failed to ${action} plugin: ${plugin.name}`);
|
|
||||||
|
const msg = `Error while ${wasEnabled ? "stopping" : "starting"} plugin ${plugin.name}`;
|
||||||
|
logger.error(msg);
|
||||||
|
showErrorToast(msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +173,7 @@ function PluginCard({ plugin, disabled, onRestartNeeded, onMouseEnter, onMouseLe
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum SearchStatus {
|
const enum SearchStatus {
|
||||||
ALL,
|
ALL,
|
||||||
ENABLED,
|
ENABLED,
|
||||||
DISABLED
|
DISABLED
|
||||||
|
3
src/components/PluginSettings/userPopoutHideBotTag.css
Normal file
3
src/components/PluginSettings/userPopoutHideBotTag.css
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[class|="userPopoutOuter"] [class*="botTag"] {
|
||||||
|
display: none;
|
||||||
|
}
|
@ -86,7 +86,7 @@ function SettingsSyncSection() {
|
|||||||
<Button
|
<Button
|
||||||
size={Button.Sizes.SMALL}
|
size={Button.Sizes.SMALL}
|
||||||
disabled={!sectionEnabled}
|
disabled={!sectionEnabled}
|
||||||
onClick={() => putCloudSettings()}
|
onClick={() => putCloudSettings(true)}
|
||||||
>Sync to Cloud</Button>
|
>Sync to Cloud</Button>
|
||||||
<Tooltip text="This will overwrite your local settings with the ones on the cloud. Use wisely!">
|
<Tooltip text="This will overwrite your local settings with the ones on the cloud. Use wisely!">
|
||||||
{({ onMouseLeave, onMouseEnter }) => (
|
{({ onMouseLeave, onMouseEnter }) => (
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.vc-text-selectable,
|
.vc-text-selectable,
|
||||||
.vc-text-selectable :not(a, button, a *, button *) {
|
.vc-text-selectable :where([class*="text" i], [class*="title" i]) {
|
||||||
/* make text selectable, silly discord makes the entirety of settings not selectable */
|
/* make text selectable, silly discord makes the entirety of settings not selectable */
|
||||||
user-select: text;
|
user-select: text;
|
||||||
|
|
||||||
|
7
src/components/iconStyles.css
Normal file
7
src/components/iconStyles.css
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
.vc-open-external-icon {
|
||||||
|
transform: rotate(45deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-owner-crown-icon {
|
||||||
|
color: var(--text-warning);
|
||||||
|
}
|
2
src/globals.d.ts
vendored
2
src/globals.d.ts
vendored
@ -37,6 +37,8 @@ declare global {
|
|||||||
export var IS_STANDALONE: boolean;
|
export var IS_STANDALONE: boolean;
|
||||||
export var IS_DISCORD_DESKTOP: boolean;
|
export var IS_DISCORD_DESKTOP: boolean;
|
||||||
export var IS_VENCORD_DESKTOP: boolean;
|
export var IS_VENCORD_DESKTOP: boolean;
|
||||||
|
export var VERSION: string;
|
||||||
|
export var BUILD_TIMESTAMP: number;
|
||||||
|
|
||||||
export var VencordNative: typeof import("./VencordNative").default;
|
export var VencordNative: typeof import("./VencordNative").default;
|
||||||
export var Vencord: typeof import("./Vencord");
|
export var Vencord: typeof import("./Vencord");
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import "./updater";
|
import "./updater";
|
||||||
|
import "./ipcPlugins";
|
||||||
|
|
||||||
import { debounce } from "@utils/debounce";
|
import { debounce } from "@utils/debounce";
|
||||||
import { IpcEvents } from "@utils/IpcEvents";
|
import { IpcEvents } from "@utils/IpcEvents";
|
||||||
|
46
src/main/ipcPlugins.ts
Normal file
46
src/main/ipcPlugins.ts
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Vencord, a modification for Discord's desktop app
|
||||||
|
* Copyright (c) 2023 Vendicated and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { IpcEvents } from "@utils/IpcEvents";
|
||||||
|
import { ipcMain } from "electron";
|
||||||
|
import { request } from "https";
|
||||||
|
|
||||||
|
// #region OpenInApp
|
||||||
|
// These links don't support CORS, so this has to be native
|
||||||
|
const validRedirectUrls = /^https:\/\/(spotify\.link|s\.team)\/.+$/;
|
||||||
|
|
||||||
|
function getRedirect(url: string) {
|
||||||
|
return new Promise<string>((resolve, reject) => {
|
||||||
|
const req = request(new URL(url), { method: "HEAD" }, res => {
|
||||||
|
resolve(
|
||||||
|
res.headers.location
|
||||||
|
? getRedirect(res.headers.location)
|
||||||
|
: url
|
||||||
|
);
|
||||||
|
});
|
||||||
|
req.on("error", reject);
|
||||||
|
req.end();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ipcMain.handle(IpcEvents.OPEN_IN_APP__RESOLVE_REDIRECT, async (_, url: string) => {
|
||||||
|
if (!validRedirectUrls.test(url)) return url;
|
||||||
|
|
||||||
|
return getRedirect(url);
|
||||||
|
});
|
||||||
|
// #endregion
|
@ -31,7 +31,8 @@ export const ALLOWED_PROTOCOLS = [
|
|||||||
"https:",
|
"https:",
|
||||||
"http:",
|
"http:",
|
||||||
"steam:",
|
"steam:",
|
||||||
"spotify:"
|
"spotify:",
|
||||||
|
"com.epicgames.launcher:",
|
||||||
];
|
];
|
||||||
|
|
||||||
export const IS_VANILLA = /* @__PURE__ */ process.argv.includes("--vanilla");
|
export const IS_VANILLA = /* @__PURE__ */ process.argv.includes("--vanilla");
|
||||||
|
@ -24,15 +24,13 @@ import { Heart } from "@components/Heart";
|
|||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { Logger } from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
|
import { isPluginDev } from "@utils/misc";
|
||||||
import { closeModal, Modals, openModal } from "@utils/modal";
|
import { closeModal, Modals, openModal } from "@utils/modal";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { Forms, Toasts } from "@webpack/common";
|
import { Forms, Toasts } from "@webpack/common";
|
||||||
|
|
||||||
const CONTRIBUTOR_BADGE = "https://cdn.discordapp.com/attachments/1033680203433660458/1092089947126780035/favicon.png";
|
const CONTRIBUTOR_BADGE = "https://cdn.discordapp.com/attachments/1033680203433660458/1092089947126780035/favicon.png";
|
||||||
|
|
||||||
/** List of vencord contributor IDs */
|
|
||||||
const contributorIds: string[] = Object.values(Devs).map(d => d.id.toString());
|
|
||||||
|
|
||||||
const ContributorBadge: ProfileBadge = {
|
const ContributorBadge: ProfileBadge = {
|
||||||
description: "Vencord Contributor",
|
description: "Vencord Contributor",
|
||||||
image: CONTRIBUTOR_BADGE,
|
image: CONTRIBUTOR_BADGE,
|
||||||
@ -43,7 +41,7 @@ const ContributorBadge: ProfileBadge = {
|
|||||||
transform: "scale(0.9)" // The image is a bit too big compared to default badges
|
transform: "scale(0.9)" // The image is a bit too big compared to default badges
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
shouldShow: ({ user }) => contributorIds.includes(user.id),
|
shouldShow: ({ user }) => isPluginDev(user.id),
|
||||||
link: "https://github.com/Vendicated/Vencord"
|
link: "https://github.com/Vendicated/Vencord"
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -82,8 +80,8 @@ export default definePlugin({
|
|||||||
find: "Messages.PROFILE_USER_BADGES,role:",
|
find: "Messages.PROFILE_USER_BADGES,role:",
|
||||||
replacement: [
|
replacement: [
|
||||||
{
|
{
|
||||||
match: /(?<=(\i)\.isTryItOutFlow,)(.{0,300})null==\i\?void 0:(\i)\.getBadges\(\)/,
|
match: /&&(\i)\.push\(\{id:"premium".+?\}\);/,
|
||||||
replace: (_, props, restCode, badgesMod) => `vencordProps=${props},${restCode}Vencord.Api.Badges._getBadges(vencordProps).concat(${badgesMod}?.getBadges()??[])`,
|
replace: "$&$1.unshift(...Vencord.Api.Badges._getBadges(arguments[0]));",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// alt: "", aria-hidden: false, src: originalSrc
|
// alt: "", aria-hidden: false, src: originalSrc
|
@ -82,6 +82,8 @@ export default definePlugin({
|
|||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
|
|
||||||
|
customSections: [] as ((ID: Record<string, unknown>) => any)[],
|
||||||
|
|
||||||
makeSettingsCategories({ ID }: { ID: Record<string, unknown>; }) {
|
makeSettingsCategories({ ID }: { ID: Record<string, unknown>; }) {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@ -123,11 +125,13 @@ export default definePlugin({
|
|||||||
label: "Patch Helper",
|
label: "Patch Helper",
|
||||||
element: require("@components/VencordSettings/PatchHelperTab").default,
|
element: require("@components/VencordSettings/PatchHelperTab").default,
|
||||||
},
|
},
|
||||||
|
// TODO: make this use customSections
|
||||||
IS_VENCORD_DESKTOP && {
|
IS_VENCORD_DESKTOP && {
|
||||||
section: "VencordDesktop",
|
section: "VencordDesktop",
|
||||||
label: "Desktop Settings",
|
label: "Desktop Settings",
|
||||||
element: VencordDesktop.Components.Settings,
|
element: VencordDesktop.Components.Settings,
|
||||||
},
|
},
|
||||||
|
...this.customSections.map(func => func(ID)),
|
||||||
{
|
{
|
||||||
section: ID.DIVIDER
|
section: ID.DIVIDER
|
||||||
}
|
}
|
@ -20,7 +20,7 @@ import { Settings } from "@api/Settings";
|
|||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
|
||||||
enum Methods {
|
const enum Methods {
|
||||||
Random,
|
Random,
|
||||||
Consistent,
|
Consistent,
|
||||||
Timestamp,
|
Timestamp,
|
||||||
|
@ -104,6 +104,6 @@ export default definePlugin({
|
|||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
FluxDispatcher.dispatch({ type: "LOCAL_ACTIVITY_UPDATE", activity: null }); // clear status
|
FluxDispatcher.dispatch({ type: "LOCAL_ACTIVITY_UPDATE", activity: null }); // clear status
|
||||||
ws.close(); // close WebSocket
|
ws?.close(); // close WebSocket
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -36,7 +36,8 @@ function Guilds(props: {
|
|||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
const res = Vencord.Plugins.plugins.BetterFolders.Guilds(props);
|
const res = Vencord.Plugins.plugins.BetterFolders.Guilds(props);
|
||||||
|
|
||||||
const scrollerProps = res.props.children?.props?.children?.[1]?.props;
|
// TODO: Make this better
|
||||||
|
const scrollerProps = res.props.children?.props?.children?.props?.children?.[1]?.props;
|
||||||
if (scrollerProps?.children) {
|
if (scrollerProps?.children) {
|
||||||
const servers = scrollerProps.children.find(c => c?.props?.["aria-label"] === i18n.Messages.SERVERS);
|
const servers = scrollerProps.children.find(c => c?.props?.["aria-label"] === i18n.Messages.SERVERS);
|
||||||
if (servers) scrollerProps.children = servers;
|
if (servers) scrollerProps.children = servers;
|
||||||
|
100
src/plugins/biggerStreamPreview/index.tsx
Normal file
100
src/plugins/biggerStreamPreview/index.tsx
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
/*
|
||||||
|
* Vencord, a modification for Discord's desktop app
|
||||||
|
* Copyright (c) 2023 Vendicated and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
|
||||||
|
import { ScreenshareIcon } from "@components/Icons";
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
|
import { openImageModal } from "@utils/discord";
|
||||||
|
import definePlugin from "@utils/types";
|
||||||
|
import { Menu } from "@webpack/common";
|
||||||
|
import { Channel, User } from "discord-types/general";
|
||||||
|
|
||||||
|
import { ApplicationStreamingStore, ApplicationStreamPreviewStore } from "./webpack/stores";
|
||||||
|
import { ApplicationStream, Stream } from "./webpack/types/stores";
|
||||||
|
|
||||||
|
export interface UserContextProps {
|
||||||
|
channel: Channel,
|
||||||
|
channelSelected: boolean,
|
||||||
|
className: string,
|
||||||
|
config: { context: string; };
|
||||||
|
context: string,
|
||||||
|
onHeightUpdate: Function,
|
||||||
|
position: string,
|
||||||
|
target: HTMLElement,
|
||||||
|
theme: string,
|
||||||
|
user: User;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StreamContextProps {
|
||||||
|
appContext: string,
|
||||||
|
className: string,
|
||||||
|
config: { context: string; };
|
||||||
|
context: string,
|
||||||
|
exitFullscreen: Function,
|
||||||
|
onHeightUpdate: Function,
|
||||||
|
position: string,
|
||||||
|
target: HTMLElement,
|
||||||
|
stream: Stream,
|
||||||
|
theme: string,
|
||||||
|
}
|
||||||
|
|
||||||
|
export const handleViewPreview = async ({ guildId, channelId, ownerId }: ApplicationStream | Stream) => {
|
||||||
|
const previewUrl = await ApplicationStreamPreviewStore.getPreviewURL(guildId, channelId, ownerId);
|
||||||
|
if (!previewUrl) return;
|
||||||
|
|
||||||
|
openImageModal(previewUrl);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const addViewStreamContext: NavContextMenuPatchCallback = (children, { userId }: { userId: string | bigint; }) => () => {
|
||||||
|
const stream = ApplicationStreamingStore.getAnyStreamForUser(userId);
|
||||||
|
if (!stream) return;
|
||||||
|
|
||||||
|
const streamPreviewItem = (
|
||||||
|
<Menu.MenuItem
|
||||||
|
label="View Stream Preview"
|
||||||
|
id="view-stream-preview"
|
||||||
|
icon={ScreenshareIcon}
|
||||||
|
action={() => stream && handleViewPreview(stream)}
|
||||||
|
disabled={!stream}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
children.push(<Menu.MenuSeparator />, streamPreviewItem);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const streamContextPatch: NavContextMenuPatchCallback = (children, { stream }: StreamContextProps) => {
|
||||||
|
return addViewStreamContext(children, { userId: stream.ownerId });
|
||||||
|
};
|
||||||
|
|
||||||
|
export const userContextPatch: NavContextMenuPatchCallback = (children, { user }: UserContextProps) => {
|
||||||
|
return addViewStreamContext(children, { userId: user.id });
|
||||||
|
};
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "BiggerStreamPreview",
|
||||||
|
description: "This plugin allows you to enlarge stream previews",
|
||||||
|
authors: [Devs.phil],
|
||||||
|
start: () => {
|
||||||
|
addContextMenuPatch("user-context", userContextPatch);
|
||||||
|
addContextMenuPatch("stream-context", streamContextPatch);
|
||||||
|
},
|
||||||
|
stop: () => {
|
||||||
|
removeContextMenuPatch("user-context", userContextPatch);
|
||||||
|
removeContextMenuPatch("stream-context", streamContextPatch);
|
||||||
|
}
|
||||||
|
});
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Vencord, a modification for Discord's desktop app
|
* Vencord, a modification for Discord's desktop app
|
||||||
* Copyright (c) 2022 Vendicated and contributors
|
* Copyright (c) 2023 Vendicated and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -16,20 +16,10 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Badge } from "./Badge";
|
|
||||||
|
|
||||||
export interface Sender {
|
import { findStoreLazy } from "@webpack";
|
||||||
id : number,
|
|
||||||
discordID: string,
|
|
||||||
username: string,
|
|
||||||
profilePhoto: string,
|
|
||||||
badges: Badge[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Review {
|
import * as t from "./types/stores";
|
||||||
comment: string,
|
|
||||||
id: number,
|
export const ApplicationStreamPreviewStore: t.ApplicationStreamPreviewStore = findStoreLazy("ApplicationStreamPreviewStore");
|
||||||
star: number,
|
export const ApplicationStreamingStore: t.ApplicationStreamingStore = findStoreLazy("ApplicationStreamingStore");
|
||||||
sender: Sender,
|
|
||||||
timestamp: number
|
|
||||||
}
|
|
77
src/plugins/biggerStreamPreview/webpack/types/stores.ts
Normal file
77
src/plugins/biggerStreamPreview/webpack/types/stores.ts
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* Vencord, a modification for Discord's desktop app
|
||||||
|
* Copyright (c) 2023 Vendicated and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { FluxStore } from "@webpack/types";
|
||||||
|
|
||||||
|
export interface ApplicationStreamPreviewStore extends FluxStore {
|
||||||
|
getIsPreviewLoading: (guildId: string | bigint | null, channelId: string | bigint, ownerId: string | bigint) => boolean;
|
||||||
|
getPreviewURL: (guildId: string | bigint | null, channelId: string | bigint, ownerId: string | bigint) => Promise<string | null>;
|
||||||
|
getPreviewURLForStreamKey: (streamKey: string) => ReturnType<ApplicationStreamPreviewStore["getPreviewURL"]>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ApplicationStream {
|
||||||
|
streamType: string;
|
||||||
|
guildId: string | null;
|
||||||
|
channelId: string;
|
||||||
|
ownerId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Stream extends ApplicationStream {
|
||||||
|
state: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RTCStream {
|
||||||
|
region: string,
|
||||||
|
streamKey: string,
|
||||||
|
viewerIds: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StreamMetadata {
|
||||||
|
id: string | null,
|
||||||
|
pid: number | null,
|
||||||
|
sourceName: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StreamingStoreState {
|
||||||
|
activeStreams: [string, Stream][];
|
||||||
|
rtcStreams: { [key: string]: RTCStream; };
|
||||||
|
streamerActiveStreamMetadatas: { [key: string]: StreamMetadata | null; };
|
||||||
|
streamsByUserAndGuild: { [key: string]: { [key: string]: ApplicationStream; }; };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* example how a stream key could look like: `call(type of connection):1116549917987192913(channelId):305238513941667851(ownerId)`
|
||||||
|
*/
|
||||||
|
export interface ApplicationStreamingStore extends FluxStore {
|
||||||
|
getActiveStreamForApplicationStream: (stream: ApplicationStream) => Stream | null;
|
||||||
|
getActiveStreamForStreamKey: (streamKey: string) => Stream | null;
|
||||||
|
getActiveStreamForUser: (userId: string | bigint, guildId?: string | bigint | null) => Stream | null;
|
||||||
|
getAllActiveStreams: () => Stream[];
|
||||||
|
getAllApplicationStreams: () => ApplicationStream[];
|
||||||
|
getAllApplicationStreamsForChannel: (channelId: string | bigint) => ApplicationStream[];
|
||||||
|
getAllActiveStreamsForChannel: (channelId: string | bigint) => Stream[];
|
||||||
|
getAnyStreamForUser: (userId: string | bigint) => Stream | ApplicationStream | null;
|
||||||
|
getStreamForUser: (userId: string | bigint, guildId?: string | bigint | null) => Stream | null;
|
||||||
|
getCurrentUserActiveStream: () => Stream | null;
|
||||||
|
getLastActiveStream: () => Stream | null;
|
||||||
|
getState: () => StreamingStoreState;
|
||||||
|
getRTCStream: (streamKey: string) => RTCStream | null;
|
||||||
|
getStreamerActiveStreamMetadata: () => StreamMetadata;
|
||||||
|
getViewerIds: (stream: ApplicationStream) => string[];
|
||||||
|
isSelfStreamHidden: (channelId: string | bigint | null) => boolean;
|
||||||
|
}
|
@ -74,7 +74,7 @@ interface Activity {
|
|||||||
flags: number;
|
flags: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ActivityType {
|
const enum ActivityType {
|
||||||
PLAYING = 0,
|
PLAYING = 0,
|
||||||
LISTENING = 2,
|
LISTENING = 2,
|
||||||
WATCHING = 3,
|
WATCHING = 3,
|
||||||
|
@ -24,12 +24,11 @@ import { Margins } from "@utils/margins";
|
|||||||
import { ModalContent, ModalHeader, ModalRoot, openModalLazy } from "@utils/modal";
|
import { ModalContent, ModalHeader, ModalRoot, openModalLazy } from "@utils/modal";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByCodeLazy, findStoreLazy } from "@webpack";
|
import { findByCodeLazy, findStoreLazy } from "@webpack";
|
||||||
import { FluxDispatcher, Forms, GuildStore, Menu, PermissionStore, React, RestAPI, Toasts, Tooltip, UserStore } from "@webpack/common";
|
import { EmojiStore, FluxDispatcher, Forms, GuildStore, Menu, PermissionStore, React, RestAPI, Toasts, Tooltip, UserStore } from "@webpack/common";
|
||||||
import { Promisable } from "type-fest";
|
import { Promisable } from "type-fest";
|
||||||
|
|
||||||
const MANAGE_EMOJIS_AND_STICKERS = 1n << 30n;
|
const MANAGE_EMOJIS_AND_STICKERS = 1n << 30n;
|
||||||
|
|
||||||
const GuildEmojiStore = findStoreLazy("EmojiStore");
|
|
||||||
const StickersStore = findStoreLazy("StickersStore");
|
const StickersStore = findStoreLazy("StickersStore");
|
||||||
const uploadEmoji = findByCodeLazy('"EMOJI_UPLOAD_START"', "GUILD_EMOJIS(");
|
const uploadEmoji = findByCodeLazy('"EMOJI_UPLOAD_START"', "GUILD_EMOJIS(");
|
||||||
|
|
||||||
@ -129,7 +128,7 @@ function getGuildCandidates(data: Data) {
|
|||||||
const { isAnimated } = data as Emoji;
|
const { isAnimated } = data as Emoji;
|
||||||
|
|
||||||
const emojiSlots = g.getMaxEmojiSlots();
|
const emojiSlots = g.getMaxEmojiSlots();
|
||||||
const { emojis } = GuildEmojiStore.getGuilds()[g.id];
|
const { emojis } = EmojiStore.getGuilds()[g.id];
|
||||||
|
|
||||||
let count = 0;
|
let count = 0;
|
||||||
for (const emoji of emojis)
|
for (const emoji of emojis)
|
||||||
@ -194,7 +193,8 @@ function CloneModal({ data }: { data: Sticker | Emoji; }) {
|
|||||||
setName(v);
|
setName(v);
|
||||||
}}
|
}}
|
||||||
validate={v =>
|
validate={v =>
|
||||||
(v.length > 1 && v.length < 32 && nameValidator.test(v))
|
(data.t === "Emoji" && v.length > 2 && v.length < 32 && nameValidator.test(v))
|
||||||
|
|| (data.t === "Sticker" && v.length > 2 && v.length < 30)
|
||||||
|| "Name must be between 2 and 32 characters and only contain alphanumeric characters"
|
|| "Name must be between 2 and 32 characters and only contain alphanumeric characters"
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
@ -22,11 +22,12 @@ import { Devs } from "@utils/constants";
|
|||||||
import { ApngBlendOp, ApngDisposeOp, getGifEncoder, importApngJs } from "@utils/dependencies";
|
import { ApngBlendOp, ApngDisposeOp, getGifEncoder, importApngJs } from "@utils/dependencies";
|
||||||
import { getCurrentGuild } from "@utils/discord";
|
import { getCurrentGuild } from "@utils/discord";
|
||||||
import { proxyLazy } from "@utils/lazy";
|
import { proxyLazy } from "@utils/lazy";
|
||||||
|
import { Logger } from "@utils/Logger";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByCodeLazy, findByPropsLazy, findLazy, findStoreLazy } from "@webpack";
|
import { findByCodeLazy, findByPropsLazy, findLazy, findStoreLazy } from "@webpack";
|
||||||
import { ChannelStore, FluxDispatcher, Parser, PermissionStore, UserStore } from "@webpack/common";
|
import { ChannelStore, EmojiStore, FluxDispatcher, Parser, PermissionStore, UserStore } from "@webpack/common";
|
||||||
import type { Message } from "discord-types/general";
|
import type { Message } from "discord-types/general";
|
||||||
import type { ReactNode } from "react";
|
import type { ReactElement, ReactNode } from "react";
|
||||||
|
|
||||||
const DRAFT_TYPE = 0;
|
const DRAFT_TYPE = 0;
|
||||||
const promptToUpload = findByCodeLazy("UPLOAD_FILE_LIMIT_ERROR");
|
const promptToUpload = findByCodeLazy("UPLOAD_FILE_LIMIT_ERROR");
|
||||||
@ -38,8 +39,6 @@ const StickerStore = findStoreLazy("StickersStore") as {
|
|||||||
getAllGuildStickers(): Map<string, Sticker[]>;
|
getAllGuildStickers(): Map<string, Sticker[]>;
|
||||||
getStickerById(id: string): Sticker | undefined;
|
getStickerById(id: string): Sticker | undefined;
|
||||||
};
|
};
|
||||||
const EmojiStore = findStoreLazy("EmojiStore");
|
|
||||||
|
|
||||||
|
|
||||||
function searchProtoClass(localName: string, parentProtoClass: any) {
|
function searchProtoClass(localName: string, parentProtoClass: any) {
|
||||||
if (!parentProtoClass) return;
|
if (!parentProtoClass) return;
|
||||||
@ -57,7 +56,7 @@ const ClientThemeSettingsProto = proxyLazy(() => searchProtoClass("clientThemeSe
|
|||||||
const USE_EXTERNAL_EMOJIS = 1n << 18n;
|
const USE_EXTERNAL_EMOJIS = 1n << 18n;
|
||||||
const USE_EXTERNAL_STICKERS = 1n << 37n;
|
const USE_EXTERNAL_STICKERS = 1n << 37n;
|
||||||
|
|
||||||
enum EmojiIntentions {
|
const enum EmojiIntentions {
|
||||||
REACTION = 0,
|
REACTION = 0,
|
||||||
STATUS = 1,
|
STATUS = 1,
|
||||||
COMMUNITY_CONTENT = 2,
|
COMMUNITY_CONTENT = 2,
|
||||||
@ -68,6 +67,14 @@ enum EmojiIntentions {
|
|||||||
SOUNDBOARD = 7
|
SOUNDBOARD = 7
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const enum StickerType {
|
||||||
|
PNG = 1,
|
||||||
|
APNG = 2,
|
||||||
|
LOTTIE = 3,
|
||||||
|
// don't think you can even have gif stickers but the docs have it
|
||||||
|
GIF = 4
|
||||||
|
}
|
||||||
|
|
||||||
interface BaseSticker {
|
interface BaseSticker {
|
||||||
available: boolean;
|
available: boolean;
|
||||||
description: string;
|
description: string;
|
||||||
@ -173,6 +180,10 @@ export default definePlugin({
|
|||||||
{
|
{
|
||||||
match: /(&&!\i&&)!(\i)(?=\)return \i\.\i\.DISALLOW_EXTERNAL;)/,
|
match: /(&&!\i&&)!(\i)(?=\)return \i\.\i\.DISALLOW_EXTERNAL;)/,
|
||||||
replace: (_, rest, canUseExternal) => `${rest}(!${canUseExternal}&&(typeof fakeNitroIntention==="undefined"||![${EmojiIntentions.CHAT},${EmojiIntentions.GUILD_STICKER_RELATED_EMOJI}].includes(fakeNitroIntention)))`
|
replace: (_, rest, canUseExternal) => `${rest}(!${canUseExternal}&&(typeof fakeNitroIntention==="undefined"||![${EmojiIntentions.CHAT},${EmojiIntentions.GUILD_STICKER_RELATED_EMOJI}].includes(fakeNitroIntention)))`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
match: /if\(!\i\.available/,
|
||||||
|
replace: m => `${m}&&(typeof fakeNitroIntention==="undefined"||![${EmojiIntentions.CHAT},${EmojiIntentions.GUILD_STICKER_RELATED_EMOJI}].includes(fakeNitroIntention))`
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -321,7 +332,7 @@ export default definePlugin({
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleProtoChange(proto: any, user: any) {
|
handleProtoChange(proto: any, user: any) {
|
||||||
if ((!proto.appearance && !AppearanceSettingsProto) || !UserSettingsProtoStore) return;
|
if (proto == null || typeof proto === "string" || !UserSettingsProtoStore || (!proto.appearance && !AppearanceSettingsProto)) return;
|
||||||
|
|
||||||
const premiumType: number = user?.premium_type ?? UserStore?.getCurrentUser()?.premiumType ?? 0;
|
const premiumType: number = user?.premium_type ?? UserStore?.getCurrentUser()?.premiumType ?? 0;
|
||||||
|
|
||||||
@ -382,70 +393,137 @@ export default definePlugin({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
patchFakeNitroEmojisOrRemoveStickersLinks(content: Array<any>, inline: boolean) {
|
trimContent(content: Array<any>) {
|
||||||
if (content.length > 1 && !settings.store.transformCompoundSentence) return content;
|
const firstContent = content[0];
|
||||||
|
if (typeof firstContent === "string") content[0] = firstContent.trimStart();
|
||||||
|
if (content[0] === "") content.shift();
|
||||||
|
|
||||||
const newContent: Array<any> = [];
|
const lastIndex = content.length - 1;
|
||||||
|
const lastContent = content[lastIndex];
|
||||||
|
if (typeof lastContent === "string") content[lastIndex] = lastContent.trimEnd();
|
||||||
|
if (content[lastIndex] === "") content.pop();
|
||||||
|
},
|
||||||
|
|
||||||
|
clearEmptyArrayItems(array: Array<any>) {
|
||||||
|
return array.filter(item => item != null);
|
||||||
|
},
|
||||||
|
|
||||||
|
ensureChildrenIsArray(child: ReactElement) {
|
||||||
|
if (!Array.isArray(child.props.children)) child.props.children = [child.props.children];
|
||||||
|
},
|
||||||
|
|
||||||
|
patchFakeNitroEmojisOrRemoveStickersLinks(content: Array<any>, inline: boolean) {
|
||||||
|
// If content has more than one child or it's a single ReactElement like a header or list
|
||||||
|
if ((content.length > 1 || typeof content[0]?.type === "string") && !settings.store.transformCompoundSentence) return content;
|
||||||
|
|
||||||
let nextIndex = content.length;
|
let nextIndex = content.length;
|
||||||
|
|
||||||
for (const element of content) {
|
const transformLinkChild = (child: ReactElement) => {
|
||||||
if (element.props?.trusted == null) {
|
|
||||||
newContent.push(element);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (settings.store.transformEmojis) {
|
if (settings.store.transformEmojis) {
|
||||||
const fakeNitroMatch = element.props.href.match(fakeNitroEmojiRegex);
|
const fakeNitroMatch = child.props.href.match(fakeNitroEmojiRegex);
|
||||||
if (fakeNitroMatch) {
|
if (fakeNitroMatch) {
|
||||||
let url: URL | null = null;
|
let url: URL | null = null;
|
||||||
try {
|
try {
|
||||||
url = new URL(element.props.href);
|
url = new URL(child.props.href);
|
||||||
} catch { }
|
} catch { }
|
||||||
|
|
||||||
const emojiName = EmojiStore.getCustomEmojiById(fakeNitroMatch[1])?.name ?? url?.searchParams.get("name") ?? "FakeNitroEmoji";
|
const emojiName = EmojiStore.getCustomEmojiById(fakeNitroMatch[1])?.name ?? url?.searchParams.get("name") ?? "FakeNitroEmoji";
|
||||||
|
|
||||||
newContent.push(Parser.defaultRules.customEmoji.react({
|
return Parser.defaultRules.customEmoji.react({
|
||||||
jumboable: !inline && content.length === 1,
|
jumboable: !inline && content.length === 1 && typeof content[0].type !== "string",
|
||||||
animated: fakeNitroMatch[2] === "gif",
|
animated: fakeNitroMatch[2] === "gif",
|
||||||
emojiId: fakeNitroMatch[1],
|
emojiId: fakeNitroMatch[1],
|
||||||
name: emojiName,
|
name: emojiName,
|
||||||
fake: true
|
fake: true
|
||||||
}, void 0, { key: String(nextIndex++) }));
|
}, void 0, { key: String(nextIndex++) });
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.store.transformStickers) {
|
if (settings.store.transformStickers) {
|
||||||
if (fakeNitroStickerRegex.test(element.props.href)) continue;
|
if (fakeNitroStickerRegex.test(child.props.href)) return null;
|
||||||
|
|
||||||
const gifMatch = element.props.href.match(fakeNitroGifStickerRegex);
|
const gifMatch = child.props.href.match(fakeNitroGifStickerRegex);
|
||||||
if (gifMatch) {
|
if (gifMatch) {
|
||||||
// There is no way to differentiate a regular gif attachment from a fake nitro animated sticker, so we check if the StickerStore contains the id of the fake sticker
|
// There is no way to differentiate a regular gif attachment from a fake nitro animated sticker, so we check if the StickerStore contains the id of the fake sticker
|
||||||
if (StickerStore.getStickerById(gifMatch[1])) continue;
|
if (StickerStore.getStickerById(gifMatch[1])) return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newContent.push(element);
|
return child;
|
||||||
|
};
|
||||||
|
|
||||||
|
const transformChild = (child: ReactElement) => {
|
||||||
|
if (child?.props?.trusted != null) return transformLinkChild(child);
|
||||||
|
if (child?.props?.children != null) {
|
||||||
|
if (!Array.isArray(child.props.children)) {
|
||||||
|
child.props.children = modifyChild(child.props.children);
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
|
||||||
|
child.props.children = modifyChildren(child.props.children);
|
||||||
|
if (child.props.children.length === 0) return null;
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
|
||||||
|
return child;
|
||||||
|
};
|
||||||
|
|
||||||
|
const modifyChild = (child: ReactElement) => {
|
||||||
|
const newChild = transformChild(child);
|
||||||
|
|
||||||
|
if (newChild?.type === "ul" || newChild?.type === "ol") {
|
||||||
|
this.ensureChildrenIsArray(newChild);
|
||||||
|
if (newChild.props.children.length === 0) return null;
|
||||||
|
|
||||||
|
let listHasAnItem = false;
|
||||||
|
for (const [index, child] of newChild.props.children.entries()) {
|
||||||
|
if (child == null) {
|
||||||
|
delete newChild.props.children[index];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.ensureChildrenIsArray(child);
|
||||||
|
if (child.props.children.length > 0) listHasAnItem = true;
|
||||||
|
else delete newChild.props.children[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!listHasAnItem) return null;
|
||||||
|
|
||||||
|
newChild.props.children = this.clearEmptyArrayItems(newChild.props.children);
|
||||||
|
}
|
||||||
|
|
||||||
|
return newChild;
|
||||||
|
};
|
||||||
|
|
||||||
|
const modifyChildren = (children: Array<ReactElement>) => {
|
||||||
|
for (const [index, child] of children.entries()) children[index] = modifyChild(child);
|
||||||
|
|
||||||
|
children = this.clearEmptyArrayItems(children);
|
||||||
|
this.trimContent(children);
|
||||||
|
|
||||||
|
return children;
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
return modifyChildren(window._.cloneDeep(content));
|
||||||
|
} catch (err) {
|
||||||
|
new Logger("FakeNitro").error(err);
|
||||||
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
const firstContent = newContent[0];
|
|
||||||
if (typeof firstContent === "string") newContent[0] = firstContent.trimStart();
|
|
||||||
|
|
||||||
return newContent;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
patchFakeNitroStickers(stickers: Array<any>, message: Message) {
|
patchFakeNitroStickers(stickers: Array<any>, message: Message) {
|
||||||
const itemsToMaybePush: Array<string> = [];
|
const itemsToMaybePush: Array<string> = [];
|
||||||
|
|
||||||
const contentItems = message.content.split(/\s/);
|
const contentItems = message.content.split(/\s/);
|
||||||
if (contentItems.length === 1 && !settings.store.transformCompoundSentence) itemsToMaybePush.push(contentItems[0]);
|
if (settings.store.transformCompoundSentence) itemsToMaybePush.push(...contentItems);
|
||||||
else itemsToMaybePush.push(...contentItems);
|
else if (contentItems.length === 1) itemsToMaybePush.push(contentItems[0]);
|
||||||
|
|
||||||
itemsToMaybePush.push(...message.attachments.filter(attachment => attachment.content_type === "image/gif").map(attachment => attachment.url));
|
itemsToMaybePush.push(...message.attachments.filter(attachment => attachment.content_type === "image/gif").map(attachment => attachment.url));
|
||||||
|
|
||||||
for (const item of itemsToMaybePush) {
|
for (const item of itemsToMaybePush) {
|
||||||
|
if (!settings.store.transformCompoundSentence && !item.startsWith("http")) continue;
|
||||||
|
|
||||||
const imgMatch = item.match(fakeNitroStickerRegex);
|
const imgMatch = item.match(fakeNitroStickerRegex);
|
||||||
if (imgMatch) {
|
if (imgMatch) {
|
||||||
let url: URL | null = null;
|
let url: URL | null = null;
|
||||||
@ -482,10 +560,13 @@ export default definePlugin({
|
|||||||
},
|
},
|
||||||
|
|
||||||
shouldIgnoreEmbed(embed: Message["embeds"][number], message: Message) {
|
shouldIgnoreEmbed(embed: Message["embeds"][number], message: Message) {
|
||||||
if (message.content.split(/\s/).length > 1 && !settings.store.transformCompoundSentence) return false;
|
const contentItems = message.content.split(/\s/);
|
||||||
|
if (contentItems.length > 1 && !settings.store.transformCompoundSentence) return false;
|
||||||
|
|
||||||
switch (embed.type) {
|
switch (embed.type) {
|
||||||
case "image": {
|
case "image": {
|
||||||
|
if (!settings.store.transformCompoundSentence && !contentItems.includes(embed.url!) && !contentItems.includes(embed.image!.proxyURL)) return false;
|
||||||
|
|
||||||
if (settings.store.transformEmojis) {
|
if (settings.store.transformEmojis) {
|
||||||
if (fakeNitroEmojiRegex.test(embed.url!)) return true;
|
if (fakeNitroEmojiRegex.test(embed.url!)) return true;
|
||||||
}
|
}
|
||||||
@ -544,7 +625,7 @@ export default definePlugin({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
hasPermissionToUseExternalEmojis(channelId: string) {
|
hasPermissionToUseExternalEmojis(channelId: string): boolean {
|
||||||
const channel = ChannelStore.getChannel(channelId);
|
const channel = ChannelStore.getChannel(channelId);
|
||||||
|
|
||||||
if (!channel || channel.isDM() || channel.isGroupDM() || channel.isMultiUserDM()) return true;
|
if (!channel || channel.isDM() || channel.isGroupDM() || channel.isMultiUserDM()) return true;
|
||||||
@ -625,8 +706,9 @@ export default definePlugin({
|
|||||||
},
|
},
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
const settings = Settings.plugins.FakeNitro;
|
const s = settings.store;
|
||||||
if (!settings.enableEmojiBypass && !settings.enableStickerBypass) {
|
|
||||||
|
if (!s.enableEmojiBypass && !s.enableStickerBypass) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -638,39 +720,37 @@ export default definePlugin({
|
|||||||
const { guildId } = this;
|
const { guildId } = this;
|
||||||
|
|
||||||
stickerBypass: {
|
stickerBypass: {
|
||||||
if (!settings.enableStickerBypass)
|
if (!s.enableStickerBypass)
|
||||||
break stickerBypass;
|
break stickerBypass;
|
||||||
|
|
||||||
const sticker = StickerStore.getStickerById(extra.stickers?.[0]!);
|
const sticker = StickerStore.getStickerById(extra.stickers?.[0]!);
|
||||||
if (!sticker)
|
if (!sticker)
|
||||||
break stickerBypass;
|
break stickerBypass;
|
||||||
|
|
||||||
if (sticker.available !== false && ((this.canUseStickers && this.hasPermissionToUseExternalStickers(channelId)) || (sticker as GuildSticker)?.guild_id === guildId))
|
// Discord Stickers are now free yayyy!! :D
|
||||||
|
if ("pack_id" in sticker)
|
||||||
break stickerBypass;
|
break stickerBypass;
|
||||||
|
|
||||||
let link = this.getStickerLink(sticker.id);
|
const canUseStickers = this.canUseStickers && this.hasPermissionToUseExternalStickers(channelId);
|
||||||
if (sticker.format_type === 2) {
|
if (sticker.available !== false && (canUseStickers || sticker.guild_id === guildId))
|
||||||
|
break stickerBypass;
|
||||||
|
|
||||||
|
const link = this.getStickerLink(sticker.id);
|
||||||
|
if (sticker.format_type === StickerType.APNG) {
|
||||||
this.sendAnimatedSticker(link, sticker.id, channelId);
|
this.sendAnimatedSticker(link, sticker.id, channelId);
|
||||||
return { cancel: true };
|
return { cancel: true };
|
||||||
} else {
|
} else {
|
||||||
if ("pack_id" in sticker) {
|
|
||||||
const packId = sticker.pack_id === "847199849233514549"
|
|
||||||
// Discord moved these stickers into a different pack at some point, but
|
|
||||||
// Distok still uses the old id
|
|
||||||
? "749043879713701898"
|
|
||||||
: sticker.pack_id;
|
|
||||||
|
|
||||||
link = `https://distok.top/stickers/${packId}/${sticker.id}.gif`;
|
|
||||||
}
|
|
||||||
|
|
||||||
extra.stickers!.length = 0;
|
extra.stickers!.length = 0;
|
||||||
messageObj.content += " " + link + `&name=${encodeURIComponent(sticker.name)}`;
|
messageObj.content += ` ${link}&name=${encodeURIComponent(sticker.name)}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!this.canUseEmotes || !this.hasPermissionToUseExternalEmojis(channelId)) && settings.enableEmojiBypass) {
|
if (s.enableEmojiBypass) {
|
||||||
|
const canUseEmotes = this.canUseEmotes && this.hasPermissionToUseExternalEmojis(channelId);
|
||||||
|
|
||||||
for (const emoji of messageObj.validNonShortcutEmojis) {
|
for (const emoji of messageObj.validNonShortcutEmojis) {
|
||||||
if (!emoji.require_colons) continue;
|
if (!emoji.require_colons) continue;
|
||||||
|
if (emoji.available !== false && canUseEmotes) continue;
|
||||||
if (emoji.guildId === guildId && !emoji.animated) continue;
|
if (emoji.guildId === guildId && !emoji.animated) continue;
|
||||||
|
|
||||||
const emojiString = `<${emoji.animated ? "a" : ""}:${emoji.originalName || emoji.name}:${emoji.id}>`;
|
const emojiString = `<${emoji.animated ? "a" : ""}:${emoji.originalName || emoji.name}:${emoji.id}>`;
|
||||||
@ -688,23 +768,25 @@ export default definePlugin({
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.preEdit = addPreEditListener((channelId, __, messageObj) => {
|
this.preEdit = addPreEditListener((channelId, __, messageObj) => {
|
||||||
if (this.canUseEmotes && this.hasPermissionToUseExternalEmojis(channelId)) return;
|
if (!s.enableEmojiBypass) return;
|
||||||
|
|
||||||
|
const canUseEmotes = this.canUseEmotes && this.hasPermissionToUseExternalEmojis(channelId);
|
||||||
|
|
||||||
const { guildId } = this;
|
const { guildId } = this;
|
||||||
|
|
||||||
for (const [emojiStr, _, emojiId] of messageObj.content.matchAll(/(?<!\\)<a?:(\w+):(\d+)>/ig)) {
|
messageObj.content = messageObj.content.replace(/(?<!\\)<a?:(?:\w+):(\d+)>/ig, (emojiStr, emojiId, offset, origStr) => {
|
||||||
const emoji = EmojiStore.getCustomEmojiById(emojiId);
|
const emoji = EmojiStore.getCustomEmojiById(emojiId);
|
||||||
if (emoji == null || (emoji.guildId === guildId && !emoji.animated)) continue;
|
if (emoji == null) return emojiStr;
|
||||||
if (!emoji.require_colons) continue;
|
if (!emoji.require_colons) return emojiStr;
|
||||||
|
if (emoji.available !== false && canUseEmotes) return emojiStr;
|
||||||
|
if (emoji.guildId === guildId && !emoji.animated) return emojiStr;
|
||||||
|
|
||||||
const url = emoji.url.replace(/\?size=\d+/, "?" + new URLSearchParams({
|
const url = emoji.url.replace(/\?size=\d+/, "?" + new URLSearchParams({
|
||||||
size: Settings.plugins.FakeNitro.emojiSize,
|
size: Settings.plugins.FakeNitro.emojiSize,
|
||||||
name: encodeURIComponent(emoji.name)
|
name: encodeURIComponent(emoji.name)
|
||||||
}));
|
}));
|
||||||
messageObj.content = messageObj.content.replace(emojiStr, (match, offset, origStr) => {
|
return `${getWordBoundary(origStr, offset - 1)}${url}${getWordBoundary(origStr, offset + emojiStr.length)}`;
|
||||||
return `${getWordBoundary(origStr, offset - 1)}${url}${getWordBoundary(origStr, offset + match.length)}`;
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
* Vencord, a modification for Discord's desktop app
|
|
||||||
* Copyright (c) 2022 Vendicated and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { ApplicationCommandOptionType } from "@api/Commands";
|
|
||||||
import { Settings } from "@api/Settings";
|
|
||||||
import { makeRange } from "@components/PluginSettings/components";
|
|
||||||
import { Devs } from "@utils/constants";
|
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
|
||||||
|
|
||||||
export default definePlugin({
|
|
||||||
name: "Fart2",
|
|
||||||
authors: [Devs.Animal],
|
|
||||||
description: "Enable farting v2, a slash command that allows you to perform or request that someone perform a little toot.",
|
|
||||||
dependencies: ["CommandsAPI"],
|
|
||||||
commands: [{
|
|
||||||
name: "fart",
|
|
||||||
description: "A simple command in which you may either request that a user do a little toot for you, or conduct one yourself.",
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
type: ApplicationCommandOptionType.USER,
|
|
||||||
name: "user",
|
|
||||||
description: "A Discord™ user of which you would humbly request a toot from.",
|
|
||||||
required: false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
|
|
||||||
execute(args) {
|
|
||||||
const fart = new Audio("https://raw.githubusercontent.com/ItzOnlyAnimal/AliuPlugins/main/fart.mp3");
|
|
||||||
fart.volume = Settings.plugins.Fart2.volume;
|
|
||||||
fart.play();
|
|
||||||
|
|
||||||
return {
|
|
||||||
content: (args[0]) ? `<@${args[0].value}> fart` : "fart"
|
|
||||||
};
|
|
||||||
},
|
|
||||||
}],
|
|
||||||
options: {
|
|
||||||
volume: {
|
|
||||||
description: "how loud you wanna fart (aka volume)",
|
|
||||||
type: OptionType.SLIDER,
|
|
||||||
markers: makeRange(0, 1, 0.1),
|
|
||||||
default: 0.5,
|
|
||||||
stickToMarkers: false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
83
src/plugins/favEmojiFirst.ts
Normal file
83
src/plugins/favEmojiFirst.ts
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* Vencord, a modification for Discord's desktop app
|
||||||
|
* Copyright (c) 2023 Vendicated and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
|
import definePlugin from "@utils/types";
|
||||||
|
import { EmojiStore } from "@webpack/common";
|
||||||
|
import { Emoji } from "@webpack/types";
|
||||||
|
|
||||||
|
interface EmojiAutocompleteState {
|
||||||
|
query?: {
|
||||||
|
type: string;
|
||||||
|
typeInfo: {
|
||||||
|
sentinel: string;
|
||||||
|
};
|
||||||
|
results: {
|
||||||
|
emojis: Emoji[] & { sliceTo?: number; };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "FavoriteEmojiFirst",
|
||||||
|
authors: [Devs.Aria, Devs.Ven],
|
||||||
|
description: "Puts your favorite emoji first in the emoji autocomplete.",
|
||||||
|
patches: [
|
||||||
|
{
|
||||||
|
find: ".activeCommandOption",
|
||||||
|
replacement: [
|
||||||
|
{
|
||||||
|
// = someFunc(a.selectedIndex); ...trackEmojiSearch({ state: theState, isInPopoutExperimental: someBool })
|
||||||
|
match: /=\i\(\i\.selectedIndex\);(?=.+?state:(\i),isInPopoutExperiment:\i)/,
|
||||||
|
// self.sortEmojis(theState)
|
||||||
|
replace: "$&$self.sortEmojis($1);"
|
||||||
|
},
|
||||||
|
|
||||||
|
// set maxCount to Infinity so our sortEmojis callback gets the entire list, not just the first 10
|
||||||
|
// and remove Discord's emojiResult slice, storing the endIndex on the array for us to use later
|
||||||
|
{
|
||||||
|
// searchEmojis(...,maxCount: stuff) ... endEmojis = emojis.slice(0, maxCount - gifResults.length)
|
||||||
|
match: /,maxCount:(\i)(.+?)=(\i)\.slice\(0,(\1-\i\.length)\)/,
|
||||||
|
// ,maxCount:Infinity ... endEmojis = (emojis.sliceTo = n, emojis)
|
||||||
|
replace: ",maxCount:Infinity$2=($3.sliceTo=$4,$3)"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
sortEmojis({ query }: EmojiAutocompleteState) {
|
||||||
|
if (
|
||||||
|
query?.type !== "EMOJIS_AND_STICKERS"
|
||||||
|
|| query.typeInfo?.sentinel !== ":"
|
||||||
|
|| !query.results?.emojis?.length
|
||||||
|
) return;
|
||||||
|
|
||||||
|
const emojiContext = EmojiStore.getDisambiguatedEmojiContext();
|
||||||
|
|
||||||
|
query.results.emojis = query.results.emojis.sort((a, b) => {
|
||||||
|
const aIsFavorite = emojiContext.isFavoriteEmojiWithoutFetchingLatest(a);
|
||||||
|
const bIsFavorite = emojiContext.isFavoriteEmojiWithoutFetchingLatest(b);
|
||||||
|
|
||||||
|
if (aIsFavorite && !bIsFavorite) return -1;
|
||||||
|
|
||||||
|
if (!aIsFavorite && bIsFavorite) return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}).slice(0, query.results.emojis.sliceTo ?? 10);
|
||||||
|
}
|
||||||
|
});
|
@ -18,25 +18,15 @@
|
|||||||
|
|
||||||
import { get, set } from "@api/DataStore";
|
import { get, set } from "@api/DataStore";
|
||||||
import { addButton, removeButton } from "@api/MessagePopover";
|
import { addButton, removeButton } from "@api/MessagePopover";
|
||||||
|
import { ImageInvisible, ImageVisible } from "@components/Icons";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { ChannelStore, FluxDispatcher } from "@webpack/common";
|
import { ChannelStore } from "@webpack/common";
|
||||||
|
|
||||||
let style: HTMLStyleElement;
|
let style: HTMLStyleElement;
|
||||||
|
|
||||||
const KEY = "HideAttachments_HiddenIds";
|
const KEY = "HideAttachments_HiddenIds";
|
||||||
|
|
||||||
const ImageVisible = () => (
|
|
||||||
<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
|
|
||||||
<path d="M5 21q-.825 0-1.413-.587Q3 19.825 3 19V5q0-.825.587-1.413Q4.175 3 5 3h14q.825 0 1.413.587Q21 4.175 21 5v14q0 .825-.587 1.413Q19.825 21 19 21Zm0-2h14V5H5v14Zm1-2h12l-3.75-5-3 4L9 13Zm-1 2V5v14Z" />
|
|
||||||
</svg>
|
|
||||||
);
|
|
||||||
const ImageInvisible = () => (
|
|
||||||
<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
|
|
||||||
<path d="m21 18.15-2-2V5H7.85l-2-2H19q.825 0 1.413.587Q21 4.175 21 5Zm-1.2 4.45L18.2 21H5q-.825 0-1.413-.587Q3 19.825 3 19V5.8L1.4 4.2l1.4-1.4 18.4 18.4ZM6 17l3-4 2.25 3 .825-1.1L5 7.825V19h11.175l-2-2Zm7.425-6.425ZM10.6 13.4Z" />
|
|
||||||
</svg>
|
|
||||||
);
|
|
||||||
|
|
||||||
let hiddenMessages: Set<string> = new Set();
|
let hiddenMessages: Set<string> = new Set();
|
||||||
const getHiddenMessages = () => get(KEY).then(set => {
|
const getHiddenMessages = () => get(KEY).then(set => {
|
||||||
hiddenMessages = set ?? new Set<string>();
|
hiddenMessages = set ?? new Set<string>();
|
||||||
@ -101,11 +91,5 @@ export default definePlugin({
|
|||||||
|
|
||||||
await saveHiddenMessages(ids);
|
await saveHiddenMessages(ids);
|
||||||
await this.buildCss();
|
await this.buildCss();
|
||||||
|
|
||||||
// update is necessary to rerender the PopOver
|
|
||||||
FluxDispatcher.dispatch({
|
|
||||||
type: "MESSAGE_UPDATE",
|
|
||||||
message: { id }
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -24,7 +24,7 @@ import definePlugin from "@utils/types";
|
|||||||
import { findByPropsLazy, findStoreLazy } from "@webpack";
|
import { findByPropsLazy, findStoreLazy } from "@webpack";
|
||||||
import { Tooltip } from "webpack/common";
|
import { Tooltip } from "webpack/common";
|
||||||
|
|
||||||
enum ActivitiesTypes {
|
const enum ActivitiesTypes {
|
||||||
Game,
|
Game,
|
||||||
Embedded
|
Embedded
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ function ToggleIconOff() {
|
|||||||
className={RegisteredGamesClasses.overlayToggleIconOff}
|
className={RegisteredGamesClasses.overlayToggleIconOff}
|
||||||
height="24"
|
height="24"
|
||||||
width="24"
|
width="24"
|
||||||
viewBox="0 0 32 26"
|
viewBox="0 2.2 32 26"
|
||||||
aria-hidden={true}
|
aria-hidden={true}
|
||||||
role="img"
|
role="img"
|
||||||
>
|
>
|
||||||
@ -77,7 +77,7 @@ function ToggleIconOn({ forceWhite }: { forceWhite?: boolean; }) {
|
|||||||
className={RegisteredGamesClasses.overlayToggleIconOn}
|
className={RegisteredGamesClasses.overlayToggleIconOn}
|
||||||
height="24"
|
height="24"
|
||||||
width="24"
|
width="24"
|
||||||
viewBox="0 0 32 26"
|
viewBox="0 2.2 32 26"
|
||||||
>
|
>
|
||||||
<path
|
<path
|
||||||
className={forceWhite ? "" : RegisteredGamesClasses.fill}
|
className={forceWhite ? "" : RegisteredGamesClasses.fill}
|
||||||
@ -119,7 +119,7 @@ function ToggleActivityComponentWithBackground({ activity }: { activity: Ignored
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`${TryItOutClasses.tryItOutBadge} ${BaseShapeRoundClasses.baseShapeRound}`}
|
className={`${TryItOutClasses.tryItOutBadge} ${BaseShapeRoundClasses.baseShapeRound}`}
|
||||||
style={{ padding: "0px 2px" }}
|
style={{ padding: "0px 2px", height: 28 }}
|
||||||
>
|
>
|
||||||
<ToggleActivityComponent activity={activity} forceWhite={true} />
|
<ToggleActivityComponent activity={activity} forceWhite={true} />
|
||||||
</div>
|
</div>
|
||||||
@ -157,10 +157,16 @@ export default definePlugin({
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
find: ".overlayBadge",
|
find: ".overlayBadge",
|
||||||
replacement: {
|
replacement: [
|
||||||
match: /(?<=\(\)\.badgeContainer.+?(\i)\.name}\):null)/,
|
{
|
||||||
replace: (_, props) => `,$self.renderToggleActivityButton(${props})`
|
match: /(?<=\(\)\.badgeContainer,children:).{0,50}?name:(\i)\.name.+?null/,
|
||||||
}
|
replace: (m, props) => `[${m},$self.renderToggleActivityButton(${props})]`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
match: /(?<=\(\)\.badgeContainer,children:).{0,50}?name:(\i\.application)\.name.+?null/,
|
||||||
|
replace: (m, props) => `${m},$self.renderToggleActivityButton(${props})`
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
find: '.displayName="LocalActivityStore"',
|
find: '.displayName="LocalActivityStore"',
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { classNameFactory } from "@api/Styles";
|
||||||
import { FluxDispatcher, React, useRef, useState } from "@webpack/common";
|
import { FluxDispatcher, React, useRef, useState } from "@webpack/common";
|
||||||
|
|
||||||
import { ELEMENT_ID } from "../constants";
|
import { ELEMENT_ID } from "../constants";
|
||||||
@ -33,6 +34,8 @@ export interface MagnifierProps {
|
|||||||
instance: any;
|
instance: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cl = classNameFactory("vc-imgzoom-");
|
||||||
|
|
||||||
export const Magnifier: React.FC<MagnifierProps> = ({ instance, size: initialSize, zoom: initalZoom }) => {
|
export const Magnifier: React.FC<MagnifierProps> = ({ instance, size: initialSize, zoom: initalZoom }) => {
|
||||||
const [ready, setReady] = useState(false);
|
const [ready, setReady] = useState(false);
|
||||||
|
|
||||||
@ -156,7 +159,7 @@ export const Magnifier: React.FC<MagnifierProps> = ({ instance, size: initialSiz
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="vc-imgzoom-lens"
|
className={cl("lens", { "nearest-neighbor": settings.store.nearestNeighbour, square: settings.store.square })}
|
||||||
style={{
|
style={{
|
||||||
opacity,
|
opacity,
|
||||||
width: size.current + "px",
|
width: size.current + "px",
|
||||||
|
@ -23,7 +23,7 @@ import { makeRange } from "@components/PluginSettings/components";
|
|||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { debounce } from "@utils/debounce";
|
import { debounce } from "@utils/debounce";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { Menu, React, ReactDOM } from "@webpack/common";
|
import { ContextMenu, Menu, React, ReactDOM } from "@webpack/common";
|
||||||
import type { Root } from "react-dom/client";
|
import type { Root } from "react-dom/client";
|
||||||
|
|
||||||
import { Magnifier, MagnifierProps } from "./components/Magnifier";
|
import { Magnifier, MagnifierProps } from "./components/Magnifier";
|
||||||
@ -50,6 +50,18 @@ export const settings = definePluginSettings({
|
|||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
nearestNeighbour: {
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
description: "Use Nearest Neighbour Interpolation when scaling images",
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
|
||||||
|
square: {
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
description: "Make the lens square",
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
|
||||||
zoom: {
|
zoom: {
|
||||||
description: "Zoom of the lens",
|
description: "Zoom of the lens",
|
||||||
type: OptionType.SLIDER,
|
type: OptionType.SLIDER,
|
||||||
@ -78,9 +90,17 @@ export const settings = definePluginSettings({
|
|||||||
const imageContextMenuPatch: NavContextMenuPatchCallback = children => () => {
|
const imageContextMenuPatch: NavContextMenuPatchCallback = children => () => {
|
||||||
children.push(
|
children.push(
|
||||||
<Menu.MenuGroup id="image-zoom">
|
<Menu.MenuGroup id="image-zoom">
|
||||||
{/* thanks SpotifyControls */}
|
<Menu.MenuCheckboxItem
|
||||||
|
id="vc-square"
|
||||||
|
label="Square Lens"
|
||||||
|
checked={settings.store.square}
|
||||||
|
action={() => {
|
||||||
|
settings.store.square = !settings.store.square;
|
||||||
|
ContextMenu.close();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<Menu.MenuControlItem
|
<Menu.MenuControlItem
|
||||||
id="zoom"
|
id="vc-zoom"
|
||||||
label="Zoom"
|
label="Zoom"
|
||||||
control={(props, ref) => (
|
control={(props, ref) => (
|
||||||
<Menu.MenuSliderControl
|
<Menu.MenuSliderControl
|
||||||
@ -94,7 +114,7 @@ const imageContextMenuPatch: NavContextMenuPatchCallback = children => () => {
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<Menu.MenuControlItem
|
<Menu.MenuControlItem
|
||||||
id="size"
|
id="vc-size"
|
||||||
label="Lens Size"
|
label="Lens Size"
|
||||||
control={(props, ref) => (
|
control={(props, ref) => (
|
||||||
<Menu.MenuSliderControl
|
<Menu.MenuSliderControl
|
||||||
@ -108,7 +128,7 @@ const imageContextMenuPatch: NavContextMenuPatchCallback = children => () => {
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<Menu.MenuControlItem
|
<Menu.MenuControlItem
|
||||||
id="zoom-speed"
|
id="vc-zoom-speed"
|
||||||
label="Zoom Speed"
|
label="Zoom Speed"
|
||||||
control={(props, ref) => (
|
control={(props, ref) => (
|
||||||
<Menu.MenuSliderControl
|
<Menu.MenuSliderControl
|
||||||
|
@ -11,6 +11,14 @@
|
|||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.vc-imgzoom-square {
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-imgzoom-nearest-neighbor > img {
|
||||||
|
image-rendering: pixelated; /* https://googlechrome.github.io/samples/image-rendering-pixelated/index.html */
|
||||||
|
}
|
||||||
|
|
||||||
/* make the carousel take up less space so we can click the backdrop and exit out of it */
|
/* make the carousel take up less space so we can click the backdrop and exit out of it */
|
||||||
[class|="carouselModal"] {
|
[class|="carouselModal"] {
|
||||||
height: fit-content;
|
height: fit-content;
|
||||||
|
@ -22,7 +22,7 @@ import ErrorBoundary from "@components/ErrorBoundary";
|
|||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { getStegCloak } from "@utils/dependencies";
|
import { getStegCloak } from "@utils/dependencies";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { Button, ButtonLooks, ButtonWrapperClasses, ChannelStore, FluxDispatcher, Tooltip } from "@webpack/common";
|
import { Button, ButtonLooks, ButtonWrapperClasses, ChannelStore, FluxDispatcher, RestAPI, Tooltip } from "@webpack/common";
|
||||||
import { Message } from "discord-types/general";
|
import { Message } from "discord-types/general";
|
||||||
|
|
||||||
import { buildDecModal } from "./components/DecryptionModal";
|
import { buildDecModal } from "./components/DecryptionModal";
|
||||||
@ -123,7 +123,7 @@ const settings = definePluginSettings({
|
|||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "InvisibleChat",
|
name: "InvisibleChat",
|
||||||
description: "Encrypt your Messages in a non-suspicious way! This plugin makes requests to >>https://embed.sammcheese.net<< to provide embeds to decrypted links!",
|
description: "Encrypt your Messages in a non-suspicious way!",
|
||||||
authors: [Devs.SammCheese],
|
authors: [Devs.SammCheese],
|
||||||
dependencies: ["MessagePopoverAPI"],
|
dependencies: ["MessagePopoverAPI"],
|
||||||
patches: [
|
patches: [
|
||||||
@ -132,7 +132,7 @@ export default definePlugin({
|
|||||||
find: ".Messages.MESSAGE_EDITED,",
|
find: ".Messages.MESSAGE_EDITED,",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /var .,.,.=(.)\.className,.=.\.message,.=.\.children,.=.\.content,.=.\.onUpdate/gm,
|
match: /var .,.,.=(.)\.className,.=.\.message,.=.\.children,.=.\.content,.=.\.onUpdate/gm,
|
||||||
replace: "try {$1 && $self.INV_REGEX.test($1.content[0]) ? $1.content.push($self.indicator()) : null } catch {};$&"
|
replace: "try {$1 && $self.INV_REGEX.test($1.message.content) ? $1.content.push($self.indicator()) : null } catch {};$&"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -178,25 +178,13 @@ export default definePlugin({
|
|||||||
|
|
||||||
// Gets the Embed of a Link
|
// Gets the Embed of a Link
|
||||||
async getEmbed(url: URL): Promise<Object | {}> {
|
async getEmbed(url: URL): Promise<Object | {}> {
|
||||||
const controller = new AbortController();
|
const { body } = await RestAPI.post({
|
||||||
const timeout = setTimeout(() => controller.abort(), 5000);
|
url: "/unfurler/embed-urls",
|
||||||
|
body: {
|
||||||
const options: RequestInit = {
|
urls: [url]
|
||||||
signal: controller.signal,
|
}
|
||||||
method: "POST",
|
});
|
||||||
headers: {
|
return await body.embeds[0];
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
url,
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
||||||
// AWS hosted url to discord embed object
|
|
||||||
const rawRes = await fetch(this.EMBED_API_URL, options);
|
|
||||||
clearTimeout(timeout);
|
|
||||||
|
|
||||||
return await rawRes.json();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async buildEmbed(message: any, revealed: string): Promise<void> {
|
async buildEmbed(message: any, revealed: string): Promise<void> {
|
||||||
@ -212,8 +200,11 @@ export default definePlugin({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (urlCheck?.length)
|
if (urlCheck?.length) {
|
||||||
message.embeds.push(await this.getEmbed(new URL(urlCheck[0])));
|
const embed = await this.getEmbed(new URL(urlCheck[0]));
|
||||||
|
if (embed)
|
||||||
|
message.embeds.push(embed);
|
||||||
|
}
|
||||||
|
|
||||||
this.updateMessage(message);
|
this.updateMessage(message);
|
||||||
},
|
},
|
||||||
|
@ -63,16 +63,16 @@ interface TrackData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// only relevant enum values
|
// only relevant enum values
|
||||||
enum ActivityType {
|
const enum ActivityType {
|
||||||
PLAYING = 0,
|
PLAYING = 0,
|
||||||
LISTENING = 2,
|
LISTENING = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ActivityFlag {
|
const enum ActivityFlag {
|
||||||
INSTANCE = 1 << 0,
|
INSTANCE = 1 << 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
const applicationId = "1043533871037284423";
|
const applicationId = "1108588077900898414";
|
||||||
const placeholderId = "2a96cbd8b46e442fc41c2b86b821562f";
|
const placeholderId = "2a96cbd8b46e442fc41c2b86b821562f";
|
||||||
|
|
||||||
const logger = new Logger("LastFMRichPresence");
|
const logger = new Logger("LastFMRichPresence");
|
||||||
@ -167,6 +167,7 @@ export default definePlugin({
|
|||||||
settings,
|
settings,
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
|
this.updatePresence();
|
||||||
this.updateInterval = setInterval(() => { this.updatePresence(); }, 16000);
|
this.updateInterval = setInterval(() => { this.updatePresence(); }, 16000);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -198,7 +199,7 @@ export default definePlugin({
|
|||||||
|
|
||||||
const trackData = json.recenttracks?.track[0];
|
const trackData = json.recenttracks?.track[0];
|
||||||
|
|
||||||
if (!trackData || !trackData["@attr"]?.nowplaying)
|
if (!trackData?.["@attr"]?.nowplaying)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// why does the json api have xml structure
|
// why does the json api have xml structure
|
||||||
|
@ -67,7 +67,7 @@ export default definePlugin({
|
|||||||
document.addEventListener("keydown", keydown);
|
document.addEventListener("keydown", keydown);
|
||||||
document.addEventListener("keyup", keyup);
|
document.addEventListener("keyup", keyup);
|
||||||
|
|
||||||
this.onClick = addClickListener((msg, channel, event) => {
|
this.onClick = addClickListener((msg: any, channel, event) => {
|
||||||
const isMe = msg.author.id === UserStore.getCurrentUser().id;
|
const isMe = msg.author.id === UserStore.getCurrentUser().id;
|
||||||
if (!isDeletePressed) {
|
if (!isDeletePressed) {
|
||||||
if (event.detail < 2) return;
|
if (event.detail < 2) return;
|
||||||
@ -90,7 +90,16 @@ export default definePlugin({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (settings.store.enableDeleteOnClick && (isMe || PermissionStore.can(MANAGE_CHANNELS, channel))) {
|
} else if (settings.store.enableDeleteOnClick && (isMe || PermissionStore.can(MANAGE_CHANNELS, channel))) {
|
||||||
MessageActions.deleteMessage(channel.id, msg.id);
|
if (msg.deleted) {
|
||||||
|
FluxDispatcher.dispatch({
|
||||||
|
type: "MESSAGE_DELETE",
|
||||||
|
channelId: channel.id,
|
||||||
|
id: msg.id,
|
||||||
|
mlDeleted: true
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
MessageActions.deleteMessage(channel.id, msg.id);
|
||||||
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -225,6 +225,8 @@ function MessageEmbedAccessory({ message }: { message: Message; }) {
|
|||||||
} else {
|
} else {
|
||||||
const msg = { ...message } as any;
|
const msg = { ...message } as any;
|
||||||
delete msg.embeds;
|
delete msg.embeds;
|
||||||
|
delete msg.interaction;
|
||||||
|
|
||||||
messageFetchQueue.push(() => fetchMessage(channelID, messageID)
|
messageFetchQueue.push(() => fetchMessage(channelID, messageID)
|
||||||
.then(m => m && FluxDispatcher.dispatch({
|
.then(m => m && FluxDispatcher.dispatch({
|
||||||
type: "MESSAGE_UPDATE",
|
type: "MESSAGE_UPDATE",
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
.messagelogger-deleted :is(div, h1, h2, h3, p) {
|
/* Message content highlighting */
|
||||||
|
.messagelogger-deleted [class*="contents-"] > :is(div, h1, h2, h3, p) {
|
||||||
|
color: #f04747 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Embed highlighting */
|
||||||
|
.messagelogger-deleted article :is(div, span, h1, h2, h3, p) {
|
||||||
color: #f04747 !important;
|
color: #f04747 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,6 +147,11 @@ export default definePlugin({
|
|||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
description: "Whether to ignore messages by yourself",
|
description: "Whether to ignore messages by yourself",
|
||||||
default: false
|
default: false
|
||||||
|
},
|
||||||
|
ignoreUsers: {
|
||||||
|
type: OptionType.STRING,
|
||||||
|
description: "Comma-separated list of user IDs to ignore",
|
||||||
|
default: ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -154,7 +159,7 @@ export default definePlugin({
|
|||||||
try {
|
try {
|
||||||
if (cache == null || (!isBulk && !cache.has(data.id))) return cache;
|
if (cache == null || (!isBulk && !cache.has(data.id))) return cache;
|
||||||
|
|
||||||
const { ignoreBots, ignoreSelf } = Settings.plugins.MessageLogger;
|
const { ignoreBots, ignoreSelf, ignoreUsers } = Settings.plugins.MessageLogger;
|
||||||
const myId = UserStore.getCurrentUser().id;
|
const myId = UserStore.getCurrentUser().id;
|
||||||
|
|
||||||
function mutate(id: string) {
|
function mutate(id: string) {
|
||||||
@ -165,7 +170,8 @@ export default definePlugin({
|
|||||||
const shouldIgnore = data.mlDeleted ||
|
const shouldIgnore = data.mlDeleted ||
|
||||||
(msg.flags & EPHEMERAL) === EPHEMERAL ||
|
(msg.flags & EPHEMERAL) === EPHEMERAL ||
|
||||||
ignoreBots && msg.author?.bot ||
|
ignoreBots && msg.author?.bot ||
|
||||||
ignoreSelf && msg.author?.id === myId;
|
ignoreSelf && msg.author?.id === myId ||
|
||||||
|
ignoreUsers.includes(msg.author?.id);
|
||||||
|
|
||||||
if (shouldIgnore) {
|
if (shouldIgnore) {
|
||||||
cache = cache.remove(id);
|
cache = cache.remove(id);
|
||||||
|
@ -2,16 +2,29 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.messagelogger-deleted :is(video, .emoji, [data-type="sticker"]),
|
.messagelogger-deleted
|
||||||
.messagelogger-deleted .messagelogger-deleted-attachment,
|
:is(
|
||||||
.messagelogger-deleted div iframe {
|
video,
|
||||||
|
.emoji,
|
||||||
|
[data-type="sticker"],
|
||||||
|
iframe,
|
||||||
|
.messagelogger-deleted-attachment,
|
||||||
|
[class|="inlineMediaEmbed"]
|
||||||
|
) {
|
||||||
filter: grayscale(1) !important;
|
filter: grayscale(1) !important;
|
||||||
transition: 150ms filter ease-in-out;
|
transition: 150ms filter ease-in-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
.messagelogger-deleted:hover :is(video, .emoji, [data-type="sticker"]),
|
.messagelogger-deleted
|
||||||
.messagelogger-deleted .messagelogger-deleted-attachment:hover,
|
:is(
|
||||||
.messagelogger-deleted iframe:hover {
|
video,
|
||||||
|
.emoji,
|
||||||
|
[data-type="sticker"],
|
||||||
|
iframe,
|
||||||
|
.messagelogger-deleted-attachment,
|
||||||
|
[class|="inlineMediaEmbed"]
|
||||||
|
):hover,
|
||||||
|
.messagelogger-deleted {
|
||||||
filter: grayscale(0) !important;
|
filter: grayscale(0) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,11 +17,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
|
import { Flex } from "@components/Flex";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { proxyLazy } from "@utils/lazy.js";
|
import { Margins } from "@utils/margins";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { find, findByPropsLazy } from "@webpack";
|
import { findByPropsLazy, findLazy } from "@webpack";
|
||||||
import { ChannelStore, GuildStore } from "@webpack/common";
|
import { Card, ChannelStore, Forms, GuildStore, Switch, TextInput, Tooltip, useState } from "@webpack/common";
|
||||||
|
import { RC } from "@webpack/types";
|
||||||
import { Channel, Message, User } from "discord-types/general";
|
import { Channel, Message, User } from "discord-types/general";
|
||||||
|
|
||||||
type PermissionName = "CREATE_INSTANT_INVITE" | "KICK_MEMBERS" | "BAN_MEMBERS" | "ADMINISTRATOR" | "MANAGE_CHANNELS" | "MANAGE_GUILD" | "CHANGE_NICKNAME" | "MANAGE_NICKNAMES" | "MANAGE_ROLES" | "MANAGE_WEBHOOKS" | "MANAGE_GUILD_EXPRESSIONS" | "CREATE_GUILD_EXPRESSIONS" | "VIEW_AUDIT_LOG" | "VIEW_CHANNEL" | "VIEW_GUILD_ANALYTICS" | "VIEW_CREATOR_MONETIZATION_ANALYTICS" | "MODERATE_MEMBERS" | "SEND_MESSAGES" | "SEND_TTS_MESSAGES" | "MANAGE_MESSAGES" | "EMBED_LINKS" | "ATTACH_FILES" | "READ_MESSAGE_HISTORY" | "MENTION_EVERYONE" | "USE_EXTERNAL_EMOJIS" | "ADD_REACTIONS" | "USE_APPLICATION_COMMANDS" | "MANAGE_THREADS" | "CREATE_PUBLIC_THREADS" | "CREATE_PRIVATE_THREADS" | "USE_EXTERNAL_STICKERS" | "SEND_MESSAGES_IN_THREADS" | "CONNECT" | "SPEAK" | "MUTE_MEMBERS" | "DEAFEN_MEMBERS" | "MOVE_MEMBERS" | "USE_VAD" | "PRIORITY_SPEAKER" | "STREAM" | "USE_EMBEDDED_ACTIVITIES" | "USE_SOUNDBOARD" | "USE_EXTERNAL_SOUNDS" | "REQUEST_TO_SPEAK" | "MANAGE_EVENTS" | "CREATE_EVENTS";
|
type PermissionName = "CREATE_INSTANT_INVITE" | "KICK_MEMBERS" | "BAN_MEMBERS" | "ADMINISTRATOR" | "MANAGE_CHANNELS" | "MANAGE_GUILD" | "CHANGE_NICKNAME" | "MANAGE_NICKNAMES" | "MANAGE_ROLES" | "MANAGE_WEBHOOKS" | "MANAGE_GUILD_EXPRESSIONS" | "CREATE_GUILD_EXPRESSIONS" | "VIEW_AUDIT_LOG" | "VIEW_CHANNEL" | "VIEW_GUILD_ANALYTICS" | "VIEW_CREATOR_MONETIZATION_ANALYTICS" | "MODERATE_MEMBERS" | "SEND_MESSAGES" | "SEND_TTS_MESSAGES" | "MANAGE_MESSAGES" | "EMBED_LINKS" | "ATTACH_FILES" | "READ_MESSAGE_HISTORY" | "MENTION_EVERYONE" | "USE_EXTERNAL_EMOJIS" | "ADD_REACTIONS" | "USE_APPLICATION_COMMANDS" | "MANAGE_THREADS" | "CREATE_PUBLIC_THREADS" | "CREATE_PRIVATE_THREADS" | "USE_EXTERNAL_STICKERS" | "SEND_MESSAGES_IN_THREADS" | "CONNECT" | "SPEAK" | "MUTE_MEMBERS" | "DEAFEN_MEMBERS" | "MOVE_MEMBERS" | "USE_VAD" | "PRIORITY_SPEAKER" | "STREAM" | "USE_EMBEDDED_ACTIVITIES" | "USE_SOUNDBOARD" | "USE_EXTERNAL_SOUNDS" | "REQUEST_TO_SPEAK" | "MANAGE_EVENTS" | "CREATE_EVENTS";
|
||||||
@ -36,6 +38,21 @@ interface Tag {
|
|||||||
condition?(message: Message | null, user: User, channel: Channel): boolean;
|
condition?(message: Message | null, user: User, channel: Channel): boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface TagSetting {
|
||||||
|
text: string;
|
||||||
|
showInChat: boolean;
|
||||||
|
showInNotChat: boolean;
|
||||||
|
}
|
||||||
|
interface TagSettings {
|
||||||
|
WEBHOOK: TagSetting,
|
||||||
|
OWNER: TagSetting,
|
||||||
|
ADMINISTRATOR: TagSetting,
|
||||||
|
MODERATOR_STAFF: TagSetting,
|
||||||
|
MODERATOR: TagSetting,
|
||||||
|
VOICE_MODERATOR: TagSetting,
|
||||||
|
[k: string]: TagSetting;
|
||||||
|
}
|
||||||
|
|
||||||
const CLYDE_ID = "1081004946872352958";
|
const CLYDE_ID = "1081004946872352958";
|
||||||
|
|
||||||
// PermissionStore.computePermissions is not the same function and doesn't work here
|
// PermissionStore.computePermissions is not the same function and doesn't work here
|
||||||
@ -44,7 +61,7 @@ const PermissionUtil = findByPropsLazy("computePermissions", "canEveryoneRole")
|
|||||||
};
|
};
|
||||||
|
|
||||||
const Permissions = findByPropsLazy("SEND_MESSAGES", "VIEW_CREATOR_MONETIZATION_ANALYTICS") as Record<PermissionName, bigint>;
|
const Permissions = findByPropsLazy("SEND_MESSAGES", "VIEW_CREATOR_MONETIZATION_ANALYTICS") as Record<PermissionName, bigint>;
|
||||||
const Tags = proxyLazy(() => find(m => m.Types?.[0] === "BOT").Types) as Record<string, number>;
|
const Tag = findLazy(m => m.Types?.[0] === "BOT") as RC<{ type?: number, className?: string, useRemSizes?: boolean; }> & { Types: Record<string, number>; };
|
||||||
|
|
||||||
const isWebhook = (message: Message, user: User) => !!message?.webhookId && user.isNonUserBot();
|
const isWebhook = (message: Message, user: User) => !!message?.webhookId && user.isNonUserBot();
|
||||||
|
|
||||||
@ -81,64 +98,119 @@ const tags: Tag[] = [
|
|||||||
permissions: ["MOVE_MEMBERS", "MUTE_MEMBERS", "DEAFEN_MEMBERS"]
|
permissions: ["MOVE_MEMBERS", "MUTE_MEMBERS", "DEAFEN_MEMBERS"]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
const defaultSettings = Object.fromEntries(
|
||||||
|
tags.map(({ name, displayName }) => [name, { text: displayName, showInChat: true, showInNotChat: true }])
|
||||||
|
) as TagSettings;
|
||||||
|
|
||||||
|
function SettingsComponent(props: { setValue(v: any): void; }) {
|
||||||
|
settings.store.tagSettings ??= defaultSettings;
|
||||||
|
|
||||||
|
const [tagSettings, setTagSettings] = useState(settings.store.tagSettings as TagSettings);
|
||||||
|
const setValue = (v: TagSettings) => {
|
||||||
|
setTagSettings(v);
|
||||||
|
props.setValue(v);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Flex flexDirection="column">
|
||||||
|
{tags.map(t => (
|
||||||
|
<Card style={{ padding: "1em 1em 0" }}>
|
||||||
|
<Forms.FormTitle style={{ width: "fit-content" }}>
|
||||||
|
<Tooltip text={t.description}>
|
||||||
|
{({ onMouseEnter, onMouseLeave }) => (
|
||||||
|
<div
|
||||||
|
onMouseEnter={onMouseEnter}
|
||||||
|
onMouseLeave={onMouseLeave}
|
||||||
|
>
|
||||||
|
{t.displayName} Tag <Tag type={Tag.Types[t.name]} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Tooltip>
|
||||||
|
</Forms.FormTitle>
|
||||||
|
|
||||||
|
<TextInput
|
||||||
|
type="text"
|
||||||
|
value={tagSettings[t.name]?.text ?? t.displayName}
|
||||||
|
placeholder={`Text on tag (default: ${t.displayName})`}
|
||||||
|
onChange={v => {
|
||||||
|
tagSettings[t.name].text = v;
|
||||||
|
setValue(tagSettings);
|
||||||
|
}}
|
||||||
|
className={Margins.bottom16}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Switch
|
||||||
|
value={tagSettings[t.name]?.showInChat ?? true}
|
||||||
|
onChange={v => {
|
||||||
|
tagSettings[t.name].showInChat = v;
|
||||||
|
setValue(tagSettings);
|
||||||
|
}}
|
||||||
|
hideBorder
|
||||||
|
>
|
||||||
|
Show in messages
|
||||||
|
</Switch>
|
||||||
|
|
||||||
|
<Switch
|
||||||
|
value={tagSettings[t.name]?.showInNotChat ?? true}
|
||||||
|
onChange={v => {
|
||||||
|
tagSettings[t.name].showInNotChat = v;
|
||||||
|
setValue(tagSettings);
|
||||||
|
}}
|
||||||
|
hideBorder
|
||||||
|
>
|
||||||
|
Show in member list and profiles
|
||||||
|
</Switch>
|
||||||
|
</Card>
|
||||||
|
))}
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
dontShowForBots: {
|
dontShowForBots: {
|
||||||
description: "Don't show tags (not including the webhook tag) for bots",
|
description: "Don't show extra tags for bots (excluding webhooks)",
|
||||||
type: OptionType.BOOLEAN
|
type: OptionType.BOOLEAN
|
||||||
},
|
},
|
||||||
dontShowBotTag: {
|
dontShowBotTag: {
|
||||||
description: "Don't show [BOT] text for bots with other tags (verified bots will still have checkmark)",
|
description: "Only show extra tags for bots / Hide [BOT] text",
|
||||||
type: OptionType.BOOLEAN
|
type: OptionType.BOOLEAN
|
||||||
},
|
},
|
||||||
...Object.fromEntries(tags.map(({ name, displayName, description }) => [
|
tagSettings: {
|
||||||
`visibility_${name}`, {
|
type: OptionType.COMPONENT,
|
||||||
description: `Show ${displayName} tags (${description})`,
|
component: SettingsComponent,
|
||||||
type: OptionType.SELECT,
|
description: "fill me",
|
||||||
options: [
|
}
|
||||||
{
|
|
||||||
label: "Always",
|
|
||||||
value: "always",
|
|
||||||
default: true
|
|
||||||
}, {
|
|
||||||
label: "Only in chat",
|
|
||||||
value: "chat"
|
|
||||||
}, {
|
|
||||||
label: "Only in member list and profiles",
|
|
||||||
value: "not-chat"
|
|
||||||
}, {
|
|
||||||
label: "Never",
|
|
||||||
value: "never"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]))
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "MoreUserTags",
|
name: "MoreUserTags",
|
||||||
description: "Adds tags for webhooks and moderative roles (owner, admin, etc.)",
|
description: "Adds tags for webhooks and moderative roles (owner, admin, etc.)",
|
||||||
authors: [Devs.Cyn, Devs.TheSun, Devs.RyanCaoDev],
|
authors: [Devs.Cyn, Devs.TheSun, Devs.RyanCaoDev, Devs.LordElias],
|
||||||
settings,
|
settings,
|
||||||
patches: [
|
patches: [
|
||||||
// add tags to the tag list
|
// add tags to the tag list
|
||||||
{
|
{
|
||||||
find: '.BOT=0]="BOT"',
|
find: '.BOT=0]="BOT"',
|
||||||
replacement: [
|
replacement: [
|
||||||
// add tags to the exported tags list (the Tags variable here)
|
// add tags to the exported tags list (Tag.Types)
|
||||||
{
|
{
|
||||||
match: /(\i)\[.\.BOT=0\]="BOT";/,
|
match: /(\i)\[.\.BOT=0\]="BOT";/,
|
||||||
replace: "$&$1=$self.addTagVariants($1);"
|
replace: "$&$1=$self.addTagVariants($1);"
|
||||||
},
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
find: ".DISCORD_SYSTEM_MESSAGE_BOT_TAG_TOOLTIP;",
|
||||||
|
replacement: [
|
||||||
// make the tag show the right text
|
// make the tag show the right text
|
||||||
{
|
{
|
||||||
match: /(switch\((\i)\){.+?)case (\i)\.BOT:default:(\i)=(\i\.\i\.Messages)\.BOT_TAG_BOT/,
|
match: /(switch\((\i)\){.+?)case (\i(?:\.\i)?)\.BOT:default:(\i)=(\i\.\i\.Messages)\.BOT_TAG_BOT/,
|
||||||
replace: (_, origSwitch, variant, tags, displayedText, strings) =>
|
replace: (_, origSwitch, variant, tags, displayedText, strings) =>
|
||||||
`${origSwitch}default:{${displayedText} = $self.getTagText(${tags}[${variant}], ${strings})}`
|
`${origSwitch}default:{${displayedText} = $self.getTagText(${tags}[${variant}], ${strings})}`
|
||||||
},
|
},
|
||||||
// show OP tags correctly
|
// show OP tags correctly
|
||||||
{
|
{
|
||||||
match: /(\i)=(\i)===\i\.ORIGINAL_POSTER/,
|
match: /(\i)=(\i)===\i(?:\.\i)?\.ORIGINAL_POSTER/,
|
||||||
replace: "$1=$self.isOPTag($2)"
|
replace: "$1=$self.isOPTag($2)"
|
||||||
},
|
},
|
||||||
// add HTML data attributes (for easier theming)
|
// add HTML data attributes (for easier theming)
|
||||||
@ -169,15 +241,15 @@ return type!==null?$2.botTag,type"
|
|||||||
{
|
{
|
||||||
find: ".hasAvatarForGuild(null==",
|
find: ".hasAvatarForGuild(null==",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /\.usernameSection,user/,
|
match: /(?=usernameIcon:)/,
|
||||||
replace: ".usernameSection,moreTags_channelId:arguments[0].channelId,user"
|
replace: "moreTags_channelId:arguments[0].channelId,"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
find: 'copyMetaData:"User Tag"',
|
find: 'copyMetaData:"User Tag"',
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /discriminatorClass:(.{1,100}),botClass:/,
|
match: /(?=,botClass:)/,
|
||||||
replace: "discriminatorClass:$1,moreTags_channelId:arguments[0].moreTags_channelId,botClass:"
|
replace: ",moreTags_channelId:arguments[0].moreTags_channelId"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// in profiles
|
// in profiles
|
||||||
@ -190,6 +262,37 @@ return type!==null?$2.botTag,type"
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
|
start() {
|
||||||
|
if (settings.store.tagSettings) return;
|
||||||
|
// @ts-ignore
|
||||||
|
if (!settings.store.visibility_WEBHOOK) settings.store.tagSettings = defaultSettings;
|
||||||
|
else {
|
||||||
|
const newSettings = { ...defaultSettings };
|
||||||
|
Object.entries(Vencord.PlainSettings.plugins.MoreUserTags).forEach(([name, value]) => {
|
||||||
|
const [setting, tag] = name.split("_");
|
||||||
|
if (setting === "visibility") {
|
||||||
|
switch (value) {
|
||||||
|
case "always":
|
||||||
|
// its the default
|
||||||
|
break;
|
||||||
|
case "chat":
|
||||||
|
newSettings[tag].showInNotChat = false;
|
||||||
|
break;
|
||||||
|
case "not-chat":
|
||||||
|
newSettings[tag].showInChat = false;
|
||||||
|
break;
|
||||||
|
case "never":
|
||||||
|
newSettings[tag].showInChat = false;
|
||||||
|
newSettings[tag].showInNotChat = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
settings.store.tagSettings = newSettings;
|
||||||
|
delete Vencord.Settings.plugins.MoreUserTags[name];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
getPermissions(user: User, channel: Channel): string[] {
|
getPermissions(user: User, channel: Channel): string[] {
|
||||||
const guild = GuildStore.getGuild(channel?.guild_id);
|
const guild = GuildStore.getGuild(channel?.guild_id);
|
||||||
if (!guild) return [];
|
if (!guild) return [];
|
||||||
@ -202,35 +305,36 @@ return type!==null?$2.botTag,type"
|
|||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
},
|
},
|
||||||
|
|
||||||
addTagVariants(val: any /* i cant think of a good name */) {
|
addTagVariants(tagConstant) {
|
||||||
let i = 100;
|
let i = 100;
|
||||||
tags.forEach(({ name }) => {
|
tags.forEach(({ name }) => {
|
||||||
val[name] = ++i;
|
tagConstant[name] = ++i;
|
||||||
val[i] = name;
|
tagConstant[i] = name;
|
||||||
val[`${name}-BOT`] = ++i;
|
tagConstant[`${name}-BOT`] = ++i;
|
||||||
val[i] = `${name}-BOT`;
|
tagConstant[i] = `${name}-BOT`;
|
||||||
val[`${name}-OP`] = ++i;
|
tagConstant[`${name}-OP`] = ++i;
|
||||||
val[i] = `${name}-OP`;
|
tagConstant[i] = `${name}-OP`;
|
||||||
});
|
});
|
||||||
return val;
|
return tagConstant;
|
||||||
},
|
},
|
||||||
|
|
||||||
isOPTag: (tag: number) => tag === Tags.ORIGINAL_POSTER || tags.some(t => tag === Tags[`${t.name}-OP`]),
|
isOPTag: (tag: number) => tag === Tag.Types.ORIGINAL_POSTER || tags.some(t => tag === Tag.Types[`${t.name}-OP`]),
|
||||||
|
|
||||||
getTagText(passedTagName: string, strings: Record<string, string>) {
|
getTagText(passedTagName: string, strings: Record<string, string>) {
|
||||||
if (!passedTagName) return "BOT";
|
if (!passedTagName) return strings.BOT_TAG_BOT;
|
||||||
const [tagName, variant] = passedTagName.split("-");
|
const [tagName, variant] = passedTagName.split("-");
|
||||||
const tag = tags.find(({ name }) => tagName === name);
|
const tag = tags.find(({ name }) => tagName === name);
|
||||||
if (!tag) return "BOT";
|
if (!tag) return strings.BOT_TAG_BOT;
|
||||||
if (variant === "BOT" && tagName !== "WEBHOOK" && this.settings.store.dontShowForBots) return strings.BOT_TAG_BOT;
|
if (variant === "BOT" && tagName !== "WEBHOOK" && this.settings.store.dontShowForBots) return strings.BOT_TAG_BOT;
|
||||||
|
|
||||||
|
const tagText = settings.store.tagSettings?.[tag.name]?.text || tag.displayName;
|
||||||
switch (variant) {
|
switch (variant) {
|
||||||
case "OP":
|
case "OP":
|
||||||
return `${strings.BOT_TAG_FORUM_ORIGINAL_POSTER} • ${tag.displayName}`;
|
return `${strings.BOT_TAG_FORUM_ORIGINAL_POSTER} • ${tagText}`;
|
||||||
case "BOT":
|
case "BOT":
|
||||||
return `${strings.BOT_TAG_BOT} • ${tag.displayName}`;
|
return `${strings.BOT_TAG_BOT} • ${tagText}`;
|
||||||
default:
|
default:
|
||||||
return tag.displayName;
|
return tagText;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -242,12 +346,12 @@ return type!==null?$2.botTag,type"
|
|||||||
channel?: Channel & { isForumPost(): boolean; },
|
channel?: Channel & { isForumPost(): boolean; },
|
||||||
channelId?: string;
|
channelId?: string;
|
||||||
origType?: number;
|
origType?: number;
|
||||||
location: string;
|
location: "chat" | "not-chat";
|
||||||
}): number | null {
|
}): number | null {
|
||||||
if (location === "chat" && user.id === "1")
|
if (location === "chat" && user.id === "1")
|
||||||
return Tags.OFFICIAL;
|
return Tag.Types.OFFICIAL;
|
||||||
if (user.id === CLYDE_ID)
|
if (user.id === CLYDE_ID)
|
||||||
return Tags.AI;
|
return Tag.Types.AI;
|
||||||
|
|
||||||
let type = typeof origType === "number" ? origType : null;
|
let type = typeof origType === "number" ? origType : null;
|
||||||
|
|
||||||
@ -258,24 +362,19 @@ return type!==null?$2.botTag,type"
|
|||||||
const perms = this.getPermissions(user, channel);
|
const perms = this.getPermissions(user, channel);
|
||||||
|
|
||||||
for (const tag of tags) {
|
for (const tag of tags) {
|
||||||
switch (settings[`visibility_${tag.name}`]) {
|
if (location === "chat" && !settings.tagSettings[tag.name].showInChat) continue;
|
||||||
case "always":
|
if (location === "not-chat" && !settings.tagSettings[tag.name].showInNotChat) continue;
|
||||||
case location:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
tag.permissions?.some(perm => perms.includes(perm)) ||
|
tag.permissions?.some(perm => perms.includes(perm)) ||
|
||||||
(tag.condition?.(message!, user, channel))
|
(tag.condition?.(message!, user, channel))
|
||||||
) {
|
) {
|
||||||
if (channel.isForumPost() && channel.ownerId === user.id)
|
if (channel.isForumPost() && channel.ownerId === user.id)
|
||||||
type = Tags[`${tag.name}-OP`];
|
type = Tag.Types[`${tag.name}-OP`];
|
||||||
else if (user.bot && !isWebhook(message!, user) && !settings.dontShowBotTag)
|
else if (user.bot && !isWebhook(message!, user) && !settings.dontShowBotTag)
|
||||||
type = Tags[`${tag.name}-BOT`];
|
type = Tag.Types[`${tag.name}-BOT`];
|
||||||
else
|
else
|
||||||
type = Tags[tag.name];
|
type = Tag.Types[tag.name];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -21,7 +21,7 @@ import { makeRange } from "@components/PluginSettings/components/SettingSliderCo
|
|||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { sleep } from "@utils/misc";
|
import { sleep } from "@utils/misc";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { SelectedChannelStore, UserStore } from "@webpack/common";
|
import { RelationshipStore, SelectedChannelStore, UserStore } from "@webpack/common";
|
||||||
import { Message, ReactionEmoji } from "discord-types/general";
|
import { Message, ReactionEmoji } from "discord-types/general";
|
||||||
|
|
||||||
interface IMessageCreate {
|
interface IMessageCreate {
|
||||||
@ -37,6 +37,7 @@ interface IReactionAdd {
|
|||||||
optimistic: boolean;
|
optimistic: boolean;
|
||||||
channelId: string;
|
channelId: string;
|
||||||
messageId: string;
|
messageId: string;
|
||||||
|
messageAuthorId: string;
|
||||||
userId: "195136840355807232";
|
userId: "195136840355807232";
|
||||||
emoji: ReactionEmoji;
|
emoji: ReactionEmoji;
|
||||||
}
|
}
|
||||||
@ -71,6 +72,11 @@ const settings = definePluginSettings({
|
|||||||
description: "Ignore bots",
|
description: "Ignore bots",
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
default: true
|
default: true
|
||||||
|
},
|
||||||
|
ignoreBlocked: {
|
||||||
|
description: "Ignore blocked users",
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
default: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -85,6 +91,7 @@ export default definePlugin({
|
|||||||
if (optimistic || type !== "MESSAGE_CREATE") return;
|
if (optimistic || type !== "MESSAGE_CREATE") return;
|
||||||
if (message.state === "SENDING") return;
|
if (message.state === "SENDING") return;
|
||||||
if (settings.store.ignoreBots && message.author?.bot) return;
|
if (settings.store.ignoreBots && message.author?.bot) return;
|
||||||
|
if (settings.store.ignoreBlocked && RelationshipStore.isBlocked(message.author?.id)) return;
|
||||||
if (!message.content) return;
|
if (!message.content) return;
|
||||||
if (channelId !== SelectedChannelStore.getChannelId()) return;
|
if (channelId !== SelectedChannelStore.getChannelId()) return;
|
||||||
|
|
||||||
@ -96,9 +103,10 @@ export default definePlugin({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
MESSAGE_REACTION_ADD({ optimistic, type, channelId, userId, emoji }: IReactionAdd) {
|
MESSAGE_REACTION_ADD({ optimistic, type, channelId, userId, messageAuthorId, emoji }: IReactionAdd) {
|
||||||
if (optimistic || type !== "MESSAGE_REACTION_ADD") return;
|
if (optimistic || type !== "MESSAGE_REACTION_ADD") return;
|
||||||
if (settings.store.ignoreBots && UserStore.getUser(userId)?.bot) return;
|
if (settings.store.ignoreBots && UserStore.getUser(userId)?.bot) return;
|
||||||
|
if (settings.store.ignoreBlocked && RelationshipStore.isBlocked(messageAuthorId)) return;
|
||||||
if (channelId !== SelectedChannelStore.getChannelId()) return;
|
if (channelId !== SelectedChannelStore.getChannelId()) return;
|
||||||
|
|
||||||
const name = emoji.name.toLowerCase();
|
const name = emoji.name.toLowerCase();
|
||||||
|
@ -18,37 +18,8 @@
|
|||||||
|
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { ModalContent, ModalFooter, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByProps, findStoreLazy } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { Button, Text } from "@webpack/common";
|
|
||||||
|
|
||||||
const UserGuildSettingsStore = findStoreLazy("UserGuildSettingsStore");
|
|
||||||
|
|
||||||
function NoDMNotificationsModal({ modalProps }: { modalProps: ModalProps; }) {
|
|
||||||
return (
|
|
||||||
<ModalRoot {...modalProps} size={ModalSize.MEDIUM}>
|
|
||||||
<ModalContent>
|
|
||||||
<div style={{ display: "flex", flexDirection: "column", justifyContent: "center", "alignItems": "center", textAlign: "center", height: "100%", padding: "8px 0", gap: "16px" }}>
|
|
||||||
<Text variant="text-lg/semibold">You seem to have been affected by a bug that caused DM notifications to be muted and break if you used the MuteNewGuild plugin.</Text>
|
|
||||||
<Text variant="text-lg/semibold">If you haven't received any notifications for private messages, this is why. This issue is now fixed, so they should work again. Please verify, and in case they are still broken, ask for help in the Vencord support channel!</Text>
|
|
||||||
<Text variant="text-lg/semibold">We're very sorry for any inconvenience caused by this issue :(</Text>
|
|
||||||
</div>
|
|
||||||
</ModalContent>
|
|
||||||
<ModalFooter>
|
|
||||||
<div style={{ display: "flex", justifyContent: "center", width: "100%" }}>
|
|
||||||
<Button
|
|
||||||
onClick={modalProps.onClose}
|
|
||||||
size={Button.Sizes.MEDIUM}
|
|
||||||
color={Button.Colors.BRAND}
|
|
||||||
>
|
|
||||||
Understood!
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</ModalFooter>
|
|
||||||
</ModalRoot>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
guild: {
|
guild: {
|
||||||
@ -92,15 +63,5 @@ export default definePlugin({
|
|||||||
suppress_roles: settings.store.role
|
suppress_roles: settings.store.role
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
|
||||||
|
|
||||||
start() {
|
|
||||||
const [isMuted, isEveryoneSupressed, isRolesSupressed] = [UserGuildSettingsStore.isMuted(null), UserGuildSettingsStore.isSuppressEveryoneEnabled(null), UserGuildSettingsStore.isSuppressRolesEnabled(null)];
|
|
||||||
|
|
||||||
if (isMuted || isEveryoneSupressed || isRolesSupressed) {
|
|
||||||
findByProps("updateGuildNotificationSettings").updateGuildNotificationSettings(null, { muted: false, suppress_everyone: false, suppress_roles: false });
|
|
||||||
|
|
||||||
openModal(modalProps => <NoDMNotificationsModal modalProps={modalProps} />);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
104
src/plugins/mutualGroupDMs.tsx
Normal file
104
src/plugins/mutualGroupDMs.tsx
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
/*
|
||||||
|
* Vencord, a modification for Discord's desktop app
|
||||||
|
* Copyright (c) 2023 Vendicated and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
|
import { isNonNullish } from "@utils/guards";
|
||||||
|
import definePlugin from "@utils/types";
|
||||||
|
import { findByPropsLazy } from "@webpack";
|
||||||
|
import { Avatar, ChannelStore, Clickable, RelationshipStore, ScrollerThin, UserStore } from "@webpack/common";
|
||||||
|
import { Channel, User } from "discord-types/general";
|
||||||
|
|
||||||
|
const SelectedChannelActionCreators = findByPropsLazy("selectPrivateChannel");
|
||||||
|
const AvatarUtils = findByPropsLazy("getChannelIconURL");
|
||||||
|
const UserUtils = findByPropsLazy("getGlobalName");
|
||||||
|
|
||||||
|
const ProfileListClasses = findByPropsLazy("emptyIconFriends", "emptyIconGuilds");
|
||||||
|
const GuildLabelClasses = findByPropsLazy("guildNick", "guildAvatarWithoutIcon");
|
||||||
|
|
||||||
|
function getGroupDMName(channel: Channel) {
|
||||||
|
return channel.name ||
|
||||||
|
channel.recipients
|
||||||
|
.map(UserStore.getUser)
|
||||||
|
.filter(isNonNullish)
|
||||||
|
.map(c => RelationshipStore.getNickname(c.id) || UserUtils.getName(c))
|
||||||
|
.join(", ");
|
||||||
|
}
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "MutualGroupDMs",
|
||||||
|
description: "Shows mutual group dms in profiles",
|
||||||
|
authors: [Devs.amia],
|
||||||
|
|
||||||
|
patches: [
|
||||||
|
{
|
||||||
|
find: ".Messages.USER_PROFILE_MODAL", // Note: the module is lazy-loaded
|
||||||
|
replacement: [
|
||||||
|
{
|
||||||
|
match: /(?<=\.MUTUAL_GUILDS\}\),)(?=(\i\.bot).{0,20}(\(0,\i\.jsx\)\(.{0,100}id:))/,
|
||||||
|
replace: '$1?null:$2"MUTUAL_GDMS",children:"Mutual Groups"}),'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
match: /(?<={user:(\i),onClose:(\i)}\);)(?=case \i\.\i\.MUTUAL_FRIENDS)/,
|
||||||
|
replace: "case \"MUTUAL_GDMS\":return $self.renderMutualGDMs($1,$2);"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
renderMutualGDMs(user: User, onClose: () => void) {
|
||||||
|
const entries = ChannelStore.getSortedPrivateChannels().filter(c => c.isGroupDM() && c.recipients.includes(user.id)).map(c => (
|
||||||
|
<Clickable
|
||||||
|
className={ProfileListClasses.listRow}
|
||||||
|
onClick={() => {
|
||||||
|
onClose();
|
||||||
|
SelectedChannelActionCreators.selectPrivateChannel(c.id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Avatar
|
||||||
|
src={AvatarUtils.getChannelIconURL({ id: c.id, icon: c.icon, size: 32 })}
|
||||||
|
size="SIZE_40"
|
||||||
|
className={ProfileListClasses.listAvatar}
|
||||||
|
>
|
||||||
|
</Avatar>
|
||||||
|
<div className={ProfileListClasses.listRowContent}>
|
||||||
|
<div className={ProfileListClasses.listName}>{getGroupDMName(c)}</div>
|
||||||
|
<div className={GuildLabelClasses.guildNick}>{c.recipients.length + 1} Members</div>
|
||||||
|
</div>
|
||||||
|
</Clickable>
|
||||||
|
));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ScrollerThin
|
||||||
|
className={ProfileListClasses.listScroller}
|
||||||
|
fade={true}
|
||||||
|
onClose={onClose}
|
||||||
|
>
|
||||||
|
{entries.length > 0
|
||||||
|
? entries
|
||||||
|
: (
|
||||||
|
<div className={ProfileListClasses.empty}>
|
||||||
|
<div className={ProfileListClasses.emptyIconFriends}></div>
|
||||||
|
<div className={ProfileListClasses.emptyText}>No group dms in common</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</ScrollerThin>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
97
src/plugins/noPendingCount.ts
Normal file
97
src/plugins/noPendingCount.ts
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
* Vencord, a modification for Discord's desktop app
|
||||||
|
* Copyright (c) 2023 Vendicated and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import { definePluginSettings } from "@api/Settings";
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
import { findByPropsLazy } from "@webpack";
|
||||||
|
|
||||||
|
const MessageRequestStore = findByPropsLazy("getMessageRequestsCount");
|
||||||
|
|
||||||
|
const settings = definePluginSettings({
|
||||||
|
hideFriendRequestsCount: {
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
description: "Hide incoming friend requests count",
|
||||||
|
default: true,
|
||||||
|
restartNeeded: true
|
||||||
|
},
|
||||||
|
hideMessageRequestsCount: {
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
description: "Hide message requests count",
|
||||||
|
default: true,
|
||||||
|
restartNeeded: true
|
||||||
|
},
|
||||||
|
hidePremiumOffersCount: {
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
description: "Hide nitro offers count",
|
||||||
|
default: true,
|
||||||
|
restartNeeded: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "NoPendingCount",
|
||||||
|
description: "Removes the ping count of incoming friend requests, message requests, and nitro offers.",
|
||||||
|
authors: [Devs.amia],
|
||||||
|
|
||||||
|
settings: settings,
|
||||||
|
|
||||||
|
// Functions used to determine the top left count indicator can be found in the single module that calls getUnacknowledgedOffers(...)
|
||||||
|
// or by searching for "showProgressBadge:"
|
||||||
|
patches: [
|
||||||
|
{
|
||||||
|
find: ".getPendingCount=",
|
||||||
|
predicate: () => settings.store.hideFriendRequestsCount,
|
||||||
|
replacement: {
|
||||||
|
match: /(?<=\.getPendingCount=function\(\)\{)/,
|
||||||
|
replace: "return 0;"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
find: ".getMessageRequestsCount=",
|
||||||
|
predicate: () => settings.store.hideMessageRequestsCount,
|
||||||
|
replacement: {
|
||||||
|
match: /(?<=\.getMessageRequestsCount=function\(\)\{)/,
|
||||||
|
replace: "return 0;"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// This prevents the Message Requests tab from always hiding due to the previous patch (and is compatible with spam requests)
|
||||||
|
// In short, only the red badge is hidden. Button visibility behavior isn't changed.
|
||||||
|
{
|
||||||
|
find: ".getSpamChannelsCount(),",
|
||||||
|
predicate: () => settings.store.hideMessageRequestsCount,
|
||||||
|
replacement: {
|
||||||
|
match: /(?<=getSpamChannelsCount\(\),\i=)\i\.getMessageRequestsCount\(\)/,
|
||||||
|
replace: "$self.getRealMessageRequestCount()"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
find: "showProgressBadge:",
|
||||||
|
predicate: () => settings.store.hidePremiumOffersCount,
|
||||||
|
replacement: {
|
||||||
|
match: /\(function\(\){return \i\.\i\.getUnacknowledgedOffers\(\i\)\.length}\)/,
|
||||||
|
replace: "(function(){return 0})"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
getRealMessageRequestCount() {
|
||||||
|
return MessageRequestStore.getMessageRequestChannelIds().size;
|
||||||
|
}
|
||||||
|
});
|
53
src/plugins/noProfileThemes.ts
Normal file
53
src/plugins/noProfileThemes.ts
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Vencord, a modification for Discord's desktop app
|
||||||
|
* Copyright (c) 2023 Vendicated and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
|
import definePlugin from "@utils/types";
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "NoProfileThemes",
|
||||||
|
description: "Completely removes Nitro profile themes",
|
||||||
|
authors: [Devs.TheKodeToad],
|
||||||
|
patches: [
|
||||||
|
{
|
||||||
|
find: ".NITRO_BANNER,",
|
||||||
|
replacement: {
|
||||||
|
// = isPremiumAtLeast(user.premiumType, TIER_2)
|
||||||
|
match: /=(?=\i\.\i\.isPremiumAtLeast\(null==(\i))/,
|
||||||
|
// = user.banner && isPremiumAtLeast(user.premiumType, TIER_2)
|
||||||
|
replace: "=$1?.banner&&"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
find: "().avatarPositionPremiumNoBanner,default:",
|
||||||
|
replacement: {
|
||||||
|
// premiumUserWithoutBanner: foo().avatarPositionPremiumNoBanner, default: foo().avatarPositionNormal
|
||||||
|
match: /\.avatarPositionPremiumNoBanner(?=,default:\i\(\)\.(\i))/,
|
||||||
|
// premiumUserWithoutBanner: foo().avatarPositionNormal...
|
||||||
|
replace: ".$1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
find: ".hasThemeColors=function(){",
|
||||||
|
replacement: {
|
||||||
|
match: /(?<=key:"canUsePremiumProfileCustomization",get:function\(\){return)/,
|
||||||
|
replace: " false;"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
@ -22,12 +22,27 @@ import definePlugin, { OptionType } from "@utils/types";
|
|||||||
import type { Message } from "discord-types/general";
|
import type { Message } from "discord-types/general";
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
exemptList: {
|
userList: {
|
||||||
description:
|
description:
|
||||||
"List of users to exempt from this plugin (separated by commas or spaces)",
|
"List of users to allow or exempt pings for (separated by commas or spaces)",
|
||||||
type: OptionType.STRING,
|
type: OptionType.STRING,
|
||||||
default: "1234567890123445,1234567890123445",
|
default: "1234567890123445,1234567890123445",
|
||||||
},
|
},
|
||||||
|
shouldPingListed: {
|
||||||
|
description: "Behaviour",
|
||||||
|
type: OptionType.SELECT,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: "Do not ping the listed users",
|
||||||
|
value: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Only ping the listed users",
|
||||||
|
value: true,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
inverseShiftReply: {
|
inverseShiftReply: {
|
||||||
description: "Invert Discord's shift replying behaviour (enable to make shift reply mention user)",
|
description: "Invert Discord's shift replying behaviour (enable to make shift reply mention user)",
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
@ -38,11 +53,12 @@ const settings = definePluginSettings({
|
|||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "NoReplyMention",
|
name: "NoReplyMention",
|
||||||
description: "Disables reply pings by default",
|
description: "Disables reply pings by default",
|
||||||
authors: [Devs.DustyAngel47, Devs.axyie, Devs.pylix],
|
authors: [Devs.DustyAngel47, Devs.axyie, Devs.pylix, Devs.outfoxxed],
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
shouldMention(message: Message, isHoldingShift: boolean) {
|
shouldMention(message: Message, isHoldingShift: boolean) {
|
||||||
const isExempt = settings.store.exemptList.includes(message.author.id);
|
const isListed = settings.store.userList.includes(message.author.id);
|
||||||
|
const isExempt = settings.store.shouldPingListed ? isListed : !isListed;
|
||||||
return settings.store.inverseShiftReply ? isHoldingShift !== isExempt : !isHoldingShift && isExempt;
|
return settings.store.inverseShiftReply ? isHoldingShift !== isExempt : !isHoldingShift && isExempt;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
147
src/plugins/openInApp.ts
Normal file
147
src/plugins/openInApp.ts
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
/*
|
||||||
|
* Vencord, a modification for Discord's desktop app
|
||||||
|
* Copyright (c) 2023 Vendicated and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { definePluginSettings } from "@api/Settings";
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
import { showToast, Toasts } from "@webpack/common";
|
||||||
|
import type { MouseEvent } from "react";
|
||||||
|
|
||||||
|
const ShortUrlMatcher = /^https:\/\/(spotify\.link|s\.team)\/.+$/;
|
||||||
|
const SpotifyMatcher = /^https:\/\/open\.spotify\.com\/(track|album|artist|playlist|user)\/(.+)(?:\?.+?)?$/;
|
||||||
|
const SteamMatcher = /^https:\/\/(steamcommunity\.com|(?:help|store)\.steampowered\.com)\/.+$/;
|
||||||
|
const EpicMatcher = /^https:\/\/store\.epicgames\.com\/(.+)$/;
|
||||||
|
|
||||||
|
const settings = definePluginSettings({
|
||||||
|
spotify: {
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
description: "Open Spotify links in the Spotify app",
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
steam: {
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
description: "Open Steam links in the Steam app",
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
epic: {
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
description: "Open Epic Games links in the Epic Games Launcher",
|
||||||
|
default: true,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "OpenInApp",
|
||||||
|
description: "Open Spotify, Steam and Epic Games URLs in their respective apps instead of your browser",
|
||||||
|
authors: [Devs.Ven],
|
||||||
|
settings,
|
||||||
|
|
||||||
|
patches: [
|
||||||
|
{
|
||||||
|
find: '"MaskedLinkStore"',
|
||||||
|
replacement: {
|
||||||
|
match: /return ((\i)\.apply\(this,arguments\))(?=\}function \i.{0,200}\.trusted)/,
|
||||||
|
replace: "return $self.handleLink(...arguments).then(handled => handled || $1)"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// Make Spotify profile activity links open in app on web
|
||||||
|
{
|
||||||
|
find: "WEB_OPEN(",
|
||||||
|
predicate: () => !IS_DISCORD_DESKTOP && settings.store.spotify,
|
||||||
|
replacement: {
|
||||||
|
match: /\i\.\i\.isProtocolRegistered\(\)(.{0,100})window.open/g,
|
||||||
|
replace: "true$1VencordNative.native.openExternal"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
find: ".CONNECTED_ACCOUNT_VIEWED,",
|
||||||
|
replacement: {
|
||||||
|
match: /(?<=href:\i,onClick:function\(\)\{)(?=return \i=(\i)\.type,.{0,50}CONNECTED_ACCOUNT_VIEWED)/,
|
||||||
|
replace: "$self.handleAccountView(arguments[0],$1.type,$1.id);"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
async handleLink(data: { href: string; }, event?: MouseEvent) {
|
||||||
|
if (!data) return false;
|
||||||
|
|
||||||
|
let url = data.href;
|
||||||
|
if (!IS_WEB && ShortUrlMatcher.test(url)) {
|
||||||
|
event?.preventDefault();
|
||||||
|
// CORS jumpscare
|
||||||
|
url = await VencordNative.pluginHelpers.OpenInApp.resolveRedirect(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
spotify: {
|
||||||
|
if (!settings.store.spotify) break spotify;
|
||||||
|
|
||||||
|
const match = SpotifyMatcher.exec(url);
|
||||||
|
if (!match) break spotify;
|
||||||
|
|
||||||
|
const [, type, id] = match;
|
||||||
|
VencordNative.native.openExternal(`spotify:${type}:${id}`);
|
||||||
|
|
||||||
|
event?.preventDefault();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
steam: {
|
||||||
|
if (!settings.store.steam) break steam;
|
||||||
|
|
||||||
|
if (!SteamMatcher.test(url)) break steam;
|
||||||
|
|
||||||
|
VencordNative.native.openExternal(`steam://openurl/${url}`);
|
||||||
|
event?.preventDefault();
|
||||||
|
|
||||||
|
// Steam does not focus itself so show a toast so it's slightly less confusing
|
||||||
|
showToast("Opened link in Steam", Toasts.Type.SUCCESS);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
epic: {
|
||||||
|
if (!settings.store.epic) break epic;
|
||||||
|
|
||||||
|
const match = EpicMatcher.exec(url);
|
||||||
|
if (!match) break epic;
|
||||||
|
|
||||||
|
VencordNative.native.openExternal(`com.epicgames.launcher://store/${match[1]}`);
|
||||||
|
event?.preventDefault();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// in case short url didn't end up being something we can handle
|
||||||
|
if (event?.defaultPrevented) {
|
||||||
|
window.open(url, "_blank");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
handleAccountView(event: { preventDefault(): void; }, platformType: string, userId: string) {
|
||||||
|
if (platformType === "spotify" && settings.store.spotify) {
|
||||||
|
VencordNative.native.openExternal(`spotify:user:${userId}`);
|
||||||
|
event.preventDefault();
|
||||||
|
} else if (platformType === "steam" && settings.store.steam) {
|
||||||
|
VencordNative.native.openExternal(`steam://openurl/https://steamcommunity.com/profiles/${userId}`);
|
||||||
|
showToast("Opened link in Steam", Toasts.Type.SUCCESS);
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
105
src/plugins/partyMode.ts
Normal file
105
src/plugins/partyMode.ts
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
/*
|
||||||
|
* Vencord, a modification for Discord's desktop app
|
||||||
|
* Copyright (c) 2023 Vendicated and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { definePluginSettings } from "@api/Settings";
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
import { findStoreLazy } from "@webpack";
|
||||||
|
import { GenericStore } from "@webpack/common";
|
||||||
|
|
||||||
|
const PoggerModeSettingsStore: GenericStore = findStoreLazy("PoggermodeSettingsStore");
|
||||||
|
|
||||||
|
const enum Intensity {
|
||||||
|
Normal,
|
||||||
|
Better,
|
||||||
|
ProjectX,
|
||||||
|
}
|
||||||
|
|
||||||
|
const settings = definePluginSettings({
|
||||||
|
superIntensePartyMode: {
|
||||||
|
description: "Party intensity",
|
||||||
|
type: OptionType.SELECT,
|
||||||
|
options: [
|
||||||
|
{ label: "Normal", value: Intensity.Normal, default: true },
|
||||||
|
{ label: "Better", value: Intensity.Better },
|
||||||
|
{ label: "Project X", value: Intensity.ProjectX },
|
||||||
|
],
|
||||||
|
restartNeeded: false,
|
||||||
|
onChange: setSettings
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "Party mode 🎉",
|
||||||
|
description: "Allows you to use party mode cause the party never ends ✨",
|
||||||
|
authors: [Devs.UwUDev],
|
||||||
|
settings,
|
||||||
|
|
||||||
|
start() {
|
||||||
|
setPoggerState(true);
|
||||||
|
setSettings(settings.store.superIntensePartyMode);
|
||||||
|
},
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
setPoggerState(false);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
function setPoggerState(state: boolean) {
|
||||||
|
Object.assign(PoggerModeSettingsStore.__getLocalVars().state, {
|
||||||
|
enabled: state,
|
||||||
|
settingsVisible: state
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function setSettings(intensity: Intensity) {
|
||||||
|
const state = {
|
||||||
|
screenshakeEnabledLocations: { 0: true, 1: true, 2: true },
|
||||||
|
shakeIntensity: 1,
|
||||||
|
confettiSize: 16,
|
||||||
|
confettiCount: 5,
|
||||||
|
combosRequiredCount: 1
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (intensity) {
|
||||||
|
case Intensity.Normal: {
|
||||||
|
Object.assign(state, {
|
||||||
|
screenshakeEnabledLocations: { 0: true, 1: false, 2: false },
|
||||||
|
combosRequiredCount: 5
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Intensity.Better: {
|
||||||
|
Object.assign(state, {
|
||||||
|
confettiSize: 12,
|
||||||
|
confettiCount: 8,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Intensity.ProjectX: {
|
||||||
|
Object.assign(state, {
|
||||||
|
shakeIntensity: 20,
|
||||||
|
confettiSize: 25,
|
||||||
|
confettiCount: 15,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.assign(PoggerModeSettingsStore.__getLocalVars().state, state);
|
||||||
|
}
|
@ -0,0 +1,227 @@
|
|||||||
|
/*
|
||||||
|
* Vencord, a modification for Discord's desktop app
|
||||||
|
* Copyright (c) 2023 Vendicated and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
|
import { Flex } from "@components/Flex";
|
||||||
|
import { InfoIcon, OwnerCrownIcon } from "@components/Icons";
|
||||||
|
import { getUniqueUsername } from "@utils/discord";
|
||||||
|
import { ModalCloseButton, ModalContent, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||||
|
import { ContextMenu, FluxDispatcher, GuildMemberStore, Menu, PermissionsBits, Text, Tooltip, useEffect, UserStore, useState, useStateFromStores } from "@webpack/common";
|
||||||
|
import type { Guild } from "discord-types/general";
|
||||||
|
|
||||||
|
import { settings } from "..";
|
||||||
|
import { cl, getPermissionDescription, getPermissionString } from "../utils";
|
||||||
|
import { PermissionAllowedIcon, PermissionDefaultIcon, PermissionDeniedIcon } from "./icons";
|
||||||
|
|
||||||
|
export const enum PermissionType {
|
||||||
|
Role = 0,
|
||||||
|
User = 1,
|
||||||
|
Owner = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RoleOrUserPermission {
|
||||||
|
type: PermissionType;
|
||||||
|
id?: string;
|
||||||
|
permissions?: bigint;
|
||||||
|
overwriteAllow?: bigint;
|
||||||
|
overwriteDeny?: bigint;
|
||||||
|
}
|
||||||
|
|
||||||
|
function openRolesAndUsersPermissionsModal(permissions: Array<RoleOrUserPermission>, guild: Guild, header: string) {
|
||||||
|
return openModal(modalProps => (
|
||||||
|
<RolesAndUsersPermissions
|
||||||
|
modalProps={modalProps}
|
||||||
|
permissions={permissions}
|
||||||
|
guild={guild}
|
||||||
|
header={header}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
function RolesAndUsersPermissionsComponent({ permissions, guild, modalProps, header }: { permissions: Array<RoleOrUserPermission>; guild: Guild; modalProps: ModalProps; header: string; }) {
|
||||||
|
permissions.sort((a, b) => a.type - b.type);
|
||||||
|
|
||||||
|
useStateFromStores(
|
||||||
|
[GuildMemberStore],
|
||||||
|
() => GuildMemberStore.getMemberIds(guild.id),
|
||||||
|
null,
|
||||||
|
(old, current) => old.length === current.length
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const usersToRequest = permissions
|
||||||
|
.filter(p => p.type === PermissionType.User && !GuildMemberStore.isMember(guild.id, p.id!))
|
||||||
|
.map(({ id }) => id);
|
||||||
|
|
||||||
|
FluxDispatcher.dispatch({
|
||||||
|
type: "GUILD_MEMBERS_REQUEST",
|
||||||
|
guildIds: [guild.id],
|
||||||
|
userIds: usersToRequest
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const [selectedItemIndex, selectItem] = useState(0);
|
||||||
|
const selectedItem = permissions[selectedItemIndex];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ModalRoot
|
||||||
|
{...modalProps}
|
||||||
|
size={ModalSize.LARGE}
|
||||||
|
>
|
||||||
|
<ModalHeader>
|
||||||
|
<Text className={cl("perms-title")} variant="heading-lg/semibold">{header} permissions:</Text>
|
||||||
|
<ModalCloseButton onClick={modalProps.onClose} />
|
||||||
|
</ModalHeader>
|
||||||
|
|
||||||
|
<ModalContent>
|
||||||
|
{!selectedItem && (
|
||||||
|
<div className={cl("perms-no-perms")}>
|
||||||
|
<Text variant="heading-lg/normal">No permissions to display!</Text>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{selectedItem && (
|
||||||
|
<div className={cl("perms-container")}>
|
||||||
|
<div className={cl("perms-list")}>
|
||||||
|
{permissions.map((permission, index) => {
|
||||||
|
const user = UserStore.getUser(permission.id ?? "");
|
||||||
|
const role = guild.roles[permission.id ?? ""];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
className={cl("perms-list-item-btn")}
|
||||||
|
onClick={() => selectItem(index)}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className={cl("perms-list-item", { "perms-list-item-active": selectedItemIndex === index })}
|
||||||
|
onContextMenu={e => {
|
||||||
|
if ((settings.store as any).unsafeViewAsRole && permission.type === PermissionType.Role)
|
||||||
|
ContextMenu.open(e, () => (
|
||||||
|
<RoleContextMenu
|
||||||
|
guild={guild}
|
||||||
|
roleId={permission.id!}
|
||||||
|
onClose={modalProps.onClose}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{(permission.type === PermissionType.Role || permission.type === PermissionType.Owner) && (
|
||||||
|
<span
|
||||||
|
className={cl("perms-role-circle")}
|
||||||
|
style={{ backgroundColor: role?.colorString ?? "var(--primary-300)" }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{permission.type === PermissionType.User && user !== undefined && (
|
||||||
|
<img
|
||||||
|
className={cl("perms-user-img")}
|
||||||
|
src={user.getAvatarURL(void 0, void 0, false)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<Text variant="text-md/normal">
|
||||||
|
{
|
||||||
|
permission.type === PermissionType.Role
|
||||||
|
? role?.name || "Unknown Role"
|
||||||
|
: permission.type === PermissionType.User
|
||||||
|
? (user && getUniqueUsername(user)) || "Unknown User"
|
||||||
|
: (
|
||||||
|
<Flex style={{ gap: "0.2em", justifyItems: "center" }}>
|
||||||
|
@owner
|
||||||
|
<OwnerCrownIcon
|
||||||
|
height={18}
|
||||||
|
width={18}
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</Flex>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
<div className={cl("perms-perms")}>
|
||||||
|
{Object.entries(PermissionsBits).map(([permissionName, bit]) => (
|
||||||
|
<div className={cl("perms-perms-item")}>
|
||||||
|
<div className={cl("perms-perms-item-icon")}>
|
||||||
|
{(() => {
|
||||||
|
const { permissions, overwriteAllow, overwriteDeny } = selectedItem;
|
||||||
|
|
||||||
|
if (permissions)
|
||||||
|
return (permissions & bit) === bit
|
||||||
|
? PermissionAllowedIcon()
|
||||||
|
: PermissionDeniedIcon();
|
||||||
|
|
||||||
|
if (overwriteAllow && (overwriteAllow & bit) === bit)
|
||||||
|
return PermissionAllowedIcon();
|
||||||
|
if (overwriteDeny && (overwriteDeny & bit) === bit)
|
||||||
|
return PermissionDeniedIcon();
|
||||||
|
|
||||||
|
return PermissionDefaultIcon();
|
||||||
|
})()}
|
||||||
|
</div>
|
||||||
|
<Text variant="text-md/normal">{getPermissionString(permissionName)}</Text>
|
||||||
|
|
||||||
|
<Tooltip text={getPermissionDescription(permissionName) || "No Description"}>
|
||||||
|
{props => <InfoIcon {...props} />}
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</ModalContent>
|
||||||
|
</ModalRoot >
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function RoleContextMenu({ guild, roleId, onClose }: { guild: Guild; roleId: string; onClose: () => void; }) {
|
||||||
|
return (
|
||||||
|
<Menu.Menu
|
||||||
|
navId={cl("role-context-menu")}
|
||||||
|
onClose={ContextMenu.close}
|
||||||
|
aria-label="Role Options"
|
||||||
|
>
|
||||||
|
<Menu.MenuItem
|
||||||
|
id="vc-pw-view-as-role"
|
||||||
|
label="View As Role"
|
||||||
|
action={() => {
|
||||||
|
const role = guild.roles[roleId];
|
||||||
|
if (!role) return;
|
||||||
|
|
||||||
|
onClose();
|
||||||
|
|
||||||
|
FluxDispatcher.dispatch({
|
||||||
|
type: "IMPERSONATE_UPDATE",
|
||||||
|
guildId: guild.id,
|
||||||
|
data: {
|
||||||
|
type: "ROLES",
|
||||||
|
roles: {
|
||||||
|
[roleId]: role
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Menu.Menu>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const RolesAndUsersPermissions = ErrorBoundary.wrap(RolesAndUsersPermissionsComponent);
|
||||||
|
|
||||||
|
export default openRolesAndUsersPermissionsModal;
|
159
src/plugins/permissionsViewer/components/UserPermissions.tsx
Normal file
159
src/plugins/permissionsViewer/components/UserPermissions.tsx
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
/*
|
||||||
|
* Vencord, a modification for Discord's desktop app
|
||||||
|
* Copyright (c) 2023 Vendicated and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
|
import ExpandableHeader from "@components/ExpandableHeader";
|
||||||
|
import { proxyLazy } from "@utils/lazy";
|
||||||
|
import { classes } from "@utils/misc";
|
||||||
|
import { filters, findBulk } from "@webpack";
|
||||||
|
import { i18n, PermissionsBits, Text, Tooltip, useMemo, UserStore } from "@webpack/common";
|
||||||
|
import type { Guild, GuildMember } from "discord-types/general";
|
||||||
|
|
||||||
|
import { PermissionsSortOrder, settings } from "..";
|
||||||
|
import { cl, getPermissionString, getSortedRoles, sortUserRoles } from "../utils";
|
||||||
|
import openRolesAndUsersPermissionsModal, { PermissionType, type RoleOrUserPermission } from "./RolesAndUsersPermissions";
|
||||||
|
|
||||||
|
interface UserPermission {
|
||||||
|
permission: string;
|
||||||
|
roleColor: string;
|
||||||
|
rolePosition: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserPermissions = Array<UserPermission>;
|
||||||
|
|
||||||
|
const Classes = proxyLazy(() => {
|
||||||
|
const modules = findBulk(
|
||||||
|
filters.byProps("roles", "rolePill", "rolePillBorder"),
|
||||||
|
filters.byProps("roleCircle", "dotBorderBase", "dotBorderColor"),
|
||||||
|
filters.byProps("roleNameOverflow", "root", "roleName", "roleRemoveButton")
|
||||||
|
);
|
||||||
|
|
||||||
|
return Object.assign({}, ...modules);
|
||||||
|
}) as Record<"roles" | "rolePill" | "rolePillBorder" | "desaturateUserColors" | "flex" | "alignCenter" | "justifyCenter" | "svg" | "background" | "dot" | "dotBorderColor" | "roleCircle" | "dotBorderBase" | "flex" | "alignCenter" | "justifyCenter" | "wrap" | "root" | "role" | "roleRemoveButton" | "roleDot" | "roleFlowerStar" | "roleRemoveIcon" | "roleRemoveIconFocused" | "roleVerifiedIcon" | "roleName" | "roleNameOverflow" | "actionButton" | "overflowButton" | "addButton" | "addButtonIcon" | "overflowRolesPopout" | "overflowRolesPopoutArrowWrapper" | "overflowRolesPopoutArrow" | "popoutBottom" | "popoutTop" | "overflowRolesPopoutHeader" | "overflowRolesPopoutHeaderIcon" | "overflowRolesPopoutHeaderText" | "roleIcon", string>;
|
||||||
|
|
||||||
|
function UserPermissionsComponent({ guild, guildMember }: { guild: Guild; guildMember: GuildMember; }) {
|
||||||
|
const stns = settings.use(["permissionsSortOrder"]);
|
||||||
|
|
||||||
|
const [rolePermissions, userPermissions] = useMemo(() => {
|
||||||
|
const userPermissions: UserPermissions = [];
|
||||||
|
|
||||||
|
const userRoles = getSortedRoles(guild, guildMember);
|
||||||
|
|
||||||
|
const rolePermissions: Array<RoleOrUserPermission> = userRoles.map(role => ({
|
||||||
|
type: PermissionType.Role,
|
||||||
|
...role
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (guild.ownerId === guildMember.userId) {
|
||||||
|
rolePermissions.push({
|
||||||
|
type: PermissionType.Owner,
|
||||||
|
permissions: Object.values(PermissionsBits).reduce((prev, curr) => prev | curr, 0n)
|
||||||
|
});
|
||||||
|
|
||||||
|
const OWNER = i18n.Messages.GUILD_OWNER || "Server Owner";
|
||||||
|
userPermissions.push({
|
||||||
|
permission: OWNER,
|
||||||
|
roleColor: "var(--primary-300)",
|
||||||
|
rolePosition: Infinity
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
sortUserRoles(userRoles);
|
||||||
|
|
||||||
|
for (const [permission, bit] of Object.entries(PermissionsBits)) {
|
||||||
|
for (const { permissions, colorString, position, name } of userRoles) {
|
||||||
|
if ((permissions & bit) === bit) {
|
||||||
|
userPermissions.push({
|
||||||
|
permission: getPermissionString(permission),
|
||||||
|
roleColor: colorString || "var(--primary-300)",
|
||||||
|
rolePosition: position
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
userPermissions.sort((a, b) => b.rolePosition - a.rolePosition);
|
||||||
|
|
||||||
|
return [rolePermissions, userPermissions];
|
||||||
|
}, [stns.permissionsSortOrder]);
|
||||||
|
|
||||||
|
const { root, role, roleRemoveButton, roleNameOverflow, roles, rolePill, rolePillBorder, roleCircle, roleName } = Classes;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ExpandableHeader
|
||||||
|
headerText="Permissions"
|
||||||
|
moreTooltipText="Role Details"
|
||||||
|
onMoreClick={() =>
|
||||||
|
openRolesAndUsersPermissionsModal(
|
||||||
|
rolePermissions,
|
||||||
|
guild,
|
||||||
|
guildMember.nick || UserStore.getUser(guildMember.userId).username
|
||||||
|
)
|
||||||
|
}
|
||||||
|
defaultState={settings.store.defaultPermissionsDropdownState}
|
||||||
|
buttons={[
|
||||||
|
(<Tooltip text={`Sorting by ${stns.permissionsSortOrder === PermissionsSortOrder.HighestRole ? "Highest Role" : "Lowest Role"}`}>
|
||||||
|
{tooltipProps => (
|
||||||
|
<button
|
||||||
|
{...tooltipProps}
|
||||||
|
className={cl("userperms-sortorder-btn")}
|
||||||
|
onClick={() => {
|
||||||
|
stns.permissionsSortOrder = stns.permissionsSortOrder === PermissionsSortOrder.HighestRole ? PermissionsSortOrder.LowestRole : PermissionsSortOrder.HighestRole;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
width="20"
|
||||||
|
height="20"
|
||||||
|
viewBox="0 96 960 960"
|
||||||
|
transform={stns.permissionsSortOrder === PermissionsSortOrder.HighestRole ? "scale(1 1)" : "scale(1 -1)"}
|
||||||
|
>
|
||||||
|
<path fill="var(--text-normal)" d="M440 896V409L216 633l-56-57 320-320 320 320-56 57-224-224v487h-80Z" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</Tooltip>)
|
||||||
|
]}>
|
||||||
|
{userPermissions.length > 0 && (
|
||||||
|
<div className={classes(root, roles)}>
|
||||||
|
{userPermissions.map(({ permission, roleColor }) => (
|
||||||
|
<div className={classes(role, rolePill, rolePillBorder)}>
|
||||||
|
<div className={roleRemoveButton}>
|
||||||
|
<span
|
||||||
|
className={roleCircle}
|
||||||
|
style={{ backgroundColor: roleColor }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className={roleName}>
|
||||||
|
<Text
|
||||||
|
className={roleNameOverflow}
|
||||||
|
variant="text-xs/medium"
|
||||||
|
>
|
||||||
|
{permission}
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</ExpandableHeader>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ErrorBoundary.wrap(UserPermissionsComponent, { noop: true });
|
58
src/plugins/permissionsViewer/components/icons.tsx
Normal file
58
src/plugins/permissionsViewer/components/icons.tsx
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Vencord, a modification for Discord's desktop app
|
||||||
|
* Copyright (c) 2023 Vendicated and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export function PermissionDeniedIcon() {
|
||||||
|
return (
|
||||||
|
<svg
|
||||||
|
height="24"
|
||||||
|
width="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<title>Denied</title>
|
||||||
|
<path fill="var(--status-danger)" d="M18.4 4L12 10.4L5.6 4L4 5.6L10.4 12L4 18.4L5.6 20L12 13.6L18.4 20L20 18.4L13.6 12L20 5.6L18.4 4Z" />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function PermissionAllowedIcon() {
|
||||||
|
return (
|
||||||
|
<svg
|
||||||
|
height="24"
|
||||||
|
width="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<title>Allowed</title>
|
||||||
|
<path fill="var(--text-positive)" d="M8.99991 16.17L4.82991 12L3.40991 13.41L8.99991 19L20.9999 7.00003L19.5899 5.59003L8.99991 16.17ZZ" />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function PermissionDefaultIcon() {
|
||||||
|
return (
|
||||||
|
<svg
|
||||||
|
height="24"
|
||||||
|
width="24"
|
||||||
|
viewBox="0 0 16 16"
|
||||||
|
>
|
||||||
|
<g>
|
||||||
|
<title>Not overwritten</title>
|
||||||
|
<polygon fill="var(--text-normal)" points="12 2.32 10.513 2 4 13.68 5.487 14" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
189
src/plugins/permissionsViewer/index.tsx
Normal file
189
src/plugins/permissionsViewer/index.tsx
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
/*
|
||||||
|
* Vencord, a modification for Discord's desktop app
|
||||||
|
* Copyright (c) 2023 Vendicated and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import "./styles.css";
|
||||||
|
|
||||||
|
import { addContextMenuPatch, findGroupChildrenByChildId, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
|
||||||
|
import { definePluginSettings } from "@api/Settings";
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
import { ChannelStore, GuildMemberStore, GuildStore, Menu, PermissionsBits, UserStore } from "@webpack/common";
|
||||||
|
import type { Guild, GuildMember } from "discord-types/general";
|
||||||
|
|
||||||
|
import openRolesAndUsersPermissionsModal, { PermissionType, RoleOrUserPermission } from "./components/RolesAndUsersPermissions";
|
||||||
|
import UserPermissions from "./components/UserPermissions";
|
||||||
|
import { getSortedRoles, sortPermissionOverwrites } from "./utils";
|
||||||
|
|
||||||
|
export const enum PermissionsSortOrder {
|
||||||
|
HighestRole,
|
||||||
|
LowestRole
|
||||||
|
}
|
||||||
|
|
||||||
|
const enum MenuItemParentType {
|
||||||
|
User,
|
||||||
|
Channel,
|
||||||
|
Guild
|
||||||
|
}
|
||||||
|
|
||||||
|
export const settings = definePluginSettings({
|
||||||
|
permissionsSortOrder: {
|
||||||
|
description: "The sort method used for defining which role grants an user a certain permission",
|
||||||
|
type: OptionType.SELECT,
|
||||||
|
options: [
|
||||||
|
{ label: "Highest Role", value: PermissionsSortOrder.HighestRole, default: true },
|
||||||
|
{ label: "Lowest Role", value: PermissionsSortOrder.LowestRole }
|
||||||
|
],
|
||||||
|
},
|
||||||
|
defaultPermissionsDropdownState: {
|
||||||
|
description: "Whether the permissions dropdown on user popouts should be open by default",
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
default: false,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function MenuItem(guildId: string, id?: string, type?: MenuItemParentType) {
|
||||||
|
if (type === MenuItemParentType.User && !GuildMemberStore.isMember(guildId, id!)) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Menu.MenuItem
|
||||||
|
id="perm-viewer-permissions"
|
||||||
|
label="Permissions"
|
||||||
|
action={() => {
|
||||||
|
const guild = GuildStore.getGuild(guildId);
|
||||||
|
|
||||||
|
let permissions: RoleOrUserPermission[];
|
||||||
|
let header: string;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case MenuItemParentType.User: {
|
||||||
|
const member = GuildMemberStore.getMember(guildId, id!);
|
||||||
|
|
||||||
|
permissions = getSortedRoles(guild, member)
|
||||||
|
.map(role => ({
|
||||||
|
type: PermissionType.Role,
|
||||||
|
...role
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (guild.ownerId === id) {
|
||||||
|
permissions.push({
|
||||||
|
type: PermissionType.Owner,
|
||||||
|
permissions: Object.values(PermissionsBits).reduce((prev, curr) => prev | curr, 0n)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
header = member.nick ?? UserStore.getUser(member.userId).username;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case MenuItemParentType.Channel: {
|
||||||
|
const channel = ChannelStore.getChannel(id!);
|
||||||
|
|
||||||
|
permissions = sortPermissionOverwrites(Object.values(channel.permissionOverwrites).map(({ id, allow, deny, type }) => ({
|
||||||
|
type: type as PermissionType,
|
||||||
|
id,
|
||||||
|
overwriteAllow: allow,
|
||||||
|
overwriteDeny: deny
|
||||||
|
})), guildId);
|
||||||
|
|
||||||
|
header = channel.name;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
permissions = Object.values(guild.roles).map(role => ({
|
||||||
|
type: PermissionType.Role,
|
||||||
|
...role
|
||||||
|
}));
|
||||||
|
|
||||||
|
header = guild.name;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
openRolesAndUsersPermissionsModal(permissions, guild, header);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeContextMenuPatch(childId: string | string[], type?: MenuItemParentType): NavContextMenuPatchCallback {
|
||||||
|
return (children, props) => () => {
|
||||||
|
if (!props) return children;
|
||||||
|
|
||||||
|
const group = findGroupChildrenByChildId(childId, children);
|
||||||
|
|
||||||
|
const item = (() => {
|
||||||
|
switch (type) {
|
||||||
|
case MenuItemParentType.User:
|
||||||
|
return MenuItem(props.guildId, props.user.id, type);
|
||||||
|
case MenuItemParentType.Channel:
|
||||||
|
return MenuItem(props.guild.id, props.channel.id, type);
|
||||||
|
case MenuItemParentType.Guild:
|
||||||
|
return MenuItem(props.guild.id);
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
if (item == null) return;
|
||||||
|
|
||||||
|
if (group)
|
||||||
|
group.push(item);
|
||||||
|
else if (childId === "roles" && props.guildId)
|
||||||
|
// "roles" may not be present due to the member not having any roles. In that case, add it above "Copy ID"
|
||||||
|
children.splice(-1, 0, <Menu.MenuGroup>{item}</Menu.MenuGroup>);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "PermissionsViewer",
|
||||||
|
description: "View the permissions a user or channel has, and the roles of a server",
|
||||||
|
authors: [Devs.Nuckyz, Devs.Ven],
|
||||||
|
settings,
|
||||||
|
|
||||||
|
patches: [
|
||||||
|
{
|
||||||
|
find: ".Messages.BOT_PROFILE_SLASH_COMMANDS",
|
||||||
|
replacement: {
|
||||||
|
match: /showBorder:.{0,60}}\),(?<=guild:(\i),guildMember:(\i),.+?)/,
|
||||||
|
replace: (m, guild, guildMember) => `${m}$self.UserPermissions(${guild},${guildMember}),`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
UserPermissions: (guild: Guild, guildMember?: GuildMember) => !!guildMember && <UserPermissions guild={guild} guildMember={guildMember} />,
|
||||||
|
|
||||||
|
userContextMenuPatch: makeContextMenuPatch("roles", MenuItemParentType.User),
|
||||||
|
channelContextMenuPatch: makeContextMenuPatch(["mute-channel", "unmute-channel"], MenuItemParentType.Channel),
|
||||||
|
guildContextMenuPatch: makeContextMenuPatch("privacy", MenuItemParentType.Guild),
|
||||||
|
|
||||||
|
start() {
|
||||||
|
addContextMenuPatch("user-context", this.userContextMenuPatch);
|
||||||
|
addContextMenuPatch("channel-context", this.channelContextMenuPatch);
|
||||||
|
addContextMenuPatch("guild-context", this.guildContextMenuPatch);
|
||||||
|
},
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
removeContextMenuPatch("user-context", this.userContextMenuPatch);
|
||||||
|
removeContextMenuPatch("channel-context", this.channelContextMenuPatch);
|
||||||
|
removeContextMenuPatch("guild-context", this.guildContextMenuPatch);
|
||||||
|
},
|
||||||
|
});
|
151
src/plugins/permissionsViewer/styles.css
Normal file
151
src/plugins/permissionsViewer/styles.css
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
/* User Permissions Component */
|
||||||
|
|
||||||
|
.vc-permviewer-userperms-title-container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-top: 10px;
|
||||||
|
margin-bottom: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-userperms-btns-container {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-userperms-sortorder-btn {
|
||||||
|
all: unset;
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-userperms-permdetails-btn {
|
||||||
|
all: unset;
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-userperms-toggleperms-btn {
|
||||||
|
all: unset;
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* RolesAndUsersPermissions Component */
|
||||||
|
|
||||||
|
.vc-permviewer-perms-title {
|
||||||
|
flex-grow: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-perms-no-perms {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-perms-container {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 2fr;
|
||||||
|
grid-template-areas: "list permissions";
|
||||||
|
padding: 16px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-perms-list {
|
||||||
|
grid-area: list;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
border-right: 2px solid var(--background-modifier-active);
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-perms-list-item-btn {
|
||||||
|
all: unset;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-perms-list-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 8px 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
width: 230px;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-perms-list-item:hover {
|
||||||
|
background-color: var(--background-modifier-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-perms-list-item-active {
|
||||||
|
background-color: var(--background-modifier-selected);
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-perms-list-item > div {
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-perms-role-circle {
|
||||||
|
border-radius: 50%;
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
margin-left: 3px;
|
||||||
|
margin-right: 11px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-perms-user-img {
|
||||||
|
border-radius: 50%;
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
margin-right: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-perms-perms {
|
||||||
|
grid-area: permissions;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-perms-perms-item {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 10px;
|
||||||
|
border-bottom: 2px solid var(--background-modifier-active);
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-perms-perms-item:last-child {
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-perms-perms-item-icon {
|
||||||
|
border: 1px solid var(--background-modifier-selected);
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-perms-perms-item .vc-info-icon {
|
||||||
|
color: var(--interactive-muted);
|
||||||
|
cursor: pointer;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
scale: 0.9;
|
||||||
|
transition: color ease-in 0.1s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-perms-perms-item .vc-info-icon:hover {
|
||||||
|
color: var(--interactive-active);
|
||||||
|
}
|
98
src/plugins/permissionsViewer/utils.ts
Normal file
98
src/plugins/permissionsViewer/utils.ts
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
/*
|
||||||
|
* Vencord, a modification for Discord's desktop app
|
||||||
|
* Copyright (c) 2023 Vendicated and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { classNameFactory } from "@api/Styles";
|
||||||
|
import { wordsToTitle } from "@utils/text";
|
||||||
|
import { GuildStore, i18n, Parser } from "@webpack/common";
|
||||||
|
import { Guild, GuildMember, Role } from "discord-types/general";
|
||||||
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
import { PermissionsSortOrder, settings } from ".";
|
||||||
|
import { PermissionType } from "./components/RolesAndUsersPermissions";
|
||||||
|
|
||||||
|
export const cl = classNameFactory("vc-permviewer-");
|
||||||
|
|
||||||
|
function formatPermissionWithoutMatchingString(permission: string) {
|
||||||
|
return wordsToTitle(permission.toLowerCase().split("_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// because discord is unable to be consistent with their names
|
||||||
|
const PermissionKeyMap = {
|
||||||
|
MANAGE_GUILD: "MANAGE_SERVER",
|
||||||
|
MANAGE_GUILD_EXPRESSIONS: "MANAGE_EXPRESSIONS",
|
||||||
|
CREATE_GUILD_EXPRESSIONS: "CREATE_EXPRESSIONS",
|
||||||
|
MODERATE_MEMBERS: "MODERATE_MEMBER", // HELLOOOO ??????
|
||||||
|
STREAM: "VIDEO",
|
||||||
|
SEND_VOICE_MESSAGES: "ROLE_PERMISSIONS_SEND_VOICE_MESSAGE",
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export function getPermissionString(permission: string) {
|
||||||
|
permission = PermissionKeyMap[permission] || permission;
|
||||||
|
|
||||||
|
return i18n.Messages[permission] ||
|
||||||
|
// shouldn't get here but just in case
|
||||||
|
formatPermissionWithoutMatchingString(permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getPermissionDescription(permission: string): ReactNode {
|
||||||
|
// DISCORD PLEEEEEEEEAAAAASE IM BEGGING YOU :(
|
||||||
|
if (permission === "USE_APPLICATION_COMMANDS")
|
||||||
|
permission = "USE_APPLICATION_COMMANDS_GUILD";
|
||||||
|
else if (permission === "SEND_VOICE_MESSAGES")
|
||||||
|
permission = "SEND_VOICE_MESSAGE_GUILD";
|
||||||
|
else if (permission !== "STREAM")
|
||||||
|
permission = PermissionKeyMap[permission] || permission;
|
||||||
|
|
||||||
|
const msg = i18n.Messages[`ROLE_PERMISSIONS_${permission}_DESCRIPTION`] as any;
|
||||||
|
if (msg?.hasMarkdown)
|
||||||
|
return Parser.parse(msg.message);
|
||||||
|
|
||||||
|
if (typeof msg === "string") return msg;
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getSortedRoles({ roles, id }: Guild, member: GuildMember) {
|
||||||
|
return [...member.roles, id]
|
||||||
|
.map(id => roles[id])
|
||||||
|
.sort((a, b) => b.position - a.position);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function sortUserRoles(roles: Role[]) {
|
||||||
|
switch (settings.store.permissionsSortOrder) {
|
||||||
|
case PermissionsSortOrder.HighestRole:
|
||||||
|
return roles.sort((a, b) => b.position - a.position);
|
||||||
|
case PermissionsSortOrder.LowestRole:
|
||||||
|
return roles.sort((a, b) => a.position - b.position);
|
||||||
|
default:
|
||||||
|
return roles;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function sortPermissionOverwrites<T extends { id: string; type: number; }>(overwrites: T[], guildId: string) {
|
||||||
|
const guild = GuildStore.getGuild(guildId);
|
||||||
|
|
||||||
|
return overwrites.sort((a, b) => {
|
||||||
|
if (a.type !== PermissionType.Role || b.type !== PermissionType.Role) return 0;
|
||||||
|
|
||||||
|
const roleA = guild.roles[a.id];
|
||||||
|
const roleB = guild.roles[b.id];
|
||||||
|
|
||||||
|
return roleB.position - roleA.position;
|
||||||
|
});
|
||||||
|
}
|
@ -29,15 +29,15 @@ import { User } from "discord-types/general";
|
|||||||
|
|
||||||
const SessionsStore = findStoreLazy("SessionsStore");
|
const SessionsStore = findStoreLazy("SessionsStore");
|
||||||
|
|
||||||
function Icon(path: string, viewBox = "0 0 24 24") {
|
function Icon(path: string, opts?: { viewBox?: string; width?: number; height?: number; }) {
|
||||||
return ({ color, tooltip }: { color: string; tooltip: string; }) => (
|
return ({ color, tooltip }: { color: string; tooltip: string; }) => (
|
||||||
<Tooltip text={tooltip} >
|
<Tooltip text={tooltip} >
|
||||||
{(tooltipProps: any) => (
|
{(tooltipProps: any) => (
|
||||||
<svg
|
<svg
|
||||||
{...tooltipProps}
|
{...tooltipProps}
|
||||||
height="20"
|
height={opts?.height ?? 20}
|
||||||
width="20"
|
width={opts?.width ?? 20}
|
||||||
viewBox={viewBox}
|
viewBox={opts?.viewBox ?? "0 0 24 24"}
|
||||||
fill={color}
|
fill={color}
|
||||||
>
|
>
|
||||||
<path d={path} />
|
<path d={path} />
|
||||||
@ -50,8 +50,8 @@ function Icon(path: string, viewBox = "0 0 24 24") {
|
|||||||
const Icons = {
|
const Icons = {
|
||||||
desktop: Icon("M4 2.5c-1.103 0-2 .897-2 2v11c0 1.104.897 2 2 2h7v2H7v2h10v-2h-4v-2h7c1.103 0 2-.896 2-2v-11c0-1.103-.897-2-2-2H4Zm16 2v9H4v-9h16Z"),
|
desktop: Icon("M4 2.5c-1.103 0-2 .897-2 2v11c0 1.104.897 2 2 2h7v2H7v2h10v-2h-4v-2h7c1.103 0 2-.896 2-2v-11c0-1.103-.897-2-2-2H4Zm16 2v9H4v-9h16Z"),
|
||||||
web: Icon("M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2Zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93Zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39Z"),
|
web: Icon("M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2Zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93Zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39Z"),
|
||||||
mobile: Icon("M15.5 1h-8A2.5 2.5 0 0 0 5 3.5v17A2.5 2.5 0 0 0 7.5 23h8a2.5 2.5 0 0 0 2.5-2.5v-17A2.5 2.5 0 0 0 15.5 1zm-4 21c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm4.5-4H7V4h9v14z"),
|
mobile: Icon("M 187 0 L 813 0 C 916.277 0 1000 83.723 1000 187 L 1000 1313 C 1000 1416.277 916.277 1500 813 1500 L 187 1500 C 83.723 1500 0 1416.277 0 1313 L 0 187 C 0 83.723 83.723 0 187 0 Z M 125 1000 L 875 1000 L 875 250 L 125 250 Z M 500 1125 C 430.964 1125 375 1180.964 375 1250 C 375 1319.036 430.964 1375 500 1375 C 569.036 1375 625 1319.036 625 1250 C 625 1180.964 569.036 1125 500 1125 Z", { viewBox: "0 0 1000 1500", height: 17, width: 17 }),
|
||||||
console: Icon("M14.8 2.7 9 3.1V47h3.3c1.7 0 6.2.3 10 .7l6.7.6V2l-4.2.2c-2.4.1-6.9.3-10 .5zm1.8 6.4c1 1.7-1.3 3.6-2.7 2.2C12.7 10.1 13.5 8 15 8c.5 0 1.2.5 1.6 1.1zM16 33c0 6-.4 10-1 10s-1-4-1-10 .4-10 1-10 1 4 1 10zm15-8v23.3l3.8-.7c2-.3 4.7-.6 6-.6H43V3h-2.2c-1.3 0-4-.3-6-.6L31 1.7V25z", "0 0 50 50"),
|
console: Icon("M14.8 2.7 9 3.1V47h3.3c1.7 0 6.2.3 10 .7l6.7.6V2l-4.2.2c-2.4.1-6.9.3-10 .5zm1.8 6.4c1 1.7-1.3 3.6-2.7 2.2C12.7 10.1 13.5 8 15 8c.5 0 1.2.5 1.6 1.1zM16 33c0 6-.4 10-1 10s-1-4-1-10 .4-10 1-10 1 4 1 10zm15-8v23.3l3.8-.7c2-.3 4.7-.6 6-.6H43V3h-2.2c-1.3 0-4-.3-6-.6L31 1.7V25z", { viewBox: "0 0 50 50" }),
|
||||||
};
|
};
|
||||||
type Platform = keyof typeof Icons;
|
type Platform = keyof typeof Icons;
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ const PlatformIcon = ({ platform, status }: { platform: Platform, status: string
|
|||||||
|
|
||||||
const getStatus = (id: string): Record<Platform, string> => PresenceStore.getState()?.clientStatuses?.[id];
|
const getStatus = (id: string): Record<Platform, string> => PresenceStore.getState()?.clientStatuses?.[id];
|
||||||
|
|
||||||
const PlatformIndicator = ({ user, wantMargin = true }: { user: User; wantMargin?: boolean; }) => {
|
const PlatformIndicator = ({ user, wantMargin = true, wantTopMargin = false }: { user: User; wantMargin?: boolean; wantTopMargin?: boolean; }) => {
|
||||||
if (!user || user.bot) return null;
|
if (!user || user.bot) return null;
|
||||||
|
|
||||||
if (user.id === UserStore.getCurrentUser().id) {
|
if (user.id === UserStore.getCurrentUser().id) {
|
||||||
@ -110,12 +110,13 @@ const PlatformIndicator = ({ user, wantMargin = true }: { user: User; wantMargin
|
|||||||
style={{
|
style={{
|
||||||
display: "inline-flex",
|
display: "inline-flex",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
marginLeft: wantMargin ? 4 : 0,
|
marginLeft: wantMargin ? 4 : 0,
|
||||||
verticalAlign: "top",
|
verticalAlign: "top",
|
||||||
position: "relative",
|
position: "relative",
|
||||||
top: wantMargin ? 1 : 0,
|
top: wantTopMargin ? 2 : 0,
|
||||||
padding: !wantMargin ? 2 : 0,
|
padding: !wantMargin ? 1 : 0,
|
||||||
gap: 4
|
gap: 2
|
||||||
}}
|
}}
|
||||||
|
|
||||||
>
|
>
|
||||||
@ -150,7 +151,7 @@ const indicatorLocations = {
|
|||||||
description: "Inside messages",
|
description: "Inside messages",
|
||||||
onEnable: () => addDecoration("platform-indicator", props =>
|
onEnable: () => addDecoration("platform-indicator", props =>
|
||||||
<ErrorBoundary noop>
|
<ErrorBoundary noop>
|
||||||
<PlatformIndicator user={props.message?.author} />
|
<PlatformIndicator user={props.message?.author} wantTopMargin={true} />
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
),
|
),
|
||||||
onDisable: () => removeDecoration("platform-indicator")
|
onDisable: () => removeDecoration("platform-indicator")
|
||||||
@ -160,7 +161,7 @@ const indicatorLocations = {
|
|||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "PlatformIndicators",
|
name: "PlatformIndicators",
|
||||||
description: "Adds platform indicators (Desktop, Mobile, Web...) to users",
|
description: "Adds platform indicators (Desktop, Mobile, Web...) to users",
|
||||||
authors: [Devs.kemo, Devs.TheSun, Devs.Nuckyz],
|
authors: [Devs.kemo, Devs.TheSun, Devs.Nuckyz, Devs.Ven],
|
||||||
dependencies: ["MessageDecorationsAPI", "MemberListDecoratorsAPI"],
|
dependencies: ["MessageDecorationsAPI", "MemberListDecoratorsAPI"],
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
|
@ -26,10 +26,12 @@ import { settings } from "../settings";
|
|||||||
|
|
||||||
const styles: Record<string, string> = findByPropsLazy("timestampInline");
|
const styles: Record<string, string> = findByPropsLazy("timestampInline");
|
||||||
|
|
||||||
|
const AUTO_MODERATION_ACTION = 24;
|
||||||
|
|
||||||
function shouldShow(message: Message): boolean {
|
function shouldShow(message: Message): boolean {
|
||||||
if (!settings.store.showInMessages)
|
if (!settings.store.showInMessages)
|
||||||
return false;
|
return false;
|
||||||
if (message.author.bot || message.author.system)
|
if (message.author.bot || message.author.system || message.type === AUTO_MODERATION_ACTION)
|
||||||
return false;
|
return false;
|
||||||
if (!settings.store.showSelf && message.author.id === UserStore.getCurrentUser().id)
|
if (!settings.store.showSelf && message.author.id === UserStore.getCurrentUser().id)
|
||||||
return false;
|
return false;
|
||||||
@ -50,7 +52,7 @@ export function CompactPronounsChatComponentWrapper({ message }: { message: Mess
|
|||||||
}
|
}
|
||||||
|
|
||||||
function PronounsChatComponent({ message }: { message: Message; }) {
|
function PronounsChatComponent({ message }: { message: Message; }) {
|
||||||
const result = useFormattedPronouns(message.author.id);
|
const [result] = useFormattedPronouns(message.author.id);
|
||||||
|
|
||||||
return result
|
return result
|
||||||
? (
|
? (
|
||||||
@ -62,7 +64,7 @@ function PronounsChatComponent({ message }: { message: Message; }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function CompactPronounsChatComponent({ message }: { message: Message; }) {
|
export function CompactPronounsChatComponent({ message }: { message: Message; }) {
|
||||||
const result = useFormattedPronouns(message.author.id);
|
const [result] = useFormattedPronouns(message.author.id);
|
||||||
|
|
||||||
return result
|
return result
|
||||||
? (
|
? (
|
||||||
|
@ -26,6 +26,11 @@ import { CompactPronounsChatComponentWrapper, PronounsChatComponentWrapper } fro
|
|||||||
import { useProfilePronouns } from "./pronoundbUtils";
|
import { useProfilePronouns } from "./pronoundbUtils";
|
||||||
import { settings } from "./settings";
|
import { settings } from "./settings";
|
||||||
|
|
||||||
|
const PRONOUN_TOOLTIP_PATCH = {
|
||||||
|
match: /text:(.{0,10}.Messages\.USER_PROFILE_PRONOUNS)(?=,)/,
|
||||||
|
replace: '$& + (typeof vcPronounSource !== "undefined" ? ` (${vcPronounSource})` : "")'
|
||||||
|
};
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "PronounDB",
|
name: "PronounDB",
|
||||||
authors: [Devs.Tyman, Devs.TheKodeToad, Devs.Ven],
|
authors: [Devs.Tyman, Devs.TheKodeToad, Devs.Ven],
|
||||||
@ -50,18 +55,24 @@ export default definePlugin({
|
|||||||
// Patch the profile popout username header to use our pronoun hook instead of Discord's pronouns
|
// Patch the profile popout username header to use our pronoun hook instead of Discord's pronouns
|
||||||
{
|
{
|
||||||
find: ".userTagNoNickname",
|
find: ".userTagNoNickname",
|
||||||
replacement: {
|
replacement: [
|
||||||
match: /=(\i)\.pronouns/,
|
{
|
||||||
replace: "=$self.useProfilePronouns($1.user.id)"
|
match: /,(\i)=(\i)\.pronouns/,
|
||||||
}
|
replace: ",[$1,vcPronounSource]=$self.useProfilePronouns($2.user.id)"
|
||||||
|
},
|
||||||
|
PRONOUN_TOOLTIP_PATCH
|
||||||
|
]
|
||||||
},
|
},
|
||||||
// Patch the profile modal username header to use our pronoun hook instead of Discord's pronouns
|
// Patch the profile modal username header to use our pronoun hook instead of Discord's pronouns
|
||||||
{
|
{
|
||||||
find: ".USER_PROFILE_ACTIVITY",
|
find: ".USER_PROFILE_ACTIVITY",
|
||||||
replacement: {
|
replacement: [
|
||||||
match: /\).showPronouns/,
|
{
|
||||||
replace: ").showPronouns||true;const vcPronounce=$self.useProfilePronouns(arguments[0].user.id);if(arguments[0].displayProfile)arguments[0].displayProfile.pronouns=vcPronounce"
|
match: /getGlobalName\(\i\);(?<=displayProfile.{0,200})/,
|
||||||
}
|
replace: "$&const [vcPronounce,vcPronounSource]=$self.useProfilePronouns(arguments[0].user.id);if(arguments[0].displayProfile&&vcPronounce)arguments[0].displayProfile.pronouns=vcPronounce;"
|
||||||
|
},
|
||||||
|
PRONOUN_TOOLTIP_PATCH
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
@ -19,17 +19,29 @@
|
|||||||
import { Settings } from "@api/Settings";
|
import { Settings } from "@api/Settings";
|
||||||
import { VENCORD_USER_AGENT } from "@utils/constants";
|
import { VENCORD_USER_AGENT } from "@utils/constants";
|
||||||
import { debounce } from "@utils/debounce";
|
import { debounce } from "@utils/debounce";
|
||||||
|
import { getCurrentChannel } from "@utils/discord";
|
||||||
import { useAwaiter } from "@utils/react";
|
import { useAwaiter } from "@utils/react";
|
||||||
|
import { findStoreLazy } from "@webpack";
|
||||||
import { UserStore } from "@webpack/common";
|
import { UserStore } from "@webpack/common";
|
||||||
|
|
||||||
import { settings } from "./settings";
|
import { settings } from "./settings";
|
||||||
import { PronounCode, PronounMapping, PronounsResponse } from "./types";
|
import { PronounCode, PronounMapping, PronounsResponse } from "./types";
|
||||||
|
|
||||||
|
const UserProfileStore = findStoreLazy("UserProfileStore");
|
||||||
|
|
||||||
|
type PronounsWithSource = [string | null, string];
|
||||||
|
const EmptyPronouns: PronounsWithSource = [null, ""];
|
||||||
|
|
||||||
export const enum PronounsFormat {
|
export const enum PronounsFormat {
|
||||||
Lowercase = "LOWERCASE",
|
Lowercase = "LOWERCASE",
|
||||||
Capitalized = "CAPITALIZED"
|
Capitalized = "CAPITALIZED"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const enum PronounSource {
|
||||||
|
PreferPDB,
|
||||||
|
PreferDiscord
|
||||||
|
}
|
||||||
|
|
||||||
// A map of cached pronouns so the same request isn't sent twice
|
// A map of cached pronouns so the same request isn't sent twice
|
||||||
const cache: Record<string, PronounCode> = {};
|
const cache: Record<string, PronounCode> = {};
|
||||||
// A map of ids and callbacks that should be triggered on fetch
|
// A map of ids and callbacks that should be triggered on fetch
|
||||||
@ -46,46 +58,63 @@ const bulkFetch = debounce(async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export function useFormattedPronouns(id: string): string | null {
|
function getDiscordPronouns(id: string) {
|
||||||
|
return (
|
||||||
|
UserProfileStore.getGuildMemberProfile(id, getCurrentChannel()?.guild_id)?.pronouns
|
||||||
|
|| UserProfileStore.getUserProfile(id)?.pronouns
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useFormattedPronouns(id: string): PronounsWithSource {
|
||||||
|
// Discord is so stupid you can put tons of newlines in pronouns
|
||||||
|
const discordPronouns = getDiscordPronouns(id)?.trim().replace(NewLineRe, " ");
|
||||||
|
|
||||||
const [result] = useAwaiter(() => fetchPronouns(id), {
|
const [result] = useAwaiter(() => fetchPronouns(id), {
|
||||||
fallbackValue: getCachedPronouns(id),
|
fallbackValue: getCachedPronouns(id),
|
||||||
onError: e => console.error("Fetching pronouns failed: ", e)
|
onError: e => console.error("Fetching pronouns failed: ", e)
|
||||||
});
|
});
|
||||||
|
|
||||||
// If the result is present and not "unspecified", and there is a mapping for the code, then return the mappings
|
if (settings.store.pronounSource === PronounSource.PreferDiscord && discordPronouns)
|
||||||
if (result && result !== "unspecified" && PronounMapping[result])
|
return [discordPronouns, "Discord"];
|
||||||
return formatPronouns(result);
|
|
||||||
|
|
||||||
return null;
|
if (result && result !== "unspecified")
|
||||||
|
return [formatPronouns(result), "PronounDB"];
|
||||||
|
|
||||||
|
return [discordPronouns, "Discord"];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useProfilePronouns(id: string) {
|
export function useProfilePronouns(id: string): PronounsWithSource {
|
||||||
const pronouns = useFormattedPronouns(id);
|
const pronouns = useFormattedPronouns(id);
|
||||||
|
|
||||||
if (!settings.store.showInProfile) return null;
|
if (!settings.store.showInProfile) return EmptyPronouns;
|
||||||
if (!settings.store.showSelf && id === UserStore.getCurrentUser().id) return null;
|
if (!settings.store.showSelf && id === UserStore.getCurrentUser().id) return EmptyPronouns;
|
||||||
|
|
||||||
return pronouns;
|
return pronouns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const NewLineRe = /\n+/g;
|
||||||
|
|
||||||
// Gets the cached pronouns, if you're too impatient for a promise!
|
// Gets the cached pronouns, if you're too impatient for a promise!
|
||||||
export function getCachedPronouns(id: string): PronounCode | null {
|
export function getCachedPronouns(id: string): string | null {
|
||||||
return cache[id] ?? null;
|
const cached = cache[id];
|
||||||
|
if (cached && cached !== "unspecified") return cached;
|
||||||
|
|
||||||
|
return cached || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetches the pronouns for one id, returning a promise that resolves if it was cached, or once the request is completed
|
// Fetches the pronouns for one id, returning a promise that resolves if it was cached, or once the request is completed
|
||||||
export function fetchPronouns(id: string): Promise<PronounCode> {
|
export function fetchPronouns(id: string): Promise<string> {
|
||||||
return new Promise(res => {
|
return new Promise(res => {
|
||||||
// If cached, return the cached pronouns
|
const cached = getCachedPronouns(id);
|
||||||
if (id in cache) res(getCachedPronouns(id)!);
|
if (cached) return res(cached);
|
||||||
|
|
||||||
// If there is already a request added, then just add this callback to it
|
// If there is already a request added, then just add this callback to it
|
||||||
else if (id in requestQueue) requestQueue[id].push(res);
|
if (id in requestQueue) return requestQueue[id].push(res);
|
||||||
|
|
||||||
// If not already added, then add it and call the debounced function to make sure the request gets executed
|
// If not already added, then add it and call the debounced function to make sure the request gets executed
|
||||||
else {
|
requestQueue[id] = [res];
|
||||||
requestQueue[id] = [res];
|
bulkFetch();
|
||||||
bulkFetch();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +145,7 @@ async function bulkFetchPronouns(ids: string[]): Promise<PronounsResponse> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatPronouns(pronouns: PronounCode): string {
|
export function formatPronouns(pronouns: string): string {
|
||||||
const { pronounsFormat } = Settings.plugins.PronounDB as { pronounsFormat: PronounsFormat, enabled: boolean; };
|
const { pronounsFormat } = Settings.plugins.PronounDB as { pronounsFormat: PronounsFormat, enabled: boolean; };
|
||||||
// For capitalized pronouns, just return the mapping (it is by default capitalized)
|
// For capitalized pronouns, just return the mapping (it is by default capitalized)
|
||||||
if (pronounsFormat === PronounsFormat.Capitalized) return PronounMapping[pronouns];
|
if (pronounsFormat === PronounsFormat.Capitalized) return PronounMapping[pronouns];
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { OptionType } from "@utils/types";
|
import { OptionType } from "@utils/types";
|
||||||
|
|
||||||
import { PronounsFormat } from "./pronoundbUtils";
|
import { PronounsFormat, PronounSource } from "./pronoundbUtils";
|
||||||
|
|
||||||
export const settings = definePluginSettings({
|
export const settings = definePluginSettings({
|
||||||
pronounsFormat: {
|
pronounsFormat: {
|
||||||
@ -37,6 +37,21 @@ export const settings = definePluginSettings({
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
pronounSource: {
|
||||||
|
type: OptionType.SELECT,
|
||||||
|
description: "Where to source pronouns from",
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: "Prefer PronounDB, fall back to Discord",
|
||||||
|
value: PronounSource.PreferPDB,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Prefer Discord, fall back to PronounDB (might lead to inconsistency between pronouns in chat and profile)",
|
||||||
|
value: PronounSource.PreferDiscord
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
showSelf: {
|
showSelf: {
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
description: "Enable or disable showing pronouns for the current user",
|
description: "Enable or disable showing pronouns for the current user",
|
||||||
|
@ -159,9 +159,12 @@ function getNextMessage(isUp: boolean, isReply: boolean) {
|
|||||||
return i === - 1 ? undefined : messages[messages.length - i - 1];
|
return i === - 1 ? undefined : messages[messages.length - i - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldMention() {
|
function shouldMention(message) {
|
||||||
|
const { enabled, userList, shouldPingListed } = Settings.plugins.NoReplyMention;
|
||||||
|
const shouldPing = !enabled || (shouldPingListed === userList.includes(message.author.id));
|
||||||
|
|
||||||
switch (settings.store.shouldMention) {
|
switch (settings.store.shouldMention) {
|
||||||
case MentionOptions.NO_REPLY_MENTION_PLUGIN: return !Settings.plugins.NoReplyMention.enabled;
|
case MentionOptions.NO_REPLY_MENTION_PLUGIN: return shouldPing;
|
||||||
case MentionOptions.DISABLED: return false;
|
case MentionOptions.DISABLED: return false;
|
||||||
default: return true;
|
default: return true;
|
||||||
}
|
}
|
||||||
@ -184,7 +187,7 @@ function nextReply(isUp: boolean) {
|
|||||||
type: "CREATE_PENDING_REPLY",
|
type: "CREATE_PENDING_REPLY",
|
||||||
channel,
|
channel,
|
||||||
message,
|
message,
|
||||||
shouldMention: shouldMention(),
|
shouldMention: shouldMention(message),
|
||||||
showMentionToggle: channel.guild_id !== null && message.author.id !== meId,
|
showMentionToggle: channel.guild_id !== null && message.author.id !== meId,
|
||||||
_isQuickReply: true
|
_isQuickReply: true
|
||||||
});
|
});
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { getUniqueUsername, openUserProfile } from "@utils/discord";
|
||||||
import { UserUtils } from "@webpack/common";
|
import { UserUtils } from "@webpack/common";
|
||||||
|
|
||||||
import settings from "./settings";
|
import settings from "./settings";
|
||||||
@ -43,11 +44,19 @@ export async function onRelationshipRemove({ relationship: { type, id } }: Relat
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case RelationshipType.FRIEND:
|
case RelationshipType.FRIEND:
|
||||||
if (settings.store.friends)
|
if (settings.store.friends)
|
||||||
notify(`${user.tag} removed you as a friend.`, user.getAvatarURL(undefined, undefined, false));
|
notify(
|
||||||
|
`${getUniqueUsername(user)} removed you as a friend.`,
|
||||||
|
user.getAvatarURL(undefined, undefined, false),
|
||||||
|
() => openUserProfile(user.id)
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
case RelationshipType.FRIEND_REQUEST:
|
case RelationshipType.FRIEND_REQUEST:
|
||||||
if (settings.store.friendRequestCancels)
|
if (settings.store.friendRequestCancels)
|
||||||
notify(`A friend request from ${user.tag} has been removed.`, user.getAvatarURL(undefined, undefined, false));
|
notify(
|
||||||
|
`A friend request from ${getUniqueUsername(user)} has been removed.`,
|
||||||
|
user.getAvatarURL(undefined, undefined, false),
|
||||||
|
() => openUserProfile(user.id)
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
import { DataStore, Notices } from "@api/index";
|
import { DataStore, Notices } from "@api/index";
|
||||||
import { showNotification } from "@api/Notifications";
|
import { showNotification } from "@api/Notifications";
|
||||||
|
import { getUniqueUsername, openUserProfile } from "@utils/discord";
|
||||||
import { ChannelStore, GuildMemberStore, GuildStore, RelationshipStore, UserStore, UserUtils } from "@webpack/common";
|
import { ChannelStore, GuildMemberStore, GuildStore, RelationshipStore, UserStore, UserUtils } from "@webpack/common";
|
||||||
|
|
||||||
import settings from "./settings";
|
import settings from "./settings";
|
||||||
@ -69,7 +70,11 @@ export async function syncAndRunChecks() {
|
|||||||
|
|
||||||
const user = await UserUtils.fetchUser(id).catch(() => void 0);
|
const user = await UserUtils.fetchUser(id).catch(() => void 0);
|
||||||
if (user)
|
if (user)
|
||||||
notify(`You are no longer friends with ${user.tag}.`, user.getAvatarURL(undefined, undefined, false));
|
notify(
|
||||||
|
`You are no longer friends with ${getUniqueUsername(user)}.`,
|
||||||
|
user.getAvatarURL(undefined, undefined, false),
|
||||||
|
() => openUserProfile(user.id)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,20 +84,25 @@ export async function syncAndRunChecks() {
|
|||||||
|
|
||||||
const user = await UserUtils.fetchUser(id).catch(() => void 0);
|
const user = await UserUtils.fetchUser(id).catch(() => void 0);
|
||||||
if (user)
|
if (user)
|
||||||
notify(`Friend request from ${user.tag} has been revoked.`, user.getAvatarURL(undefined, undefined, false));
|
notify(
|
||||||
|
`Friend request from ${getUniqueUsername(user)} has been revoked.`,
|
||||||
|
user.getAvatarURL(undefined, undefined, false),
|
||||||
|
() => openUserProfile(user.id)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function notify(text: string, icon?: string) {
|
export function notify(text: string, icon?: string, onClick?: () => void) {
|
||||||
if (settings.store.notices)
|
if (settings.store.notices)
|
||||||
Notices.showNotice(text, "OK", () => Notices.popNotice());
|
Notices.showNotice(text, "OK", () => Notices.popNotice());
|
||||||
|
|
||||||
showNotification({
|
showNotification({
|
||||||
title: "Relationship Notifier",
|
title: "Relationship Notifier",
|
||||||
body: text,
|
body: text,
|
||||||
icon
|
icon,
|
||||||
|
onClick
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ import { Devs } from "@utils/constants";
|
|||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByPropsLazy } from "@webpack";
|
||||||
|
|
||||||
const SpoilerClasses = findByPropsLazy("spoilerText");
|
const SpoilerClasses = findByPropsLazy("spoilerContent");
|
||||||
const MessagesClasses = findByPropsLazy("messagesWrapper", "messages");
|
const MessagesClasses = findByPropsLazy("messagesWrapper", "messages");
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
@ -43,14 +43,14 @@ export default definePlugin({
|
|||||||
|
|
||||||
if (!ctrlKey) { return; }
|
if (!ctrlKey) { return; }
|
||||||
|
|
||||||
const { spoilerText, hidden } = SpoilerClasses;
|
const { spoilerContent, hidden } = SpoilerClasses;
|
||||||
const { messagesWrapper } = MessagesClasses;
|
const { messagesWrapper } = MessagesClasses;
|
||||||
|
|
||||||
const parent = shiftKey
|
const parent = shiftKey
|
||||||
? document.querySelector(`div.${messagesWrapper}`)
|
? document.querySelector(`div.${messagesWrapper}`)
|
||||||
: (target as HTMLSpanElement).parentElement;
|
: (target as HTMLSpanElement).parentElement;
|
||||||
|
|
||||||
for (const spoiler of parent!.querySelectorAll(`span.${spoilerText}.${hidden}`)) {
|
for (const spoiler of parent!.querySelectorAll(`span.${spoilerContent}.${hidden}`)) {
|
||||||
(spoiler as HTMLSpanElement).click();
|
(spoiler as HTMLSpanElement).click();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { addContextMenuPatch, findGroupChildrenByChildId, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
|
import { addContextMenuPatch, findGroupChildrenByChildId, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
|
||||||
|
import { Flex } from "@components/Flex";
|
||||||
|
import { OpenExternalIcon } from "@components/Icons";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { Menu } from "@webpack/common";
|
import { Menu } from "@webpack/common";
|
||||||
@ -28,7 +30,7 @@ const Engines = {
|
|||||||
IQDB: "https://iqdb.org/?url=",
|
IQDB: "https://iqdb.org/?url=",
|
||||||
TinEye: "https://www.tineye.com/search?url=",
|
TinEye: "https://www.tineye.com/search?url=",
|
||||||
ImgOps: "https://imgops.com/start?url="
|
ImgOps: "https://imgops.com/start?url="
|
||||||
};
|
} as const;
|
||||||
|
|
||||||
function search(src: string, engine: string) {
|
function search(src: string, engine: string) {
|
||||||
open(engine + encodeURIComponent(src), "_blank");
|
open(engine + encodeURIComponent(src), "_blank");
|
||||||
@ -50,13 +52,28 @@ const imageContextMenuPatch: NavContextMenuPatchCallback = (children, props) =>
|
|||||||
key="search-image"
|
key="search-image"
|
||||||
id="search-image"
|
id="search-image"
|
||||||
>
|
>
|
||||||
{Object.keys(Engines).map(engine => {
|
{Object.keys(Engines).map((engine, i) => {
|
||||||
const key = "search-image-" + engine;
|
const key = "search-image-" + engine;
|
||||||
return (
|
return (
|
||||||
<Menu.MenuItem
|
<Menu.MenuItem
|
||||||
key={key}
|
key={key}
|
||||||
id={key}
|
id={key}
|
||||||
label={engine}
|
label={
|
||||||
|
<Flex style={{ alignItems: "center", gap: "0.5em" }}>
|
||||||
|
<img
|
||||||
|
style={{
|
||||||
|
borderRadius: i >= 3 // Do not round Google, Yandex & SauceNAO
|
||||||
|
? "50%"
|
||||||
|
: void 0
|
||||||
|
}}
|
||||||
|
aria-hidden="true"
|
||||||
|
height={16}
|
||||||
|
width={16}
|
||||||
|
src={new URL("/favicon.ico", Engines[engine]).toString().replace("lens.", "")}
|
||||||
|
/>
|
||||||
|
{engine}
|
||||||
|
</Flex>
|
||||||
|
}
|
||||||
action={() => search(src, Engines[engine])}
|
action={() => search(src, Engines[engine])}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@ -64,7 +81,12 @@ const imageContextMenuPatch: NavContextMenuPatchCallback = (children, props) =>
|
|||||||
<Menu.MenuItem
|
<Menu.MenuItem
|
||||||
key="search-image-all"
|
key="search-image-all"
|
||||||
id="search-image-all"
|
id="search-image-all"
|
||||||
label="All"
|
label={
|
||||||
|
<Flex style={{ alignItems: "center", gap: "0.5em" }}>
|
||||||
|
<OpenExternalIcon height={16} width={16} />
|
||||||
|
All
|
||||||
|
</Flex>
|
||||||
|
}
|
||||||
action={() => Object.values(Engines).forEach(e => search(src, e))}
|
action={() => Object.values(Engines).forEach(e => search(src, e))}
|
||||||
/>
|
/>
|
||||||
</Menu.MenuItem>
|
</Menu.MenuItem>
|
||||||
|
@ -17,28 +17,44 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { LazyComponent } from "@utils/react";
|
import { findByPropsLazy } from "@webpack";
|
||||||
import { findByProps } from "@webpack";
|
import { Tooltip } from "@webpack/common";
|
||||||
|
|
||||||
export default LazyComponent(() => {
|
const iconClasses = findByPropsLazy("button", "wrapper", "disabled", "separator");
|
||||||
const { button, dangerous } = findByProps("button", "wrapper", "disabled", "separator");
|
|
||||||
|
|
||||||
return function MessageButton(props) {
|
export function DeleteButton({ onClick }: { onClick(): void; }) {
|
||||||
return props.type === "delete"
|
return (
|
||||||
? (
|
<Tooltip text="Delete Review">
|
||||||
<div className={classes(button, dangerous)} aria-label="Delete Review" onClick={props.callback}>
|
{props => (
|
||||||
<svg aria-hidden="false" width="16" height="16" viewBox="0 0 20 20">
|
<div
|
||||||
<path fill="currentColor" d="M15 3.999V2H9V3.999H3V5.999H21V3.999H15Z"></path>
|
{...props}
|
||||||
<path fill="currentColor" d="M5 6.99902V18.999C5 20.101 5.897 20.999 7 20.999H17C18.103 20.999 19 20.101 19 18.999V6.99902H5ZM11 17H9V11H11V17ZM15 17H13V11H15V17Z"></path>
|
className={classes(iconClasses.button, iconClasses.dangerous)}
|
||||||
|
onClick={onClick}
|
||||||
|
>
|
||||||
|
<svg width="16" height="16" viewBox="0 0 20 20">
|
||||||
|
<path fill="currentColor" d="M15 3.999V2H9V3.999H3V5.999H21V3.999H15Z" />
|
||||||
|
<path fill="currentColor" d="M5 6.99902V18.999C5 20.101 5.897 20.999 7 20.999H17C18.103 20.999 19 20.101 19 18.999V6.99902H5ZM11 17H9V11H11V17ZM15 17H13V11H15V17Z" />
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
)
|
)}
|
||||||
: (
|
</Tooltip>
|
||||||
<div className={button} aria-label="Report Review" onClick={() => props.callback()}>
|
);
|
||||||
<svg aria-hidden="false" width="16" height="16" viewBox="0 0 20 20">
|
}
|
||||||
<path fill="currentColor" d="M20,6.002H14V3.002C14,2.45 13.553,2.002 13,2.002H4C3.447,2.002 3,2.45 3,3.002V22.002H5V14.002H10.586L8.293,16.295C8.007,16.581 7.922,17.011 8.076,17.385C8.23,17.759 8.596,18.002 9,18.002H20C20.553,18.002 21,17.554 21,17.002V7.002C21,6.45 20.553,6.002 20,6.002Z"></path>
|
|
||||||
|
export function ReportButton({ onClick }: { onClick(): void; }) {
|
||||||
|
return (
|
||||||
|
<Tooltip text="Report Review">
|
||||||
|
{props => (
|
||||||
|
<div
|
||||||
|
{...props}
|
||||||
|
className={iconClasses.button}
|
||||||
|
onClick={onClick}
|
||||||
|
>
|
||||||
|
<svg width="16" height="16" viewBox="0 0 20 20">
|
||||||
|
<path fill="currentColor" d="M20,6.002H14V3.002C14,2.45 13.553,2.002 13,2.002H4C3.447,2.002 3,2.45 3,3.002V22.002H5V14.002H10.586L8.293,16.295C8.007,16.581 7.922,17.011 8.076,17.385C8.23,17.759 8.596,18.002 9,18.002H20C20.553,18.002 21,17.554 21,17.002V7.002C21,6.45 20.553,6.002 20,6.002Z" />
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
);
|
)}
|
||||||
};
|
</Tooltip>
|
||||||
});
|
);
|
||||||
|
}
|
||||||
|
@ -18,7 +18,8 @@
|
|||||||
|
|
||||||
import { MaskedLinkStore, Tooltip } from "@webpack/common";
|
import { MaskedLinkStore, Tooltip } from "@webpack/common";
|
||||||
|
|
||||||
import { Badge } from "../entities/Badge";
|
import { Badge } from "../entities";
|
||||||
|
import { cl } from "../utils";
|
||||||
|
|
||||||
export default function ReviewBadge(badge: Badge) {
|
export default function ReviewBadge(badge: Badge) {
|
||||||
return (
|
return (
|
||||||
@ -26,13 +27,13 @@ export default function ReviewBadge(badge: Badge) {
|
|||||||
text={badge.name}>
|
text={badge.name}>
|
||||||
{({ onMouseEnter, onMouseLeave }) => (
|
{({ onMouseEnter, onMouseLeave }) => (
|
||||||
<img
|
<img
|
||||||
|
className={cl("badge")}
|
||||||
width="24px"
|
width="24px"
|
||||||
height="24px"
|
height="24px"
|
||||||
onMouseEnter={onMouseEnter}
|
onMouseEnter={onMouseEnter}
|
||||||
onMouseLeave={onMouseLeave}
|
onMouseLeave={onMouseLeave}
|
||||||
src={badge.icon}
|
src={badge.icon}
|
||||||
alt={badge.description}
|
alt={badge.description}
|
||||||
style={{ verticalAlign: "middle", marginLeft: "4px" }}
|
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
MaskedLinkStore.openUntrustedLink({
|
MaskedLinkStore.openUntrustedLink({
|
||||||
href: badge.redirectURL,
|
href: badge.redirectURL,
|
||||||
|
@ -16,16 +16,17 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Settings } from "@api/Settings";
|
import { openUserProfile } from "@utils/discord";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { LazyComponent } from "@utils/react";
|
import { LazyComponent } from "@utils/react";
|
||||||
import { filters, findBulk } from "@webpack";
|
import { filters, findBulk } from "@webpack";
|
||||||
import { Alerts, moment, Timestamp, UserStore } from "@webpack/common";
|
import { Alerts, moment, Timestamp, UserStore } from "@webpack/common";
|
||||||
|
|
||||||
import { Review } from "../entities/Review";
|
import { Review, ReviewType } from "../entities";
|
||||||
import { deleteReview, reportReview } from "../Utils/ReviewDBAPI";
|
import { deleteReview, reportReview } from "../reviewDbApi";
|
||||||
import { canDeleteReview, openUserProfileModal, showToast } from "../Utils/Utils";
|
import { settings } from "../settings";
|
||||||
import MessageButton from "./MessageButton";
|
import { canDeleteReview, cl, showToast } from "../utils";
|
||||||
|
import { DeleteButton, ReportButton } from "./MessageButton";
|
||||||
import ReviewBadge from "./ReviewBadge";
|
import ReviewBadge from "./ReviewBadge";
|
||||||
|
|
||||||
export default LazyComponent(() => {
|
export default LazyComponent(() => {
|
||||||
@ -34,22 +35,22 @@ export default LazyComponent(() => {
|
|||||||
const [
|
const [
|
||||||
{ cozyMessage, buttons, message, groupStart },
|
{ cozyMessage, buttons, message, groupStart },
|
||||||
{ container, isHeader },
|
{ container, isHeader },
|
||||||
{ avatar, clickable, username, messageContent, wrapper, cozy, timestampInline, timestamp },
|
{ avatar, clickable, username, messageContent, wrapper, cozy },
|
||||||
{ contents },
|
|
||||||
buttonClasses,
|
buttonClasses,
|
||||||
{ defaultColor }
|
botTag
|
||||||
] = findBulk(
|
] = findBulk(
|
||||||
p("cozyMessage"),
|
p("cozyMessage"),
|
||||||
p("container", "isHeader"),
|
p("container", "isHeader"),
|
||||||
p("avatar", "zalgo"),
|
p("avatar", "zalgo"),
|
||||||
p("contents"),
|
|
||||||
p("button", "wrapper", "selected"),
|
p("button", "wrapper", "selected"),
|
||||||
p("defaultColor")
|
p("botTag")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const dateFormat = new Intl.DateTimeFormat();
|
||||||
|
|
||||||
return function ReviewComponent({ review, refetch }: { review: Review; refetch(): void; }) {
|
return function ReviewComponent({ review, refetch }: { review: Review; refetch(): void; }) {
|
||||||
function openModal() {
|
function openModal() {
|
||||||
openUserProfileModal(review.sender.discordID);
|
openUserProfile(review.sender.discordID);
|
||||||
}
|
}
|
||||||
|
|
||||||
function delReview() {
|
function delReview() {
|
||||||
@ -81,21 +82,21 @@ export default LazyComponent(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes(cozyMessage, wrapper, message, groupStart, cozy, "user-review")} style={
|
<div className={classes(cozyMessage, wrapper, message, groupStart, cozy, cl("review"))} style={
|
||||||
{
|
{
|
||||||
marginLeft: "0px",
|
marginLeft: "0px",
|
||||||
paddingLeft: "52px",
|
paddingLeft: "52px", // wth is this
|
||||||
paddingRight: "16px"
|
paddingRight: "16px"
|
||||||
}
|
}
|
||||||
}>
|
}>
|
||||||
|
|
||||||
<div className={contents} style={{ paddingLeft: "0px" }}>
|
<img
|
||||||
<img
|
className={classes(avatar, clickable)}
|
||||||
className={classes(avatar, clickable)}
|
onClick={openModal}
|
||||||
onClick={openModal}
|
src={review.sender.profilePhoto || "/assets/1f0bfc0865d324c2587920a7d80c609b.png?size=128"}
|
||||||
src={review.sender.profilePhoto || "/assets/1f0bfc0865d324c2587920a7d80c609b.png?size=128"}
|
style={{ left: "0px" }}
|
||||||
style={{ left: "0px" }}
|
/>
|
||||||
/>
|
<div style={{ display: "inline-flex", justifyContent: "center", alignItems: "center" }}>
|
||||||
<span
|
<span
|
||||||
className={classes(clickable, username)}
|
className={classes(clickable, username)}
|
||||||
style={{ color: "var(--channels-default)", fontSize: "14px" }}
|
style={{ color: "var(--channels-default)", fontSize: "14px" }}
|
||||||
@ -103,34 +104,45 @@ export default LazyComponent(() => {
|
|||||||
>
|
>
|
||||||
{review.sender.username}
|
{review.sender.username}
|
||||||
</span>
|
</span>
|
||||||
{review.sender.badges.map(badge => <ReviewBadge {...badge} />)}
|
|
||||||
|
|
||||||
{
|
{review.type === ReviewType.System && (
|
||||||
!Settings.plugins.ReviewDB.hideTimestamps && (
|
<span
|
||||||
<Timestamp
|
className={classes(botTag.botTagVerified, botTag.botTagRegular, botTag.botTag, botTag.px, botTag.rem)}
|
||||||
timestamp={moment(review.timestamp * 1000)}
|
style={{ marginLeft: "4px" }}>
|
||||||
compact={true}
|
<span className={botTag.botText}>
|
||||||
/>
|
System
|
||||||
)
|
</span>
|
||||||
}
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{review.sender.badges.map(badge => <ReviewBadge {...badge} />)}
|
||||||
|
|
||||||
<p
|
{
|
||||||
className={classes(messageContent, defaultColor)}
|
!settings.store.hideTimestamps && review.type !== ReviewType.System && (
|
||||||
style={{ fontSize: 15, marginTop: 4 }}
|
<Timestamp timestamp={moment(review.timestamp * 1000)} >
|
||||||
>
|
{dateFormat.format(review.timestamp * 1000)}
|
||||||
{review.comment}
|
</Timestamp>)
|
||||||
</p>
|
}
|
||||||
|
|
||||||
|
<p
|
||||||
|
className={classes(messageContent)}
|
||||||
|
style={{ fontSize: 15, marginTop: 4, color: "var(--text-normal)" }}
|
||||||
|
>
|
||||||
|
{review.comment}
|
||||||
|
</p>
|
||||||
|
{review.id !== 0 && (
|
||||||
<div className={classes(container, isHeader, buttons)} style={{
|
<div className={classes(container, isHeader, buttons)} style={{
|
||||||
padding: "0px",
|
padding: "0px",
|
||||||
}}>
|
}}>
|
||||||
<div className={buttonClasses.wrapper} >
|
<div className={buttonClasses.wrapper} >
|
||||||
<MessageButton type="report" callback={reportRev} />
|
<ReportButton onClick={reportRev} />
|
||||||
|
|
||||||
{canDeleteReview(review, UserStore.getCurrentUser().id) && (
|
{canDeleteReview(review, UserStore.getCurrentUser().id) && (
|
||||||
<MessageButton type="delete" callback={delReview} />
|
<DeleteButton onClick={delReview} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user