Skip to content
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.

Revert "add discord sign in by default" #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions public/discord.svg

This file was deleted.

Binary file removed public/discord_logo.png
Binary file not shown.
1 change: 0 additions & 1 deletion public/gift.svg

This file was deleted.

1 change: 0 additions & 1 deletion public/music.svg

This file was deleted.

1 change: 0 additions & 1 deletion public/poll.svg

This file was deleted.

31 changes: 9 additions & 22 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { Button } from "@material-ui/core";
import A from "./components/Shared/A";
import useSnapshot from "./hooks/useSnapshot";
import LeaderBoard from "./components/LeaderBoard/LeaderBoard";
import { v4 as uuidv4 } from "uuid";
import { v4 as uuidv4 } from 'uuid';

function App(props) {
const [userId, setUserId] = useState("");
Expand Down Expand Up @@ -57,8 +57,8 @@ function App(props) {
(async () => {
if (setOTC.current) return;
if (firebaseInit !== false && user?.uid) {
await firebase.db.collection("Secret").doc(user.uid).set({ value: uuidv4() });
setOTC.current = true;
await firebase.db.collection("Secret").doc(user.uid).set({value: uuidv4()});
setOTC.current = true
}
})();
}, [firebaseInit, user, setOTC]);
Expand All @@ -80,30 +80,24 @@ function App(props) {
} else {
try {
console.log(code);
const isSignedIn = !!firebase.auth.currentUser;
const response = await fetch(`${process.env.REACT_APP_API_URL}/discord/token?code=${code}&create=${!isSignedIn}`);
const response = await fetch(`${process.env.REACT_APP_API_URL}/discord/token?code=${code}`);
// const response = await fetch("http://localhost:3200/discord/token?code="+code)
if (!response.ok) {
console.log(await response.json());
alert("fail");
console.log("fail");
} else {
console.log(user?.uid);
const json = await response.json();
let discordUser;
if (!isSignedIn) {
discordUser = await firebase.auth.signInWithCustomToken(json.token);
}

await firebase.db
.collection("Streamers")
.doc(user?.uid || discordUser?.uid || " ")
.doc(user?.uid || " ")
.collection("discord")
.doc("data")
.set(json);
alert("success");
console.log("success");
}
} catch (err) {
alert(err.message);
console.log(err.message);
}
}
window.location = "/#/dashboard/discord";
Expand All @@ -116,14 +110,7 @@ function App(props) {
if (firebaseInit !== false && user) {
setUserId(user.uid);
const userData = (await firebase.db.collection("Streamers").doc(user.uid).get()).data();
let profilePictureResponse;
if (!userData.twitchAuthenticated) {
profilePictureResponse = await fetch(
`${process.env.REACT_APP_API_URL}/profilepicture?user=${userData?.discordId}&platform=discord`
);
} else {
profilePictureResponse = await fetch(`${process.env.REACT_APP_API_URL}/profilepicture?user=${userData?.TwitchName}`);
}
const profilePictureResponse = await fetch(`${process.env.REACT_APP_API_URL}/profilepicture?user=${userData?.TwitchName}`);
const profilePicture = await profilePictureResponse.json();
firebase.db.collection("Streamers").doc(user.uid).update({
profilePicture,
Expand Down
29 changes: 13 additions & 16 deletions src/components/DashBoard/Discord/DiscordPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,22 +177,19 @@ const DiscordPage = React.memo(({ location, history, match }) => {
async e => {
const name = e.value;
const guildByName = userDiscordInfo.guilds.find(guild => guild.name === name);
const selectedGuildId = guildByName.id;
try{

if (guildId) {
const path = match.url.split("/");
if (path.length > 3) {
history.push(`${path.slice(0, 3).join("/")}/${selectedGuildId}`);
} else {
history.push(`${selectedGuildId}`);
}
} else {
history.push(`${match.url}/${selectedGuildId}`);
}
}catch(err){

}
const selectedGuildId = guildByName.id;
try {
if (guildId) {
const path = match.url.split("/");
if (path.length > 3) {
history.push(`${path.slice(0, 3).join("/")}/${selectedGuildId}`);
} else {
history.push(`${selectedGuildId}`);
}
} else {
history.push(`${match.url}/${selectedGuildId}`);
}
} catch (err) {}
const { result: isMember } = await sendLoadingRequest(`${process.env.REACT_APP_API_URL}/ismember?guild=` + selectedGuildId);
// const channelReponse = await sendLoadingRequest(`${process.env.REACT_APP_API_URL}/getchannels?guild=` + selectedGuildId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const CommandItem = ({
</div>
<span style={{ display: "flex" }}>
<div className="display-image">
<img alt="" width="50px" src={type === "role" ? "/role.svg" : "/speech.svg"} />
<img width="50px" src={type == "role" ? "/role.svg" : "/speech.svg"} />
</div>
<div className="command-item--info">
<h3>{name}</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const CreateCommand = ({ setCreatingCommand, children, role, guild: userConnecte
}))
);
}
}, [editing, userConnectedGuildInfo?.roles, setAllowedRoles]);
}, [editing]);


