1
0
Fork 1
mirror of https://github.com/Vendicated/Vencord.git synced 2025-01-10 18:06:22 +00:00

+ Added DayNigh Switcher plugin

This commit is contained in:
MiguVT 2024-09-16 15:56:27 +02:00
parent f27361f017
commit f5cfa6285f
3 changed files with 97 additions and 0 deletions

View file

@ -0,0 +1,30 @@
# DayNight Switcher
### Overview
The **DayNight Switcher** plugin for Vencord automatically switches between Discord's light and dark themes based on the time of day. Users can easily configure the start times for the day and night themes directly from the plugin settings.
### Features
- **Automatic Theme Switching**: Automatically applies the light theme during the day and the dark theme at night.
- **Customizable Times**: Configure the start times for day and night themes using the plugin settings.
- **Seamless Integration**: No need for manual installation; simply toggle the plugin in Vencord's plugin settings.
### Usage Instructions
1. Go to **Vencord Settings** > **Plugins**.
2. Locate the **DayNight Switcher** plugin.
3. Toggle the plugin to enable it.
4. Adjust the following settings to suit your preferences:
- **Day Theme Start Time**: Set the hour (0-23) when the light theme should start.
- **Night Theme Start Time**: Set the hour (0-23) when the dark theme should start.
The default configuration is set to:
- **Day Theme**: Starts at 8 AM
- **Night Theme**: Starts at 8 PM
### Example
- If you want the **Day Theme** to start at 7 AM and the **Night Theme** to start at 6 PM:
1. Open **Vencord Settings** > **DayNight Switcher**.
2. Set the **Day Theme Start Time** to 7.
3. Set the **Night Theme Start Time** to 18.
### License
This plugin is licensed under the GNU General Public License v3.0. See the [LICENSE](https://www.gnu.org/licenses/gpl-3.0.html) for more details.

View file

@ -0,0 +1,63 @@
import { definePluginSettings, Settings } from "@api/Settings";
import { Devs } from "@utils/constants";
import { OptionType } from "@utils/types";
import definePlugin from "@utils/types";
// Define plugin settings with day and night time
const settings = definePluginSettings({
dayTime: {
type: OptionType.NUMBER,
description: "Day Theme Start Time (Hour)",
default: 8, // Default: 8 AM
isValid: (value) => value >= 0 && value <= 23 || "Must be a valid hour (0-23)"
},
nightTime: {
type: OptionType.NUMBER,
description: "Night Theme Start Time (Hour)",
default: 20, // Default: 8 PM
isValid: (value) => value >= 0 && value <= 23 || "Must be a valid hour (0-23)"
}
});
function setTheme(theme: "light" | "dark") {
const body = document.body;
if (theme === "light") {
body.classList.remove("theme-dark");
body.classList.add("theme-light");
} else {
body.classList.remove("theme-light");
body.classList.add("theme-dark");
}
}
// Function to apply light or dark theme based on current time
function applyThemeBasedOnTime() {
const currentHour = new Date().getHours();
const { dayTime, nightTime } = settings.store;
if (currentHour >= dayTime && currentHour < nightTime) {
setTheme("light");
} else {
setTheme("dark");
}
}
// Start and stop logic
function startPlugin() {
applyThemeBasedOnTime();
setInterval(applyThemeBasedOnTime, 3600000); // Check every hour
}
function stopPlugin() {
// Optionally reset to user's original theme (not implemented yet)
}
// Plugin export with metadata and settings
export default definePlugin({
name: "DayNight Switcher",
description: "Automatically switches between Discord's light and dark themes based on time.",
authors: [Devs.Migu],
settings,
start: startPlugin,
stop: stopPlugin
});

View file

@ -575,6 +575,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
name: "RamziAH", name: "RamziAH",
id: 1279957227612147747n, id: 1279957227612147747n,
}, },
Migu: {
name: "MiguVT",
id: 813034603854037024n,
},
} satisfies Record<string, Dev>); } satisfies Record<string, Dev>);
// iife so #__PURE__ works correctly // iife so #__PURE__ works correctly