MessageLatency: add option to ignore own messages (#3677)
Co-authored-by: V <vendicated@riseup.net>
This commit is contained in:
parent
8c2dc84f3b
commit
80872f4ab9
1 changed files with 9 additions and 2 deletions
|
|
@ -11,7 +11,7 @@ import { isNonNullish } from "@utils/guards";
|
|||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { Message } from "@vencord/discord-types";
|
||||
import { findComponentByCodeLazy } from "@webpack";
|
||||
import { SnowflakeUtils, Tooltip } from "@webpack/common";
|
||||
import { AuthenticationStore, SnowflakeUtils, Tooltip } from "@webpack/common";
|
||||
|
||||
type FillValue = ("status-danger" | "status-warning" | "status-positive" | "text-muted");
|
||||
type Fill = [FillValue, FillValue, FillValue];
|
||||
|
|
@ -48,6 +48,11 @@ export default definePlugin({
|
|||
type: OptionType.BOOLEAN,
|
||||
description: "Show milliseconds",
|
||||
default: false
|
||||
},
|
||||
ignoreSelf: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Don't add indicator to your own messages",
|
||||
default: false
|
||||
}
|
||||
}),
|
||||
|
||||
|
|
@ -91,7 +96,7 @@ export default definePlugin({
|
|||
},
|
||||
|
||||
latencyTooltipData(message: Message) {
|
||||
const { latency, detectDiscordKotlin, showMillis } = this.settings.store;
|
||||
const { latency, detectDiscordKotlin, showMillis, ignoreSelf } = this.settings.store;
|
||||
const { id, nonce } = message;
|
||||
|
||||
// Message wasn't received through gateway
|
||||
|
|
@ -100,6 +105,8 @@ export default definePlugin({
|
|||
// Bots basically never send a nonce, and if someone does do it then it's usually not a snowflake
|
||||
if (message.author.bot) return null;
|
||||
|
||||
if (ignoreSelf && message.author.id === AuthenticationStore.getId()) return null;
|
||||
|
||||
let isDiscordKotlin = false;
|
||||
let delta = SnowflakeUtils.extractTimestamp(id) - SnowflakeUtils.extractTimestamp(nonce); // milliseconds
|
||||
if (!showMillis) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue