Skip to content

Commit

Permalink
🤖 commit the built plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Oct 28, 2022
1 parent c22aef2 commit c8ee59d
Show file tree
Hide file tree
Showing 2 changed files with 169 additions and 29 deletions.
196 changes: 168 additions & 28 deletions release/AutoIdleOnAFK.plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
Plugin only works when your status is 'online' and you are not in a voice channel.
For Bugs or Feature Requests open an issue on my Github
* @version 0.3.1
* @version 0.3.2
* @author RoguedBear
* @authorLink https://github.com/RoguedBear
* @website https://github.com/RoguedBear/BetterDiscordPlugin-AutoIdleOnAFK
* @source https://github.com/RoguedBear/BetterDiscordPlugin-AutoIdleOnAFK/releases/latest/download/AutoIdleOnAFK.plugin.js
* @source https://raw.githubusercontent.com/RoguedBear/BetterDiscordPlugin-AutoIdleOnAFK/main/release/AutoIdleOnAFK.plugin.js
*/
/*@cc_on
@if (@_jscript)
Expand All @@ -33,36 +33,169 @@ For Bugs or Feature Requests open an issue on my Github
WScript.Quit();
@else@*/
const config = {"info":{"name":"AutoIdleOnAFK","authors":[{"name":"RoguedBear","github_username":"RoguedBear","link":"https://github.com/RoguedBear"}],"version":"0.3.1","description":"Automatically updates your discord status to 'idle' when you haven't opened your discord client for more than 5 minutes.\nPlugin only works when your status is 'online' and you are not in a voice channel. \n\nFor Bugs or Feature Requests open an issue on my Github","github":"https://github.com/RoguedBear/BetterDiscordPlugin-AutoIdleOnAFK","github_raw":"https://github.com/RoguedBear/BetterDiscordPlugin-AutoIdleOnAFK/releases/latest/download/AutoIdleOnAFK.plugin.js"},"changelog":[{"type":"fixed","title":"Fixed the plugin :)","items":["Fixed what discord broke in recent update. (thanks `Zerthox` for helping me find the new module to use!)"]}],"main":"index.js","DEBUG":false,"DEBUG_ActuallyChangeStatus":false,"defaultConfig":[{"type":"radio","name":"Change Status To:","note":"the status selected will be switched to when AFK. default: Idle","id":"afkStatus","value":"idle","options":[{"name":"Idle","value":"idle"},{"name":"Invisible","value":"invisible"},{"name":"Do Not Disturb","value":"dnd"}]},{"type":"slider","name":"AFK Timeout (minutes)","note":"minutes to wait before changing your status to Idle/Invisible","id":"afkTimeout","value":5,"defaultValue":5,"min":5,"max":30,"units":"min","markers":[5,10,15,20,25,30]},{"type":"slider","name":"Back To Online Delay (Grace/Cooldown Period)","note":"seconds to wait before changing your status back to Online. if you close or unfocus discord window, status will not be changed","id":"backToOnlineDelay","defaultValue":10,"value":10,"min":5,"max":120,"units":"s","markers":[5,10,30,60,90,120]},{"type":"switch","name":"Always Revert To Online","note":"Come back online even if this plugin didn't change your status. Useful for multiple devices.","id":"alwaysOnline","value":false,"defaultValue":false},{"type":"switch","name":"Show toast messages?","note":"toggles the visibility of \"Changing status back to online\" toast message","id":"showToasts","defaultValue":true,"value":true}]};
class Dummy {
constructor() {this._config = config;}
start() {}
stop() {}
}

