Skip to content

Commit

Permalink
fix minor bugs in various plugins
Browse files Browse the repository at this point in the history
- FriendsSince: Don't show for friend requests
- FakeNitro: Fix attempting to bypass unicode emojis Vendicated#2503
- MessageLatency: ignore bots Vendicated#2504
- CtrlEnterSend: use cmd+enter on macOS Vendicated#2502
- ReplaceGoogleSearch: trim LF character Vendicated#2488

Co-authored-by: AutumnVN <autumnvnchino@gmail.com>
Co-authored-by: rushiiMachine <33725716+rushiiMachine@users.noreply.github.com>
Co-authored-by: Lumap <lumap@duck.com>
Co-authored-by: Mylloon <kennel.anri@tutanota.com>
  • Loading branch information
5 people authored and ImLvna committed May 27, 2024
1 parent cceaff6 commit 4b617cd
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/plugins/ctrlEnterSend/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default definePlugin({
type: OptionType.SELECT,
options: [
{
label: "Ctrl+Enter (Enter or Shift+Enter for new line)",
label: "Ctrl+Enter (Enter or Shift+Enter for new line) (cmd+enter on macOS)",
value: "ctrl+enter"
},
{
Expand Down Expand Up @@ -54,7 +54,7 @@ export default definePlugin({
result = event.shiftKey;
break;
case "ctrl+enter":
result = event.ctrlKey;
result = navigator.platform.includes("Mac") ? event.metaKey : event.ctrlKey;
break;
case "enter":
result = !event.shiftKey && !event.ctrlKey;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/fakeNitro/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ export default definePlugin({
},

canUseEmote(e: Emoji, channelId: string) {
if (e.type === "UNICODE") return true;
if (e.type === 0) return true;
if (e.available === false) return false;

const isUnusableRoleSubEmoji = RoleSubscriptionEmojiUtils.isUnusableRoleSubscriptionEmojiOriginal ?? RoleSubscriptionEmojiUtils.isUnusableRoleSubscriptionEmoji;
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/friendsSince/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export default definePlugin({

getFriendSince(userId: string) {
try {
if (!RelationshipStore.isFriend(userId)) return null;

return RelationshipStore.getSince(userId);
} catch (err) {
new Logger("FriendsSince").error(err);
Expand All @@ -60,6 +62,8 @@ export default definePlugin({
},

friendsSince: ErrorBoundary.wrap(({ userId, textClassName }: { userId: string; textClassName?: string; }) => {
if (!RelationshipStore.isFriend(userId)) return null;

const friendsSince = RelationshipStore.getSince(userId);
if (!friendsSince) return null;

Expand Down
3 changes: 3 additions & 0 deletions src/plugins/messageLatency/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ export default definePlugin({
// Message wasn't received through gateway
if (!isNonNullish(nonce)) return null;

// Bots basically never send a nonce, and if someone does do it then it's usually not a snowflake
if (message.bot) return null;

let isDiscordKotlin = false;
let delta = SnowflakeUtils.extractTimestamp(id) - SnowflakeUtils.extractTimestamp(nonce); // milliseconds
if (!showMillis) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/replaceGoogleSearch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const settings = definePluginSettings({
});

function search(src: string, engine: string) {
open(engine + encodeURIComponent(src), "_blank");
open(engine + encodeURIComponent(src.trim()), "_blank");
}

function makeSearchItem(src: string) {
Expand Down
4 changes: 2 additions & 2 deletions src/webpack/common/types/stores.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export interface CustomEmoji {
originalName?: string;
require_colons: boolean;
roles: string[];
type: "GUILD_EMOJI";
type: 1;
}

export interface UnicodeEmoji {
Expand All @@ -75,7 +75,7 @@ export interface UnicodeEmoji {
};
index: number;
surrogates: string;
type: "UNICODE";
type: 0;
uniqueName: string;
useSpriteSheet: boolean;
get allNamesString(): string;
Expand Down

0 comments on commit 4b617cd

Please sign in to comment.