From 43cdab7ec53187f502c0dec90f8775aeaf9c5414 Mon Sep 17 00:00:00 2001 From: David Snyder <45735850+GypsyDangerous@users.noreply.github.com> Date: Wed, 14 Oct 2020 22:46:25 -0400 Subject: [PATCH] Revert "Reaction manager (#26)" This reverts commit 4d38b3ab1637dc1d7e93751bdf574c6ed594c408. --- .wakatime-project | 1 - package-lock.json | 52 +-- package.json | 2 - src/components/DashBoard/Dashboard.js | 49 +-- src/components/DashBoard/Dashboard.scss | 6 +- .../DashBoard/Discord/DiscordPage.js | 9 +- .../Plugins/CustomCommands/CommandItem.js | 2 +- .../Plugins/CustomCommands/CommandItem.scss | 32 +- .../Plugins/CustomCommands/CreateCommand.js | 2 +- .../DashBoard/Discord/Plugins/PluginHome.js | 9 +- .../DashBoard/Discord/Plugins/Roles.js | 67 ++++ .../Plugins/Roles/CreateJoinManager.js | 87 ----- .../Discord/Plugins/Roles/CreateManager.js | 97 ----- .../Discord/Plugins/Roles/ManagerItem.js | 342 ------------------ .../DashBoard/Discord/Plugins/Roles/Roles.js | 122 ------- .../DashBoard/Discord/Plugins/plugins.json | 65 ++-- src/components/Shared/RoleItem.js | 30 +- src/contexts/RoleContext.js | 90 ----- src/firebase.js | 4 - src/index.scss | 5 - 20 files changed, 157 insertions(+), 916 deletions(-) delete mode 100644 .wakatime-project create mode 100644 src/components/DashBoard/Discord/Plugins/Roles.js delete mode 100644 src/components/DashBoard/Discord/Plugins/Roles/CreateJoinManager.js delete mode 100644 src/components/DashBoard/Discord/Plugins/Roles/CreateManager.js delete mode 100644 src/components/DashBoard/Discord/Plugins/Roles/ManagerItem.js delete mode 100644 src/components/DashBoard/Discord/Plugins/Roles/Roles.js delete mode 100644 src/contexts/RoleContext.js diff --git a/.wakatime-project b/.wakatime-project deleted file mode 100644 index 2112f1d..0000000 --- a/.wakatime-project +++ /dev/null @@ -1 +0,0 @@ -Frontend \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 5811de0..05c6739 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5947,15 +5947,6 @@ } } }, - "emoji-mart": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/emoji-mart/-/emoji-mart-3.0.0.tgz", - "integrity": "sha512-r5DXyzOLJttdwRYfJmPq/XL3W5tiAE/VsRnS0Hqyn27SqPA/GOYwVUSx50px/dXdJyDSnvmoPbuJ/zzhwSaU4A==", - "requires": { - "@babel/runtime": "^7.0.0", - "prop-types": "^15.6.0" - } - }, "emoji-regex": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", @@ -9488,11 +9479,6 @@ "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", "integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY=" }, - "lodash.isequal": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", - "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=" - }, "lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", @@ -10369,6 +10355,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "requires": { + "is-descriptor": "^0.1.0" } } @@ -12602,16 +12589,6 @@ "prop-types": "^15.6.2" } }, - "react-twemoji": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/react-twemoji/-/react-twemoji-0.3.0.tgz", - "integrity": "sha512-y2ZQD3KvpZklETxz9c1NycRdUVF5nKsJ0bPNW3SaRJT+ReK36sMcneYwRPfv9EK2p3s9ph/NczDglnB8wbMJ0g==", - "requires": { - "lodash.isequal": "^4.5.0", - "prop-types": "^15.7.2", - "twemoji": "^13.0.1" - } - }, "react-universal-interface": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/react-universal-interface/-/react-universal-interface-0.6.0.tgz", @@ -14747,33 +14724,6 @@ "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" }, - "twemoji": { - "version": "13.0.1", - "resolved": "https://registry.npmjs.org/twemoji/-/twemoji-13.0.1.tgz", - "integrity": "sha512-mrTBq+XpCLM4zm76NJOjLHoQNV9mHdBt3Cba/T5lS1rxn8ArwpqE47mqTocupNlkvcLxoeZJjYSUW0DU5ZwqZg==", - "requires": { - "fs-extra": "^8.0.1", - "jsonfile": "^5.0.0", - "twemoji-parser": "13.0.0", - "universalify": "^0.1.2" - }, - "dependencies": { - "jsonfile": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-5.0.0.tgz", - "integrity": "sha512-NQRZ5CRo74MhMMC3/3r5g2k4fjodJ/wh8MxjFbCViWKFjxrnudWSY5vomh+23ZaXzAS7J3fBZIR2dV6WbmfM0w==", - "requires": { - "graceful-fs": "^4.1.6", - "universalify": "^0.1.2" - } - } - } - }, - "twemoji-parser": { - "version": "13.0.0", - "resolved": "https://registry.npmjs.org/twemoji-parser/-/twemoji-parser-13.0.0.tgz", - "integrity": "sha512-zMaGdskpH8yKjT2RSE/HwE340R4Fm+fbie4AaqjDa4H/l07YUmAvxkSfNl6awVWNRRQ0zdzLQ8SAJZuY5MgstQ==" - }, "type": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", diff --git a/package.json b/package.json index 2d70241..606a454 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,6 @@ "@testing-library/react": "^9.5.0", "@testing-library/user-event": "^7.2.1", "chroma-js": "^2.1.0", - "emoji-mart": "^3.0.0", "firebase": "^7.14.2", "lodash": "^4.17.15", "node-sass": "^4.14.0", @@ -25,7 +24,6 @@ "react-router-dom": "^5.2.0", "react-scripts": "^3.4.3", "react-select": "^3.1.0", - "react-twemoji": "^0.3.0", "react-use": "^15.1.0", "styled-components": "^5.2.0", "uid": "^1.0.0", diff --git a/src/components/DashBoard/Dashboard.js b/src/components/DashBoard/Dashboard.js index a161587..eb83096 100644 --- a/src/components/DashBoard/Dashboard.js +++ b/src/components/DashBoard/Dashboard.js @@ -6,26 +6,23 @@ import A from "../Shared/A"; import SettingBox from "./Settings/SettingBox"; import { AppContext } from "../../contexts/Appcontext"; import DiscordPage from "./Discord/DiscordPage"; -import AccountSettings from "./Account/Account"; -import plugins from "./Discord/Plugins/plugins.json"; -import { DiscordContextProvider, DiscordContext } from "../../contexts/DiscordContext"; +import AccountSettings from "./Account/Account" const Dashboard = props => { const [overlaySettings, setOverlaySettings] = useState(); const [appSettings, setAppSettings] = useState(); const [defaultSettings, setDefaultSettings] = useState(); const { currentUser } = useContext(AppContext); - const id = firebase.auth.currentUser.uid; - const [discordId, setDiscordId] = useState(""); - const { activePlugins } = useContext(DiscordContext); - useEffect(() => { - const idRegex = new RegExp("/\\d{17,19}[/\\b]"); - const path = props.location.pathname + "/"; - const id = path.match(idRegex); - if (id) { - setDiscordId(id[0].replace(/\//g, "")); - } - }, [props]); + const id = firebase.auth.currentUser.uid; + const [discordId, setDiscordId] = useState("") + useEffect(() => { + const idRegex = new RegExp("/\\d{17,19}[/\\b]") + const path = props.location.pathname+"/" + const id = path.match(idRegex) + if(id){ + setDiscordId(id[0].replace(/\//g, "")) + } + }, [props]) useEffect(() => { (async () => { @@ -82,20 +79,6 @@ const Dashboard = props => { Discord Settings - Account Settings @@ -149,12 +132,4 @@ const Dashboard = props => { ); }; -const IntermediateDashboard = props => { - return ( - - - - ); -}; - -export default IntermediateDashboard; +export default Dashboard; diff --git a/src/components/DashBoard/Dashboard.scss b/src/components/DashBoard/Dashboard.scss index 0638493..a984b88 100644 --- a/src/components/DashBoard/Dashboard.scss +++ b/src/components/DashBoard/Dashboard.scss @@ -157,11 +157,7 @@ align-items: center; padding: 0 1rem; border-radius: 0.5rem; - text-transform: capitalize; - &.smaller{ - height: 35px; - padding: 0 .5rem; - } + text-transform: capitalize; } .setting-link.active { diff --git a/src/components/DashBoard/Discord/DiscordPage.js b/src/components/DashBoard/Discord/DiscordPage.js index 7794f55..aac5bd7 100644 --- a/src/components/DashBoard/Discord/DiscordPage.js +++ b/src/components/DashBoard/Discord/DiscordPage.js @@ -273,5 +273,12 @@ const DiscordPage = React.memo(({ location, history, match }) => { ); }); +const IntermediateDiscordPage = props => { + return ( + + + + ); +}; -export default withRouter(React.memo(DiscordPage)); +export default withRouter(React.memo(IntermediateDiscordPage)); diff --git a/src/components/DashBoard/Discord/Plugins/CustomCommands/CommandItem.js b/src/components/DashBoard/Discord/Plugins/CustomCommands/CommandItem.js index 7baf746..6c07e0f 100644 --- a/src/components/DashBoard/Discord/Plugins/CustomCommands/CommandItem.js +++ b/src/components/DashBoard/Discord/Plugins/CustomCommands/CommandItem.js @@ -71,7 +71,7 @@ const CommandItem = ({ }); } setDescription(description); - // console.log({ allowedRoles }); + console.log({ allowedRoles }); setAllowedRoles(allowedRoles || []); setAllowedChannels( (allowedChannels || []).map(id => { diff --git a/src/components/DashBoard/Discord/Plugins/CustomCommands/CommandItem.scss b/src/components/DashBoard/Discord/Plugins/CustomCommands/CommandItem.scss index e3356ff..caccd3f 100644 --- a/src/components/DashBoard/Discord/Plugins/CustomCommands/CommandItem.scss +++ b/src/components/DashBoard/Discord/Plugins/CustomCommands/CommandItem.scss @@ -14,7 +14,21 @@ .command-item--info{ margin-left: 1rem; } - + .delete-button { + position: absolute; + color: #b33a3a; + width: 24px; + height: 24px; + top: -12px; + right: -12px; + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; + &:hover{ + filter: saturate(1.5); + } + } h1, h2, h3, @@ -49,19 +63,3 @@ }; } } - -.delete-button { - position: absolute; - color: #b33a3a; - width: 24px; - height: 24px; - top: -12px; - right: -12px; - display: flex; - align-items: center; - justify-content: center; - cursor: pointer; - &:hover{ - filter: saturate(1.5); - } -} \ No newline at end of file diff --git a/src/components/DashBoard/Discord/Plugins/CustomCommands/CreateCommand.js b/src/components/DashBoard/Discord/Plugins/CustomCommands/CreateCommand.js index 4d62048..b3936ea 100644 --- a/src/components/DashBoard/Discord/Plugins/CustomCommands/CreateCommand.js +++ b/src/components/DashBoard/Discord/Plugins/CustomCommands/CreateCommand.js @@ -95,7 +95,7 @@ const CreateCommand = ({ setCreatingCommand, children, role, guild: userConnecte return ( <>
-