if (!global.ZeresPluginLibrary) {
BdApi.showConfirmationModal("Library Missing", `The library plugin needed for ${config.info.name} is missing. Please click Download Now to install it.`, {
confirmText: "Download Now",
cancelText: "Cancel",
onConfirm: () => {
require("request").get("https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js", async (error, response, body) => {
if (error) return require("electron").shell.openExternal("https://betterdiscord.app/Download?id=9");
await new Promise(r => require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0PluginLibrary.plugin.js"), body, r));
});
const config = {
info: {
name: "AutoIdleOnAFK",
authors: [
{
name: "RoguedBear",
github_username: "RoguedBear",
link: "https://github.com/RoguedBear"
}
],
version: "0.3.2",
description: "Automatically updates your discord status to 'idle' when you haven't opened your discord client for more than 5 minutes.\nPlugin only works when your status is 'online' and you are not in a voice channel. \n\nFor Bugs or Feature Requests open an issue on my Github",
github: "https://github.com/RoguedBear/BetterDiscordPlugin-AutoIdleOnAFK",
github_raw: "https://raw.githubusercontent.com/RoguedBear/BetterDiscordPlugin-AutoIdleOnAFK/main/release/AutoIdleOnAFK.plugin.js"
},
changelog: [
{
type: "fixed",
title: "Fixed the plugin :) 🎉",
items: [
"Fixed the plugin after a long wait!!!",
"Thanks to: `@Violet-Vibes` for nudging me in the right direction, and `DevilBro's` BDFDB library for showing me the way!",
"so glad to have the plugin back working"
]
}
],
main: "index.js",
DEBUG: false,
DEBUG_ActuallyChangeStatus: false,
defaultConfig: [
{
type: "radio",
name: "Change Status To:",
note: "the status selected will be switched to when AFK. default: Idle",
id: "afkStatus",
value: "idle",
options: [
{
name: "Idle",
value: "idle"
},
{
name: "Invisible",
value: "invisible"
},
{
name: "Do Not Disturb",
value: "dnd"
}
]
},
{
type: "slider",
name: "AFK Timeout (minutes)",
note: "minutes to wait before changing your status to Idle/Invisible",
id: "afkTimeout",
value: 5,
defaultValue: 5,
min: 5,
max: 30,
units: "min",
markers: [
5,
10,
15,
20,
25,
30
]
},
{
type: "slider",
name: "Back To Online Delay (Grace/Cooldown Period)",
note: "seconds to wait before changing your status back to Online. if you close or unfocus discord window, status will not be changed",
id: "backToOnlineDelay",
defaultValue: 10,
value: 10,
min: 5,
max: 120,
units: "s",
markers: [
5,
10,
30,
60,
90,
120
]
},
{
type: "switch",
name: "Always Revert To Online",
note: "Come back online even if this plugin didn't change your status. Useful for multiple devices.",
id: "alwaysOnline",
value: false,
defaultValue: false
},
{
type: "switch",
name: "Show toast messages?",
note: "toggles the visibility of \"Changing status back to online\" toast message",
id: "showToasts",
defaultValue: true,
value: true
}
});
}

module.exports = !global.ZeresPluginLibrary ? Dummy : (([Plugin, Api]) => {
]
};
class Dummy {
constructor() {this._config = config;}
start() {}
stop() {}
}

if (!global.ZeresPluginLibrary) {
BdApi.showConfirmationModal("Library Missing", `The library plugin needed for ${config.name ?? config.info.name} is missing. Please click Download Now to install it.`, {
confirmText: "Download Now",
cancelText: "Cancel",
onConfirm: () => {
require("request").get("https://betterdiscord.app/gh-redirect?id=9", async (err, resp, body) => {
if (err) return require("electron").shell.openExternal("https://betterdiscord.app/Download?id=9");
if (resp.statusCode === 302) {
require("request").get(resp.headers.location, async (error, response, content) => {
if (error) return require("electron").shell.openExternal("https://betterdiscord.app/Download?id=9");
await new Promise(r => require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0PluginLibrary.plugin.js"), content, r));
});
}
else {
await new Promise(r => require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0PluginLibrary.plugin.js"), body, r));
}
});
}
});
}

module.exports = !global.ZeresPluginLibrary ? Dummy : (([Plugin, Api]) => {
const plugin = (Plugin, Library) => {
const { Logger, DiscordModules } = Library;
const {
SelectedChannelStore: { getVoiceChannelId },
} = DiscordModules;

// Logger.info("VC: " + getVoiceChannelId());
const StatusSetting =
BdApi.findModuleByProps("StatusSetting").StatusSetting;

const {
Webpack,
Webpack: { Filters },
} = BdApi;

const UserSettingsProtoStore = BdApi.Webpack.getModule(
(m) =>
m &&
typeof m.getName == "function" &&
m.getName() == "UserSettingsProtoStore" &&
m,
{ first: true, searchExports: true }
);

const UserSettingsProtoUtils = BdApi.Webpack.getModule(
(m) =>
m.ProtoClass &&
m.ProtoClass.typeName.endsWith(".PreloadedUserSettings"),
{ first: true, searchExports: true }
);

var DEBUG = false;
function log_debug(module, ...message) {
Expand Down Expand Up @@ -239,7 +372,7 @@ module.exports = !global.ZeresPluginLibrary ? Dummy : (([Plugin, Api]) => {
* @returns {string} the current user status
*/
currentStatus() {
return StatusSetting.getSetting();
return UserSettingsProtoStore.settings.status.status.value;
}
/**
* @returns {boolean} if user is in a VC
Expand Down Expand Up @@ -273,7 +406,14 @@ module.exports = !global.ZeresPluginLibrary ? Dummy : (([Plugin, Api]) => {
return;
}
log_debug("Actually changing status to: " + toStatus);
StatusSetting.updateSetting(toStatus);
UserSettingsProtoUtils.updateAsync(
"status",
(statusSetting) => {
log_debug(statusSetting);
statusSetting.status.value = toStatus;
},
0
);
}

/**
Expand All @@ -286,7 +426,7 @@ module.exports = !global.ZeresPluginLibrary ? Dummy : (([Plugin, Api]) => {
}
}
};
};
return plugin(Plugin, Api);
};
return plugin(Plugin, Api);
})(global.ZeresPluginLibrary.buildPlugin(config));
/*@end@*/
2 changes: 1 addition & 1 deletion release/AutoIdleOnAFK.plugin.js.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bf1aee35226eb2114f6d046d8fcea269159cfaaf7eb0bd5770025d0f7e52cee5 AutoIdleOnAFK.plugin.js
26ae77c5aa75ae6e0335ed68ed5438c1dfe36f3417d00a0fcc1007a89e1c51bb AutoIdleOnAFK.plugin.js

0 comments on commit c8ee59d

Please sign in to comment.