return (
Expand Down
8 changes: 0 additions & 8 deletions src/components/DashBoard/Discord/Plugins/PluginHome.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import plugins from "./plugins.json";
import CustomCommands from "./CustomCommands/CustomCommands";
import { CommandContextProvider } from "../../../../contexts/CommandContext";
import App from "./App";
import Roles from "./Roles";

const PluginHome = ({ match, guildId, connectedGuild }) => {
const [prefix, setPrefix] = useState("!");
Expand Down Expand Up @@ -113,13 +112,6 @@ const PluginHome = ({ match, guildId, connectedGuild }) => {
</CommandContextProvider>
</Route>
)}
{activePlugins["roles"] && (
<Route path={`${match.url}/roles`}>
<CommandContextProvider>
<Roles guild={connectedGuild} />
</CommandContextProvider>
</Route>
)}
<Route path={`${match.url}/app`}>
<App />
</Route>
Expand Down
67 changes: 0 additions & 67 deletions src/components/DashBoard/Discord/Plugins/Roles.js

This file was deleted.

24 changes: 2 additions & 22 deletions src/components/DashBoard/Discord/Plugins/plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,10 @@
"comingSoon": true
},
{
"id": "roles",
"title": "Role Management",
"id": "reactionroles",
"title": "Reaction Roles",
"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": "Let your members get roles by reacting to messages",
"comingSoon": true
},{
"id": "polls",
"title": "Polls",
"image": "poll.svg",
"description": "Let your members get roles by reacting to messages",
"comingSoon": true
},{
"id": "giveaways",
"title": "Giveaways",
"image": "gift.svg",
"description": "Let your members get roles by reacting to messages",
"comingSoon": true

}
]
31 changes: 7 additions & 24 deletions src/components/header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { CSSTransition } from "react-transition-group";
import ClickAwayListener from "@material-ui/core/ClickAwayListener";
import { useCallback } from "react";
import Modal from "react-modal";
import YouTubeIcon from "@material-ui/icons/YouTube";
import A from "../Shared/A";
import ClearIcon from "@material-ui/icons/Clear";
import firebase from "../../firebase";
Expand Down Expand Up @@ -37,7 +38,7 @@ const Header = props => {
if (data) {
const { displayName, profilePicture } = data;
setCurrentUser(prev => ({
...prev,
...prev,
name: displayName,
profilePicture,
}));
Expand Down Expand Up @@ -132,26 +133,10 @@ const Header = props => {
Twitch
</A>
</button>
<button type="submit">
<A
href={
readTerms
? `https://discord.com/api/oauth2/authorize?client_id=702929032601403482&redirect_uri=${process.env.REACT_APP_REDIRECT_URI}%2F%3Fdiscord%3Dtrue&response_type=code&scope=identify%20guilds`
: null
}
className="modal-button discord"
disabled={!readTerms}
>
<img
style={{ filter: "grayscale(1) brightness(10000%)" }}
src={`${process.env.PUBLIC_URL}/discord_logo.png`}
alt=""
width="20"
className="logo-icon"
/>
Discord
</A>
</button>
{/* <button disabled={!readTerms} type="submit" className="modal-button youtube" onClick={readTerms ? signInWithGoogle : () => {}}>
<YouTubeIcon className="logo-icon yt-icon" />
YouTube
</button> */}
<div className="legal">
<input
required
Expand Down Expand Up @@ -193,9 +178,7 @@ const Header = props => {
<Link to="/apps/download">Chat Manager</Link>
<Link to="/bot">Discord Bot</Link>
<Link to="/community">Community</Link>
<A href="https://www.patreon.com/disstreamchat?fan_landing=true" newTab>
Support Us
</A>
<A href="https://www.patreon.com/disstreamchat?fan_landing=true" newTab>Support Us</A>
{/* <Link to="/about">About</Link> */}
</nav>
</span>
Expand Down
5 changes: 1 addition & 4 deletions src/components/header/Header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
justify-content: center;
align-items: center;

& > button[type="submit"]{
& > button:first-child{
all: unset;
box-sizing: content-box !important;
width: 100%;
Expand Down Expand Up @@ -242,9 +242,6 @@
width: 70%;
flex: 1;
box-sizing: content-box !important;
&.discord{
background: #6f86d4;
}
cursor: pointer;
&:hover {
filter: brightness(0.85);
Expand Down