Create {role ? "Role" : "Text"} Command

+

Create Role Command

diff --git a/src/components/DashBoard/Discord/Plugins/PluginHome.js b/src/components/DashBoard/Discord/Plugins/PluginHome.js index f3620a7..dd6cc08 100644 --- a/src/components/DashBoard/Discord/Plugins/PluginHome.js +++ b/src/components/DashBoard/Discord/Plugins/PluginHome.js @@ -9,9 +9,8 @@ import Logging from "./Logging"; import plugins from "./plugins.json"; import CustomCommands from "./CustomCommands/CustomCommands"; import { CommandContextProvider } from "../../../../contexts/CommandContext"; -import { RoleContextProvider } from "../../../../contexts/RoleContext"; import App from "./App"; -import Roles from "./Roles/Roles"; +import Roles from "./Roles"; const PluginHome = ({ match, guildId, connectedGuild }) => { const [prefix, setPrefix] = useState("!"); @@ -93,7 +92,7 @@ const PluginHome = ({ match, guildId, connectedGuild }) => { description="Get discord chats from your server in the DisStreamChat app" /> {displayPlugins.map(plugin => ( - + ))}
@@ -116,9 +115,9 @@ const PluginHome = ({ match, guildId, connectedGuild }) => { )} {activePlugins["roles"] && ( - + - + )} diff --git a/src/components/DashBoard/Discord/Plugins/Roles.js b/src/components/DashBoard/Discord/Plugins/Roles.js new file mode 100644 index 0000000..6c29be4 --- /dev/null +++ b/src/components/DashBoard/Discord/Plugins/Roles.js @@ -0,0 +1,67 @@ +import React, { useEffect, useState, useCallback, useContext } from "react"; +import firebase from "../../../../firebase"; +import { colorStyles } from "../../../Shared/userUtils"; +import { DiscordContext } from "../../../../contexts/DiscordContext"; +import Select from "react-select"; + +const Leveling = ({ location, guild: userConnectedGuildInfo }) => { + const { setActivePlugins } = useContext(DiscordContext); + const guildId = userConnectedGuildInfo?.id; + + useEffect(() => { + (async () => { + const guild = await firebase.db + .collection("Leveling") + .doc(guildId || " ") + .get(); + const data = guild.data(); + if (data) { + const id = data.notifications; + if (id) { + const apiUrl = `${process.env.REACT_APP_API_URL}/resolvechannel?guild=${guildId}&channel=${id}`; + const response = await fetch(apiUrl); + const channel = await response.json(); + } + } + })(); + }, [location, guildId]); + + return ( +
+
+ + +

Role Management

+
+ + + +
+
+
+

Different ways to have the bot manage user roles. Give a role on join, toggle roles with reactions, etc.

+
+
+

Add an action

+
+
+
+ ); +}; + +export default React.memo(Leveling); diff --git a/src/components/DashBoard/Discord/Plugins/Roles/CreateJoinManager.js b/src/components/DashBoard/Discord/Plugins/Roles/CreateJoinManager.js deleted file mode 100644 index 4f0abba..0000000 --- a/src/components/DashBoard/Discord/Plugins/Roles/CreateJoinManager.js +++ /dev/null @@ -1,87 +0,0 @@ -import ClearIcon from "@material-ui/icons/Clear"; -import { DiscordContext } from "../../../../../contexts/DiscordContext"; -import React, { useEffect, useState, useCallback, useContext } from "react"; -import Select from "react-select"; -import { colorStyles } from "../../../../Shared/userUtils"; -import RoleItem from "../../../../Shared/RoleItem"; - -import { RoleContext } from "../../../../../contexts/RoleContext"; -import firebase from "../../../../../firebase"; -import { ActionItem } from "./ManagerItem"; - -const parseSelectValue = value => { - if (value instanceof Array) { - if (value.length === 0) return value; - return value.map(role => JSON.parse(role.value.split("=")[1])).map(val => val.id); - } else { - try { - return JSON.parse(value.value.split("=")[1]).id; - } catch (err) { - return null; - } - } -}; - -const CreateJoinManager = ({ setCreatingCommand, guild: userConnectedGuildInfo }) => { - const { state, update, error, setup, addReaction } = useContext(RoleContext); - const [addingAction, setAddingAction] = useState(false); - - useEffect(() => { - update("manager.message", "member-join"); - }, []); - return ( - <> -
-

Create Join Manager

- -
-
-

Member Join Role

-
- update("manager.message", e.target.value)} - placeholder="Message Id" - type="text" - className="prefix-input" - id="manager-message" - /> -
-

Manager Actions

-
- {Object.entries(state?.manager?.actions || {})?.map(([key, action]) => ( - - ))} - {addingAction && ( - setAddingAction(false)} - index={(state.manager?.actions?.length || -1) + 1} - guild={userConnectedGuildInfo} - adding - deleteAble={false} - /> - )} - { - setAddingAction(true); - }} - add - deleteAble={false} - /> -
- -
-
- {state.error?.message && {state.error?.message}} - -
- - ); -}; - -export default CreateManager; diff --git a/src/components/DashBoard/Discord/Plugins/Roles/ManagerItem.js b/src/components/DashBoard/Discord/Plugins/Roles/ManagerItem.js deleted file mode 100644 index 9abdf75..0000000 --- a/src/components/DashBoard/Discord/Plugins/Roles/ManagerItem.js +++ /dev/null @@ -1,342 +0,0 @@ -import React, { useState, useEffect, useContext } from "react"; -import styled from "styled-components"; -import RoleItem from "../../../../Shared/RoleItem"; -import CancelTwoToneIcon from "@material-ui/icons/CancelTwoTone"; -import Twemoji from "react-twemoji"; -import AddCircleTwoToneIcon from "@material-ui/icons/AddCircleTwoTone"; -import { RoleContext } from "../../../../../contexts/RoleContext"; -import { Picker } from "emoji-mart"; -import "emoji-mart/css/emoji-mart.css"; -import Select from "react-select"; -import { colorStyles } from "../../../../Shared/userUtils"; -import CloseIcon from "@material-ui/icons/Close"; -import CheckIcon from "@material-ui/icons/Check"; -import firebase from "../../../../../firebase"; -import FormControlLabel from "@material-ui/core/FormControlLabel"; -import { Switch } from "@material-ui/core"; -import { withStyles } from "@material-ui/core/styles"; -import { blueGrey } from "@material-ui/core/colors"; - -const FancySwitch = withStyles({ - root: { - padding: 7, - }, - thumb: { - width: 24, - height: 24, - backgroundColor: "#fff", - boxShadow: "0 0 12px 0 rgba(0,0,0,0.08), 0 0 8px 0 rgba(0,0,0,0.12), 0 0 4px 0 rgba(0,0,0,0.38)", - }, - switchBase: { - color: "rgba(0,0,0,0.38)", - padding: 7, - }, - track: { - borderRadius: 20, - backgroundColor: blueGrey[300], - }, - checked: { - "& $thumb": { - backgroundColor: "#fff", - }, - "& + $track": { - opacity: "1 !important", - }, - }, - focusVisible: {}, -})(Switch); - -const ChannelParent = styled.span` - color: #aaa; - font-size: 14px; - margin-left: 0.25rem; -`; - -const ManagerBody = styled.div` - margin: 1rem 0; - display: flex; - // align-items: center; - // justify-content: space-between; - position: relative; - padding: 0.5rem 1rem; - border: 1px solid black; - background: #1f1f1f; - flex-direction: column; -`; - -const ActionBody = styled.div` - display: flex; - padding: 1rem; - justify-content: space-between; - margin: 0.25rem; - margin-left: 0.75rem; - background: #1a1a1a; - position: relative; - align-items: center; - border-radius: 0.25rem; - z-index: ${props => (props.adding ? 10 : 0)}; - h3, - h2, - h4, - h1, - p { - margin: 0; - } - & > div:not(:first-child) { - margin-left: 0.5rem; - margin-right: 0.5rem; - } -`; - -const ActionButton = styled.div` - cursor: pointer; -`; - -const FlexContainer = styled.span` - display: flex; - align-items: center; -`; - -const types = { - ADD_ON_ADD: "Add", - REMOVE_ON_REMOVE: "Remove", - ADD_ON_REMOVE: "Add (reversed)", - REMOVE_ON_ADD: "Remove (reversed)", - TOGGLE: "Toggle", -}; - -export const ActionItem = React.memo(({ message, onSubmit, DMuser, role, guild, adding, emoji, type, deleteAble, add, onClick, close }) => { - const [displayRole, setDisplayRole] = useState(); - const { state, update } = useContext(RoleContext); - const [action, setAction] = useState({}); - - useEffect(() => { - if (!add && !adding) { - setDisplayRole(guild.roles.find(r => r.id === role)); - } - }, [adding, guild, role, add]); - - const submit = () => { - const roleID = JSON.parse(action.role.value.split("=")[1]).id; - console.log(roleID); - const actionObj = { - role: roleID, - type: action.type, - DMuser: action.DMuser, - }; - if (onSubmit) { - onSubmit(action.emoji, actionObj); - } else { - update(`manager.actions[${action.emoji}]`, actionObj); - } - return close?.(); - }; - - const deleteMe = async () => { - if (!deleteAble) return; - await firebase.db - .collection("reactions") - .doc(guild.id) - .update({ [`${message}.actions.${emoji}`]: firebase.delete() }); - }; - - return ( - - {deleteAble && ( -
- -
- )} - {!add && !adding ? ( - <> - - - - {emoji?.replace("catch-all", "All").replace("-", " ")} - - - -{" "} - {displayRole && ( - - {displayRole.name} - - )} - - -

Type: {types[type]}

-

DM: {(!!DMuser).toString()}

-
- - ) : !adding ? ( - onClick?.()} style={{ cursor: "pointer", display: "flex", alignItems: "center" }}> - -

Add Action

-
- ) : ( - <> - - { - if (e.target.checked) { - setAction(prev => ({ ...prev, emoji: "catch-all" })); - } else { - setAction(prev => ({ ...prev, emoji: null })); - } - }} - name={"catch-all"} - /> - } - label={"ALL"} - /> - - {action.emoji ? ( - - {action.emoji?.replace("catch-all", "All").replace("-", " ")} - - ) : ( - setAction(prev => ({ ...action, emoji: emoji.native }))} - /> - )} - Role:{" "} -
- { - setAction(prev => ({ ...prev, type: e.value })); - }} - placeholder="Select Action Type" - value={action?.type ? { value: action?.type, label: types[action?.type] } : ""} - options={Object.entries(types || {})?.map(([key, value]) => ({ - value: key, - label: value, - }))} - styles={{ - ...colorStyles, - container: styles => ({ - ...styles, - ...colorStyles.container, - }), - }} - /> -
-
- { - setAction(prev => ({ ...prev, DMuser: e.target.checked })); - }} - name={"dm_user"} - /> - } - label={"DM"} - /> -
- {action.role && action.type && action.emoji && ( - - - - )} - close?.()}> - - - - )} -
- ); -}); - -const ManagerItem = React.memo(({ guild, channel, actions, channelOveride, message, join }) => { - const [displayChannel, setDisplayChannel] = useState(); - const [addingAction, setAddingAction] = useState(false); - - console.log(message); - - useEffect(() => { - setDisplayChannel(guild.channels.find(c => c.id === channel)); - }, [channel, guild]); - - const deleteMe = async () => { - await firebase.db - .collection("reactions") - .doc(guild.id) - .update({ [`${message}`]: firebase.delete() }); - }; - - return ( - -
- -
-

- {displayChannel?.name || channelOveride} {displayChannel?.parent} -

- {Object.entries(actions || {}) - .sort() - .map(([key, value]) => ( - - ))} - {addingAction && ( - { - await firebase.db - .collection("reactions") - .doc(guild.id) - .update({ [`${message}.actions.${emoji}`]: { ...action, DMuser: !!action.DMuser } }); - }} - close={() => setAddingAction(false)} - guild={guild} - adding - deleteAble={false} - /> - )} - {!join && ( - { - setAddingAction(true); - }} - deleteAble={false} - add - > - )} -
- ); -}); - -export default ManagerItem; diff --git a/src/components/DashBoard/Discord/Plugins/Roles/Roles.js b/src/components/DashBoard/Discord/Plugins/Roles/Roles.js deleted file mode 100644 index 2f603cd..0000000 --- a/src/components/DashBoard/Discord/Plugins/Roles/Roles.js +++ /dev/null @@ -1,122 +0,0 @@ -import React, { useEffect, useState, useCallback, useContext } from "react"; -import firebase from "../../../../../firebase"; -import { DiscordContext } from "../../../../../contexts/DiscordContext"; -import { RoleContext } from "../../../../../contexts/RoleContext"; -import ManagerItem from "./ManagerItem"; -import Modal from "react-modal"; -import CreateManager from "./CreateManager"; -import CreateJoinManager from "./CreateJoinManager"; - -const Roles = ({ location, guild: userConnectedGuildInfo }) => { - const [MessageManagers, setMessageManagers] = useState([]); - const [JoinManager, setJoinManager] = useState(); - const { setActivePlugins } = useContext(DiscordContext); - const { state, create, setup } = useContext(RoleContext); - const guildId = userConnectedGuildInfo?.id; - - useEffect(() => { - const unsub = firebase.db - .collection("reactions") - .doc(guildId || " ") - .onSnapshot(snapshot => { - const data = snapshot.data(); - if (data) { - const managerKeys = Object.keys(data).filter(key => key !== "member-join"); - setMessageManagers(managerKeys.map(key => ({ message: key, ...data[key] }))); - if (data["member-join"]) { - setJoinManager({ message: "member-join", ...data["member-join"] }); - } else { - setJoinManager(null); - } - } - }); - return unsub; - }, [location, guildId]); - - useEffect(() => { - document.body.style.overflow = state.type ? "hidden" : "initial"; - return () => { - document.body.style.overflow = "initial"; - }; - }, [state]); - - return ( -
- - {state.type === "message" ? ( - - ) : ( - - )} - -
- - -

Role Management

-
- - - -
-
-
-

Different ways to have the bot manage user roles. Give a role on join, toggle roles with reactions, etc.

-
-
-

Create Manager

-
-
{ - create("message"); - }} - > -

Message Manager

-

allow users to give/remove roles from themeselves by reacting to a message

-
- {!JoinManager && ( -
{ - create("join"); - }} - > -

Member Join Manager

-

Automatically Give a user a role when they join your server

-
- )} -
- {!state.type && JoinManager && ( - <> -

Member Join Manager

- - - )} -

