Merge branch 'dev' into edit-users

This commit is contained in:
vee 2024-07-06 19:05:58 +02:00 committed by GitHub
commit 0a51a865d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 10 additions and 235 deletions

View file

@ -1,7 +1,7 @@
{
"name": "vencord",
"private": "true",
"version": "1.9.3",
"version": "1.9.4",
"description": "The cutest Discord client mod",
"homepage": "https://github.com/Vendicated/Vencord#readme",
"bugs": {

View file

@ -337,7 +337,7 @@ export default definePlugin({
// Pass through editHistory & deleted & original attachments to the "edited message" transformer
match: /(?<=null!=\i\.edited_timestamp\)return )\i\(\i,\{reactions:(\i)\.reactions.{0,50}\}\)/,
replace:
"Object.assign($&,{ deleted:$1.deleted, editHistory:$1.editHistory, attachments:$1.attachments })"
"Object.assign($&,{ deleted:$1.deleted, editHistory:$1.editHistory })"
},
{

View file

@ -8,11 +8,15 @@
.emoji,
[data-type="sticker"],
iframe,
.messagelogger-deleted-attachment:not([class*="hiddenAttachment_"]),
.messagelogger-deleted-attachment,
[class|="inlineMediaEmbed"]
) {
filter: grayscale(1) !important;
transition: 150ms filter ease-in-out;
&[class*="hiddenMosaicItem_"] {
filter: grayscale(1) blur(var(--custom-message-attachment-spoiler-blur-radius, 44px)) !important;
}
}
.messagelogger-deleted
@ -23,8 +27,7 @@
iframe,
.messagelogger-deleted-attachment,
[class|="inlineMediaEmbed"]
):hover,
.messagelogger-deleted {
):hover {
filter: grayscale(0) !important;
}

View file

@ -15,8 +15,8 @@ export default definePlugin({
{
find: ".Messages.VIEW_ALL_ROLES",
replacement: {
match: /return null!=\i(?=\?\i\.slice)/,
replace: "return false"
match: /(\i)\.slice\(0,\i\)/,
replace: "$1"
}
}
]

View file

@ -1,13 +0,0 @@
# Urban Dictionary
Use /urban slash command to search for a definition for a word on [Urban Dictionary](https://www.urbandictionary.com/).
## Preview
![preview](https://i.imgur.com/1zwzj38.png)
## Usage
- Enable this plugin
- Set plugin settings as desired
- Type /urban and start getting definitions right into your Discord client.

View file

@ -1,105 +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, sendBotMessage } from "@api/Commands";
import { ApplicationCommandInputType } from "@api/Commands/types";
import { definePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
const settings = definePluginSettings({
resultsAmount: {
type: OptionType.NUMBER,
description: "The amount of results you want to get (more gives better results, but is slower)",
default: 10
}
});
export default definePlugin({
name: "UrbanDictionary",
description: "Search for a word on Urban Dictionary via /urban slash command",
authors: [Devs.jewdev],
dependencies: ["CommandsAPI"],
settings,
commands: [
{
name: "urban",
description: "Returns the definition of a word from Urban Dictionary",
inputType: ApplicationCommandInputType.BUILT_IN,
options: [
{
type: ApplicationCommandOptionType.STRING,
name: "word",
description: "The word to search for on Urban Dictionary",
required: true
}
],
execute: async (args, ctx) => {
try {
const query: string = encodeURIComponent(args[0].value);
const { list } = await fetch(`https://api.urbandictionary.com/v0/define?term=${query}&per_page=${settings.store.resultsAmount}`).then(response => response.json());
if (!list.length)
return void sendBotMessage(ctx.channel.id, { content: "No results found." });
const definition = list.reduce((prev, curr) => {
return prev.thumbs_up > curr.thumbs_up ? prev : curr;
});
const linkify = (text: string) => text
.replaceAll("\r\n", "\n")
.replace(/([*>_`~\\])/gsi, "\\$1")
.replace(/\[(.+?)\]/g, (_, word) => `[${word}](https://www.urbandictionary.com/define.php?term=${encodeURIComponent(word)} "Define '${word}' on Urban Dictionary")`)
.trim();
return void sendBotMessage(ctx.channel.id, {
embeds: [
{
type: "rich",
author: {
name: `Uploaded by "${definition.author}"`,
url: `https://www.urbandictionary.com/author.php?author=${encodeURIComponent(definition.author)}`,
},
title: definition.word,
url: `https://www.urbandictionary.com/define.php?term=${encodeURIComponent(definition.word)}`,
description: linkify(definition.definition),
fields: [
{
name: "Example",
value: linkify(definition.example),
},
{
name: "Want more definitions?",
value: `Check out [more definitions](https://www.urbandictionary.com/define.php?term=${query} "Define "${args[0].value}" on Urban Dictionary") on Urban Dictionary.`,
},
],
color: 0xFF9900,
footer: { text: `👍 ${definition.thumbs_up.toString()} | 👎 ${definition.thumbs_down.toString()}`, icon_url: "https://www.urbandictionary.com/favicon.ico" },
timestamp: new Date(definition.written_on).toISOString(),
},
] as any,
});
} catch (error) {
sendBotMessage(ctx.channel.id, {
content: `Something went wrong: \`${error}\``,
});
}
}
}
]
});

View file

@ -1,110 +0,0 @@
/*
* 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 { ApplicationCommandInputType, ApplicationCommandOptionType, findOption, sendBotMessage } from "@api/Commands";
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
export default definePlugin({
name: "Wikisearch",
description: "Searches Wikipedia for your requested query. (/wikisearch)",
authors: [Devs.Samu],
dependencies: ["CommandsAPI"],
commands: [
{
name: "wikisearch",
description: "Searches Wikipedia for your request.",
inputType: ApplicationCommandInputType.BUILT_IN,
options: [
{
name: "search",
description: "Word to search for",
type: ApplicationCommandOptionType.STRING,
required: true
},
],
execute: async (_, ctx) => {
const word = findOption(_, "search", "");
if (!word) {
return sendBotMessage(ctx.channel.id, {
content: "No word was defined!"
});
}
const dataSearchParams = new URLSearchParams({
action: "query",
format: "json",
list: "search",
formatversion: "2",
origin: "*",
srsearch: word
});
const data = await fetch("https://en.wikipedia.org/w/api.php?" + dataSearchParams).then(response => response.json())
.catch(err => {
console.log(err);
sendBotMessage(ctx.channel.id, { content: "There was an error. Check the console for more info" });
return null;
});
if (!data) return;
if (!data.query?.search?.length) {
console.log(data);
return sendBotMessage(ctx.channel.id, { content: "No results given" });
}
const altData = await fetch(`https://en.wikipedia.org/w/api.php?action=query&format=json&prop=info%7Cdescription%7Cimages%7Cimageinfo%7Cpageimages&list=&meta=&indexpageids=1&pageids=${data.query.search[0].pageid}&formatversion=2&origin=*`)
.then(res => res.json())
.then(data => data.query.pages[0])
.catch(err => {
console.log(err);
sendBotMessage(ctx.channel.id, { content: "There was an error. Check the console for more info" });
return null;
});
if (!altData) return;
const thumbnailData = altData.thumbnail;
const thumbnail = thumbnailData && {
url: thumbnailData.source.replace(/(50px-)/ig, "1000px-"),
height: thumbnailData.height * 100,
width: thumbnailData.width * 100
};
sendBotMessage(ctx.channel.id, {
embeds: [
{
type: "rich",
title: data.query.search[0].title,
url: `https://wikipedia.org/w/index.php?curid=${data.query.search[0].pageid}`,
color: "0x8663BE",
description: data.query.search[0].snippet.replace(/(&nbsp;|<([^>]+)>)/ig, "").replace(/(&quot;)/ig, "\"") + "...",
image: thumbnail,
footer: {
text: "Powered by the Wikimedia API",
},
}
] as any
});
}
}
]
});