Skip to content

Commit

Permalink
rework tag alias handling, add ?thirdparty / ?dmproxying
Browse files Browse the repository at this point in the history
  • Loading branch information
u1f408 committed Dec 20, 2024
1 parent dea75e1 commit 0afdf69
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 64 deletions.
14 changes: 7 additions & 7 deletions src/evt/messageCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Context } from '..';
import config from '../config';
import { inspect } from 'util';

import tags from '../tags';
import { TAGS, TAG_ALIASES } from '../tags';

const isNewAccount = (createdAt: number) => {
const now = Math.floor((new Date() as unknown as number) / 1000);
Expand Down Expand Up @@ -45,20 +45,20 @@ export default async (evt: any, ctx: Context) => {
const content: string = evt.content.toLowerCase();

if (content == "?ping")
return await ctx.rest.createMessage(evt.channel_id, "meow!");

if (evt.guild_id != config.guild_id) return;
return await ctx.rest.createMessage(evt.channel_id, "meow!");

if (evt.guild_id != config.guild_id) return;
if (evt.channel_id == config.update_requests_channel) await updatePinnedMessage(ctx);

if (["?tags", "?tag list", "?taglist"].includes(content))
return await ctx.rest.createMessage(evt.channel_id, {
content: `available tags: ${Object.keys(tags).join(', ')}`,
content: `available tags: ${Object.keys(TAGS).join(', ')}`,
allowedMentions: { parse: [] }
});

let tag = tags[content.substring(1) as string];
if (content && content[0] == "?" && tag && evt.guild_id == config.guild_id)
let tagname = content.substring(1) as string;
let tag = TAGS[TAG_ALIASES[tagname] ?? tagname];
if (content && content[0] == "?" && tag)
return await ctx.rest.createMessage(evt.channel_id, {
content: (typeof tag === 'string' ? tag : undefined),
embeds: (typeof tag === 'string' ? undefined : [ tag ]),
Expand Down
115 changes: 58 additions & 57 deletions src/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const keepproxy =
const banner = "We don't have a recommended size for banners but a 16:9 ratio seems to work best on desktop and a 18:9 ratio seems to work best on mobile"
const rolerestrict = {
"title": "Is there a way to restrict PluralKit usage to a certain role? / Can I remove PluralKit access for specific users in my server?",
"description": "This is not a feature currently available in PluralKit. It may be added in the future.\\nIn the meantime, this feature is supported in Tupperbox (an alternative proxying bot) - ask about it in their support server: <https://discord.gg/Z4BHccHhy3>",
"description": "PluralKit does not, and *will not*, support restricting usage by role.\n\nThis feature is supported in Tupperbox (an alternative proxying bot) - ask about it in their support server: <https://discord.gg/Z4BHccHhy3>",
"url": "https://pluralkit.me/faq/#is-there-a-way-to-restrict-pluralkit-usage-to-a-certain-role-can-i-remove-pluralkit-access-for-specific-users-in-my-server",
"footer": {
"text": "https://pluralkit.me/faq",
Expand Down Expand Up @@ -99,67 +99,68 @@ const bugreport =
"\n" +
"- please send the error code **as text**, and *not* as a screenshot; to search pluralkit's logs, we need to be able to copy paste the error code.\n" +
`- Please **do** mention what you were doing at the time (even if it's "I sent a message"), it's very helpful in figuring out what the issue is.`
const community =
"Please ask about community-made resources in <#912804952953479171> (it may be helpful to @mention the creator!)"
const shards =
"PluralKit is in hundreds of thousands of servers, and that's too many servers for one single connection to Discord. So, it makes many separate connections to Discord and puts some servers in each one. Each connection to Discord is called a *shard*.\n" +
'It is possible that one shard is malfunctioning or "down". If this happens, PluralKit will be working in certain servers but not in others.'
"PluralKit is in hundreds of thousands of servers, and that's too many servers for one single connection to Discord. So, it makes many separate connections to Discord and puts some servers in each one. Each connection to Discord is called a *shard*, and each group of connections is called a *cluster*.\n" +
'It is possible that one shard or cluster is malfunctioning or "down". If this happens, PluralKit will be working in certain servers but not in others.'
const messagereport =
"**Reporting proxied messges to Discord Trust and Safety**\n\n" +
"Use the standard Discord report form (<https://dis.gd/request> - select Trust and Safety and then the reason for the report). You should provide as much information as possible - including the Discord account ID of the author of the messages, and any message links.\n" +
"You can see what Discord account sent a proxied message by using the ❓ react, or copying a message link and running `pk;msg <link>` in DMs with PluralKit."
const emojiedit =
"The `pk;edit` \"workaround\" for using emojis from servers without PluralKit relied on a bug in the emoji permissions checks on Discord's side, which has now been patched. It is **required** for a server to have PluralKit for you to be able to use emojis from that server in your proxied messages.\n\n" +
"**There is nothing that the PluralKit developers can do about this.** Just like when emoji permissions started to be enforced originally (resulting in this workaround becoming known), **this is entirely the result of a Discord change.**"

export default {
emojis: emojis,
emoji: emojis,
emote: emojis,
emotes: emojis,

avatar: avatar,
avatars: avatar,
icon: avatar,
icons: avatar,
pfp: avatar,
pfps: avatar,

recovery: recovery,

pktotupper: pktotupper,
tuppertopk: tuppertopk,

keepproxy: keepproxy,
kp: keepproxy,

smartquotes: smartquotes,

banner: banner,
banners: banner,
bannerratio: banner,

flags: flags,

slash: slash,

bothelp: bothelp,

restrictpk: rolerestrict,
rolerestrict: rolerestrict,

bugreport: bugreport,

community: community,

shards: shards,
clusters: shards,

messagereport: messagereport,

simplyplural: simplyplural,
sp: simplyplural,

emojiedit: emojiedit,
emoteedit: emojiedit,
} as Record<string, string | object>;
const thirdparty =
"**Unaffiliated resources**\n\n" +
"Please avoid recommending, or asking for support for, bots/websites/apps that are not created by the PluralKit team. We can't help with them as we do not want to take the responsibility to provide support for something we are not affiliated with.\n" +
"It is okay to talk about them in the <#912804952953479171> channel, but do not expect the staff (or anyone else) to answer questions about them. Generally, please try asking for support in the relevant server and not here.\n" +
"\n" +
"Similarly, do not recommend free image hosting providers outside of the PluralKit CDN. They do not appreciate the traffic generated by avatar hosting and many have blocked us in the past."
const dmproxying =
"**Proxying in DMs:** " +
"Unfortunately, Discord DMs do not support webhooks or adding bots, which are required for PluralKit to proxy messages. " +
"There are some third-party bots that support this (such as [D-Proxy](<https://www.dproxy.me/>) or [/plu/ral](<https://plural.gg/>)), but they are not made by the PluralKit team so we can't provide support for them here."

export const TAGS: Record<string, string | object> = {
emojis,
avatar,
recovery,
pktotupper,
tuppertopk,
keepproxy,
smartquotes,
banner,
flags,
slash,
bothelp,
rolerestrict,
bugreport,
thirdparty,
shards,
messagereport,
simplyplural,
emojiedit,
dmproxying,
};

export const TAG_ALIASES: Record<string, string> = {
emoji: 'emojis',
emote: 'emojis',
emotes: 'emojis',
avatars: 'avatar',
icon: 'avatar',
icons: 'avatar',
pfp: 'avatar',
pfps: 'avatar',
kp: 'keepproxy',
banners: 'banner',
bannerratio: 'banner',
restrictpk: 'rolerestrict',
shard: 'shards',
clusters: 'shards',
cluster: 'shards',
sp: 'simplyplural',
emoteedit: 'emojiedit',
community: 'thirdparty',
dmproxy: 'dmproxying',
proxydm: 'dmproxying',
};

0 comments on commit 0afdf69

Please sign in to comment.