- Message Managers — {MessageManagers.length} -

- {!state.type && - MessageManagers.sort((a, b) => a.message.localeCompare(b.message)).map((manager, i) => ( - - ))} -
-
- ); -}; - -export default React.memo(Roles); diff --git a/src/components/DashBoard/Discord/Plugins/plugins.json b/src/components/DashBoard/Discord/Plugins/plugins.json index c1a2d78..12c16de 100644 --- a/src/components/DashBoard/Discord/Plugins/plugins.json +++ b/src/components/DashBoard/Discord/Plugins/plugins.json @@ -3,70 +3,69 @@ "id": "leveling", "title": "Leveling", "image": "trophy.svg", - "description": "Let your users gain XP and levels by participating in the chat!", - "comingSoon": false + "description": "Let your users gain XP and levels by participating in the chat!", + "comingSoon": false }, { "id": "commands", "title": "Custom Commands", "image": "discord.png", - "description": "Create custom commands for your server", - "comingSoon": false + "description": "Create custom commands for your server", + "comingSoon": false }, { "id": "logging", "title": "Logging", "image": "clipboard.svg", - "description": "Log the events that take place on your server", - "comingSoon": false - }, - { - "id": "roles", - "title": "Role Management", - "image": "aprove.png", - "description": "Let the bot manage members roles in different ways like reaction roles" + "description": "Log the events that take place on your server", + "comingSoon": false }, { "id": "welcome", "title": "Welcome", "image": "wave.svg", - "description": "Send a welcome message to new users", - "comingSoon": true + "description": "Send a welcome message to new users", + "comingSoon": true }, { "id": "streamislive", "title": "Stream Notifications", "image": "twitch.svg", - "description": "Let your viewers when you go live", - "comingSoon": true - }, - { + "description": "Let your viewers when you go live", + "comingSoon": true + }, + { "id": "moderation", "title": "Moderation", "image": "mod.svg", - "description": "Power up your moderation with cool commands and automations!", - "comingSoon": true - }, - - { + "description": "Power up your moderation with cool commands and automations!", + "comingSoon": true + }, + { + "id": "roles", + "title": "Role Management", + "image": "aprove.png", + "description": "Let the bot manage members roles in different ways like reaction roles", + "comingSoon": true + }, + { "id": "music", "title": "Music", "image": "music.svg", - "description": "Listen to music directly on Discord", - "comingSoon": true - }, - { + "description": "Listen to music directly on Discord", + "comingSoon": true + },{ "id": "polls", "title": "Polls", "image": "poll.svg", - "description": "Hold polls within your server", - "comingSoon": true - }, - { + "description": "Hold polls within your server", + "comingSoon": true + },{ "id": "giveaways", "title": "Giveaways", "image": "gift.svg", - "description": "Host giveaways within your server", - "comingSoon": true + "description": "Host giveaways within your server", + "comingSoon": true + } ] diff --git a/src/components/Shared/RoleItem.js b/src/components/Shared/RoleItem.js index 00bdf5e..427c064 100644 --- a/src/components/Shared/RoleItem.js +++ b/src/components/Shared/RoleItem.js @@ -1,6 +1,6 @@ import styled from "styled-components"; -const colorify = number => `#${number === 0 ? "#99aab5" : number?.toString?.(16)?.padStart?.(6, "0") || "black"}`; +const colorify = number => `#${number === 0 ? "#99aab5" : number.toString(16).padStart(6, '0')}`; const RoleItem = styled.div` height: 12px; @@ -13,20 +13,20 @@ const RoleItem = styled.div` align-items: center; background: #2f3136aa; border: 2px solid ${props => colorify(props.color)}; - line-height: 1; - position: relative; - font-weight: 600; - color: #ccc; - &:before { - display: inline-block; - content: ""; - width: 12px; - height: 12px; - margin-left: -0.25rem; - margin-right: 0.25rem; - border-radius: 50%; - background: ${props => colorify(props.color)}; - } + line-height: 1; + position: relative; + font-weight: 600; + color: #ccc; + &:before{ + display: inline-block; + content: ""; + width: 12px; + height: 12px; + margin-left: -.25rem; + margin-right: .25rem; + border-radius: 50%; + background: ${props => colorify(props.color)}; + } `; export default RoleItem; diff --git a/src/contexts/RoleContext.js b/src/contexts/RoleContext.js deleted file mode 100644 index e94bef3..0000000 --- a/src/contexts/RoleContext.js +++ /dev/null @@ -1,90 +0,0 @@ -import React, { createContext, useReducer } from "react"; -import lodash from "lodash"; -// lodash.get(object, nestedPropertyString); -// lodash.set(object, path, value) -export const RoleContext = createContext({}); - -const Actions = { - EDIT: "edit", - CREATE: "create", - UPDATE: "update", - ERROR: "error", - SETUP: "setup", - ADD_REACTION: "add_reaction", -}; - -const initialState = { - editing: false, - error: null, - manager: {}, - type: null, -}; - -const RoleReducer = (state, action) => { - switch (action.type) { - case Actions.SETUP: - return initialState; - case Actions.EDIT: - return { ...state, manager: action.manager, type: action.creatingType, editing: true }; - case Actions.CREATE: - return { ...state, type: action.creatingType }; - case Actions.UPDATE: - const newState = { ...state }; - lodash.set(newState, action.path, action.value); - return newState; - case Actions.ERROR: - return { ...state, error: { message: action.message } }; - case Actions.ADD_REACTION: - if (state.manager?.actions) { - return { ...state, manager: { ...state.manager, actions: [...state.manager.actions, action.reaction] } }; - } else { - return { ...state, manager: { ...state.manager, actions: [action.reaction] } }; - } - default: - return state; - } -}; - -export const RoleContextProvider = props => { - const [state, dispatch] = useReducer(RoleReducer, initialState); - - const setup = () => dispatch({ type: Actions.SETUP }); - - const create = type => { - setup(); - dispatch({ type: Actions.CREATE, creatingType: type }); - }; - - const edit = (manager, type) => { - dispatch({ type: Actions.EDIT, manager, creatingType: type }); - }; - - const update = (path, value) => { - dispatch({ type: Actions.UPDATE, path, value }); - }; - - const error = message => { - dispatch({ type: Actions.ERROR, message }); - }; - - const addReaction = reaction => { - dispatch({ type: Actions.ADD_REACTION, reaction }); - }; - - return ( - - {props.children} - - ); -}; diff --git a/src/firebase.js b/src/firebase.js index 2c1b1cc..d1b2d06 100644 --- a/src/firebase.js +++ b/src/firebase.js @@ -65,10 +65,6 @@ class Firebase { getCurrentUsername() { return this.auth.currentUser.displayName } - - delete(){ - return this.app.firestore.FieldValue.delete() - } } diff --git a/src/index.scss b/src/index.scss index 43a98e0..563c48d 100644 --- a/src/index.scss +++ b/src/index.scss @@ -63,8 +63,3 @@ hr { text-transform: uppercase; } } - - -.twemoji{ - width: 25px; -} \ No newline at end of file