mirror of
https://github.com/Equicord/Equicord.git
synced 2025-02-22 16:19:07 -05:00
Updates
This commit is contained in:
parent
1122b3ebbb
commit
202a5355de
2 changed files with 59 additions and 25 deletions
|
@ -4,35 +4,60 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { definePluginSettings, migratePluginSettings } from "@api/Settings";
|
||||||
import { EquicordDevs } from "@utils/constants";
|
import { EquicordDevs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByCodeLazy } from "@webpack";
|
import { findByCodeLazy } from "@webpack";
|
||||||
import { FluxDispatcher, PresenceStore, UserStore } from "@webpack/common";
|
import { FluxDispatcher, PresenceStore, UserStore } from "@webpack/common";
|
||||||
|
|
||||||
const updateAsync = findByCodeLazy("updateAsync");
|
const updateAsync = findByCodeLazy("updateAsync", "status");
|
||||||
|
|
||||||
async function runningGamesChange(event) {
|
const settings = definePluginSettings({
|
||||||
const { games } = event;
|
statusToSet: {
|
||||||
let savedStatus;
|
type: OptionType.SELECT,
|
||||||
if (games.length > 0) {
|
description: "Status set while playing a game",
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: "Online",
|
||||||
|
value: "online",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Idle",
|
||||||
|
value: "idle",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Do Not Disturb",
|
||||||
|
value: "dnd",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Invisible",
|
||||||
|
value: "invisible",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
migratePluginSettings("StatusWhilePlaying", "DNDWhilePlaying");
|
||||||
|
export default definePlugin({
|
||||||
|
name: "StatusWhilePlaying",
|
||||||
|
description: "Automatically updates your status when playing games",
|
||||||
|
authors: [EquicordDevs.thororen],
|
||||||
|
settings,
|
||||||
|
runningGamesChange(event) {
|
||||||
|
let savedStatus = "";
|
||||||
|
if (event.games.length > 0) {
|
||||||
const currentUser = UserStore.getCurrentUser();
|
const currentUser = UserStore.getCurrentUser();
|
||||||
const status = PresenceStore.getStatus(currentUser.id);
|
const status = PresenceStore.getStatus(currentUser.id);
|
||||||
savedStatus = status;
|
savedStatus = status;
|
||||||
if (status === "invisible") return;
|
updateAsync(settings.store.statusToSet);
|
||||||
if (status !== "dnd") updateAsync("dnd");
|
} else if (event.games.length === 0) {
|
||||||
} else if (games.length === 0) {
|
|
||||||
updateAsync(savedStatus);
|
updateAsync(savedStatus);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
export default definePlugin({
|
|
||||||
name: "DNDWhilePlaying",
|
|
||||||
description: "Automatically updates your status to Do Not Disturb when playing games and resets it back when stopped playing",
|
|
||||||
authors: [EquicordDevs.thororen],
|
|
||||||
start() {
|
start() {
|
||||||
FluxDispatcher.subscribe("RUNNING_GAMES_CHANGE", runningGamesChange);
|
FluxDispatcher.subscribe("RUNNING_GAMES_CHANGE", this.runningGamesChange);
|
||||||
},
|
},
|
||||||
stop() {
|
stop() {
|
||||||
FluxDispatcher.unsubscribe("RUNNING_GAMES_CHANGE", runningGamesChange);
|
FluxDispatcher.unsubscribe("RUNNING_GAMES_CHANGE", this.runningGamesChange);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -66,6 +66,15 @@ export default definePlugin({
|
||||||
replace: "return true",
|
replace: "return true",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// fixes a bug where Members page must be loaded to see highest role, why is Discord depending on MemberSafetyStore.getEnhancedMember for something that can be obtained here?
|
||||||
|
{
|
||||||
|
find: "Messages.GUILD_MEMBER_MOD_VIEW_PERMISSION_GRANTED_BY_ARIA_LABEL,tooltipContentClassName",
|
||||||
|
predicate: () => settings.store.showModView,
|
||||||
|
replacement: {
|
||||||
|
match: /(role:)\i(?=,guildId.{0,100}role:(\i\[))/,
|
||||||
|
replace: "$1$2arguments[0].member.highestRoleId]",
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
find: "prod_discoverable_guilds",
|
find: "prod_discoverable_guilds",
|
||||||
predicate: () => settings.store.disableDiscoveryFilters,
|
predicate: () => settings.store.disableDiscoveryFilters,
|
||||||
|
|
Loading…
Add table
Reference in a new issue