mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-02-25 15:58:31 +00:00
add slash command and small error handling
This commit is contained in:
parent
aeff943207
commit
f60e371050
2 changed files with 17 additions and 3 deletions
|
@ -33,9 +33,12 @@ const Cache: Record<string, string> = {};
|
|||
|
||||
const PreloadedUserSettings = findLazy(m => m.ProtoClass?.typeName === "discord_protos.discord_users.v1.PreloadedUserSettings");
|
||||
export function getTimeString(timezone: string, timestamp = new Date()): string {
|
||||
try {
|
||||
const locale = PreloadedUserSettings.getCurrentValue().localization.locale.value;
|
||||
|
||||
return new Intl.DateTimeFormat(locale, { hour: "numeric", minute: "numeric", timeZone: timezone }).format(timestamp); // we hate javascript
|
||||
} catch (e) {
|
||||
return "Error"; // incase it gets invalid timezone from api, probably not gonna happen but if it does this will prevent discord from crashing
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ const EditIcon = findByCodeLazy("M19.2929 9.8299L19.9409 9.18278C21.353 7.77064
|
|||
const DeleteIcon = findByCodeLazy("M15 3.999V2H9V3.999H3V5.999H21V3.999H15Z");
|
||||
const classNames = findByPropsLazy("customStatusSection");
|
||||
|
||||
|
||||
import { API_URL, DATASTORE_KEY, getAllTimezones, getTimeString, getUserTimezone, TimezoneDB } from "./Utils";
|
||||
const styles = findByPropsLazy("timestampInline");
|
||||
|
||||
|
@ -44,6 +45,16 @@ export default definePlugin({
|
|||
description: "Allows you to see and set the timezones of other users.",
|
||||
authors: [Devs.mantikafasi, Devs.Arjix],
|
||||
|
||||
commands: [
|
||||
{
|
||||
name: "timezone",
|
||||
description: "Sends link to a website that shows timezone string, useful if you want to know your friends timezone",
|
||||
execute: () => {
|
||||
return { content: "https://gh.lewisakura.moe/timezone/" };
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
settingsAboutComponent: () => {
|
||||
const href = `${API_URL}?client_mod=${encodeURIComponent(VENCORD_USER_AGENT)}`;
|
||||
return (
|
||||
|
|
Loading…
Add table
Reference in a new issue