feat: add config
This commit is contained in:
parent
c21b623ffd
commit
dcd7407bc5
2 changed files with 32 additions and 4 deletions
33
index.ts
33
index.ts
|
@ -1,10 +1,32 @@
|
|||
import { definePluginSettings } from "@api/Settings";
|
||||
import { Logger } from "@utils/Logger";
|
||||
import definePlugin from "@utils/types";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { FluxDispatcher } from "@webpack/common";
|
||||
|
||||
const logger = new Logger("muter");
|
||||
const reconnect_interval = 5000;
|
||||
const port = 3034;
|
||||
const settings = definePluginSettings({
|
||||
port: {
|
||||
description: "Port to connect to muter on.",
|
||||
type: OptionType.NUMBER,
|
||||
default: 3034,
|
||||
onChange: value => {
|
||||
port = value;
|
||||
socket.close();
|
||||
connect();
|
||||
}
|
||||
},
|
||||
reconnect: {
|
||||
description: "Reconnect interval in seconds.",
|
||||
type: OptionType.NUMBER,
|
||||
default: 5,
|
||||
onChange: value => {
|
||||
reconnect = value * 1000;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let port: number;
|
||||
let reconnect: number;
|
||||
let muted = false;
|
||||
let socket: WebSocket;
|
||||
|
||||
|
@ -28,7 +50,7 @@ function connect() {
|
|||
socket.onclose = e => {
|
||||
if (!e.wasClean) {
|
||||
logger.error("Connection to muter was interrupted. Reconnecting...");
|
||||
setTimeout(connect, reconnect_interval);
|
||||
setTimeout(connect, reconnect);
|
||||
} else {
|
||||
logger.info("Connection to muter closed");
|
||||
}
|
||||
|
@ -39,8 +61,11 @@ export default definePlugin({
|
|||
name: "muter",
|
||||
description: "muter companion plugin. Mirrors system mutes to Discord.",
|
||||
authors: [{ name: "isitreallyalive", id: 1269669249056510026n }],
|
||||
settings,
|
||||
|
||||
start() {
|
||||
port = settings.store.port;
|
||||
reconnect = settings.store.reconnect;
|
||||
connect();
|
||||
// todo: try to fix weird virtual bug
|
||||
},
|
||||
|
|
3
readme.md
Normal file
3
readme.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# muter-vencord
|
||||
|
||||
A plugin for [Vencord](https://vencord.dev/) which integrates with [muter](https://git.newty.dev/newt/muter) to synchronise system mutes to Discord.
|
Loading…
Reference in a new issue