worked on transcripts
diff --git a/Components/Transcripts/Embed.js b/Components/Transcripts/Embed.js
index b163da8..43b1ac4 100644
--- a/Components/Transcripts/Embed.js
+++ b/Components/Transcripts/Embed.js
@@ -14,9 +14,7 @@
const codeBlock = /(\`\`\`.+\`\`\`)/g;
const spoiler = /(\`\`\`.+\`\`\`)/g;
-const regex = /(\*\*\*.+\*\*\*|\*\*.+\*\*|\*.+\*|\_.+\_|\_\_.+\_\_|\~\~.+\~\~|\`.+\`|\`\`\`.+\`\`\`|\`\`\`.+\`\`\`|<a?:.+:\D+>|<@!?\d+>)/g;
-
-const converter = new Showdown.Converter();
+const regex = /(\*\*\*.+\*\*\*|\*\*.+\*\*|\*.+\*|\_.+\_|\_\_.+\_\_|\~\~.+\~\~|\`.+\`|\`\`\`.+\`\`\`|\`\`\`.+\`\`\`|<a?:.+:\D+>|<@!?\d+>|<#\d+>)/g;
async function parse(text) {
const splitText = text.split(regex);
@@ -38,7 +36,7 @@
return <Image key={index} src={`https://cdn.discord.com/emojis/${item.replaceAll(/\D/g, '')}`} width={20} height={20} alt="" />
}
if (item.match(user)) {
- const username = (await Axios.get(`http://localhost:10000/users/${item.replaceAll(/\D/g, '')}`)).data;
+ const username = (await Axios.get(`http://${process.env.NUCLEUS_CALLBACK}/users/${item.replaceAll(/\D/g, '')}`)).data;
console.log(username)
return <>{username}</>
@@ -56,16 +54,6 @@
description = description.split("\n");
}
- const [newDesc, setNewDesc] = useState([]);
-
- useEffect(() => {
- async function stuff() {
- const parsed = await parse(props.embed.description);
- setNewDesc(newDesc => [...newDesc, parsed]);
- }
- stuff();
- })
-
return (
<div className={Styles.embed} style={{borderColor: props.color ?? "#F27878"}}>
{
@@ -95,8 +83,8 @@
props.embed.description ?
<div className={Styles.embedDescription}>
{
- newDesc.map((item) => {
- return item;
+ description.map((item) => {
+ return <>{item}<br /></>;
})
}
</div>
diff --git a/pages/api/nucleus/verify/complete.js b/pages/api/nucleus/verify/complete.js
index cdffc2e..62802ba 100644
--- a/pages/api/nucleus/verify/complete.js
+++ b/pages/api/nucleus/verify/complete.js
@@ -11,7 +11,7 @@
return res.status(200).send({success: false})
}
try {
- await Axios.post(`${process.env.VERIFY_CALLBACK}/verify/${req.body.code}`, {
+ await Axios.post(`${process.env.NUCLEUS_CALLBACK}/verify/${req.body.code}`, {
secret: process.env.VERIFY_SECRET
});
} catch (e) {
diff --git a/pages/api/rsmv/validate.js b/pages/api/rsmv/validate.js
index e0c4de1..d968d50 100644
--- a/pages/api/rsmv/validate.js
+++ b/pages/api/rsmv/validate.js
@@ -2,7 +2,7 @@
const Validate = async (req, res) => {
try {
- var out = await Axios.get(`http://localhost:10000/verify/${req.body.code}`)
+ var out = await Axios.get(`http://${process.env.NUCLEUS_CALLBACK}/verify/${req.body.code}`)
out = out.data
let props = {
user: out.user,
diff --git "a/pages/nucleus/transcript/\133code\135/human.js" "b/pages/nucleus/transcript/\133code\135/human.js"
index d84a78f..18273ef 100644
--- "a/pages/nucleus/transcript/\133code\135/human.js"
+++ "b/pages/nucleus/transcript/\133code\135/human.js"
@@ -13,7 +13,7 @@
}
let code;
try {
- code = (await Axios.get(`http://localhost:10000/transcript/${ctx.params.code}`))
+ code = (await Axios.get(`http://${process.env.NUCLEUS_CALLBACK}/transcript/${ctx.params.code}`))
} catch (e) {
return {
redirect: {
@@ -24,7 +24,7 @@
}
return {
redirect: {
- destination: `http://api.coded.codes/nucleus/transcript/${ctx.params.code}/human`,
+ destination: `http://${process.env.NUCLEUS_CALLBACK}/transcript/${ctx.params.code}/human`,
permanent: true
}
}
diff --git "a/pages/nucleus/transcript/\133code\135/index.js" "b/pages/nucleus/transcript/\133code\135/index.js"
index 4b2389f..c5c4876 100644
--- "a/pages/nucleus/transcript/\133code\135/index.js"
+++ "b/pages/nucleus/transcript/\133code\135/index.js"
@@ -1,6 +1,96 @@
import Axios from 'axios';
import React from 'react';
import Message from '../../../../Components/Transcripts/Message';
+import _ from 'lodash';
+
+const emojiRegex = /(<a?:.+:\D+>)/g;
+const userRegex = /(<@!?\d+>)/g;
+const channelRegex = /(<#\d+>)/g;
+
+async function parseText(text) {
+ const dict = {
+ "emojis": {},
+ "users": {},
+ "channels": {}
+ }
+ const emojis = text.match(emojiRegex);
+ if (emojis) {
+ for (let i = 0; i < emojis.length; i++) {
+ const emoji = emojis[i];
+ const emojiID = emoji.replaceAll(/\D/g, '');
+ const emojiURL = `https://cdn.discord.com/emojis/${emojiID}`;
+ dict["emojis"][emoji] = emojiURL;
+ }
+ }
+ const users = text.match(userRegex);
+ if (users) {
+ for (let i = 0; i < users.length; i++) {
+ const user = users[i];
+ const userID = user.replaceAll(/\D/g, '');
+ const username = (await Axios.get(`http://${process.env.NUCLEUS_CALLBACK}/users/${userID}`)).data;
+ dict["users"][user.replaceAll(/<@|>/g, '')] = username;
+ }
+ }
+ const channels = text.match(channelRegex);
+ if (channels) {
+ for (let i = 0; i < channels.length; i++) {
+ const channel = channels[i];
+ const channelID = channel.replaceAll(/\D/g, '');
+ const channelName = (await Axios.get(`http://${process.env.NUCLEUS_CALLBACK}/channels/${channelID}`)).data;
+ dict["channels"][channel] = channelName;
+ }
+ }
+ // console.log("parseText", dict)
+ return dict
+}
+
+async function parse(json) {
+ let dict = {
+ "emojis": {},
+ "users": {},
+ "channels": {}
+ }
+
+ await _.forEach(json, async (message, index) => {
+ let thisMessage = {}
+ if(message.content) {
+ let parsed = await parseText(message.content)
+ // console.log(parsed)
+ _.assign(thisMessage, parsed)
+ }
+ if(message.embeds) {
+ _.forEach(message.embeds, async (embed, _index) => {
+ // console.log(embed)
+ if(embed.description) {
+ let parsed = await parseText(embed.description)
+ _.assign(thisMessage, parsed)
+ }
+ if(embed.title) {
+ let parsed = await parseText(embed.title)
+ _.assign(thisMessage, parsed)
+ }
+ if(embed.fields) {
+ _.forEach(embed.fields, async (field, _index) => {
+ if(field.name) {
+ let parsed = await parseText(field.name)
+ _.assign(thisMessage, parsed)
+ }
+ if(field.value) {
+ let parsed = await parseText(field.value)
+ _.assign(thisMessage, parsed)
+ }
+ })
+ }
+ })
+ }
+ // console.log(thisMessage)
+ _.assign(dict, thisMessage)
+ // console.log(index, dict)
+ })
+
+ // console.log("dict", dict)
+ return dict;
+}
function Index(props) {
return <div style={{overflowY: "scroll", overflowX: "hidden"}}>
@@ -14,7 +104,7 @@
paddingLeft: "25px",
color: "white",
fontSize: "1.5em",
- }}>Transcript for: {props.data.for.username}#{props.data.for.discriminator} | In {<a href={`https://discord.com/channels/${props.data.guild}/${props.data.channel}`}>ChannelName</a>} | Type: {props.data.type}</div>
+ }}>Transcript for: {props.data.for.username}#{props.data.for.discriminator} | In #{<a href={`https://discord.com/channels/${props.data.guild}/${props.data.channel}`}>{props.channelName}</a>} | Type: {props.data.type}</div>
<div style={{
width: "100vw",
backgroundColor: "var(--theme-ui-colors-background)", //Can we change this to be not black please. it's too contrast heavy
@@ -42,20 +132,32 @@
}
}
}
- let code;
- try {
- code = (await Axios.get(`http://localhost:10000/transcript/${ctx.params.code}`))
- } catch (e) {
- return {
- redirect: {
- destination: '/nucleus/transcript/invalid',
- permanent: true
- }
- }
- }
return {
- props: {
- data: code.data
+ redirect: {
+ destination: `/nucleus/transcript/${ctx.params.code}/human`,
+ permanent: true
}
}
+ // let code;
+ // try {
+ // code = (await Axios.get(`http://${process.env.NUCLEUS_CALLBACK}/transcript/${ctx.params.code}`))
+ // } catch (e) {
+ // return {
+ // redirect: {
+ // destination: '/nucleus/transcript/invalid',
+ // permanent: true
+ // }
+ // }
+ // }
+ // const linkedData = await parse(code.data.messages)
+
+ // const channelName = (await Axios.get(`http://${process.env.NUCLEUS_CALLBACK}/channels/${code.data.channel}`)).data;
+
+ // return {
+ // props: {
+ // data: code.data,
+ // linkedData,
+ // channelName
+ // }
+ // }
}
\ No newline at end of file
diff --git "a/pages/nucleus/transcript/\133code\135/raw.js" "b/pages/nucleus/transcript/\133code\135/raw.js"
index 8c5436e..da6ac40 100644
--- "a/pages/nucleus/transcript/\133code\135/raw.js"
+++ "b/pages/nucleus/transcript/\133code\135/raw.js"
@@ -14,7 +14,7 @@
}
let code;
try {
- code = (await Axios.get(`http://localhost:10000/transcript/${ctx.params.code}`))
+ code = (await Axios.get(`http://${process.env.NUCLEUS_CALLBACK}/transcript/${ctx.params.code}`))
} catch (e) {
return {
redirect: {
@@ -25,7 +25,7 @@
}
return {
redirect: {
- destination: `http://localhost:10000/transcript/${ctx.params.code}`,
+ destination: `http://${process.env.NUCLEUS_CALLBACK}/transcript/${ctx.params.code}`,
permanent: true
}
}
diff --git a/pages/nucleus/verify/index.js b/pages/nucleus/verify/index.js
index 05a9dec..9c84b84 100644
--- a/pages/nucleus/verify/index.js
+++ b/pages/nucleus/verify/index.js
@@ -87,7 +87,7 @@
}
let code;
try {
- code = await Axios.get(`http://localhost:10000/verify/${ctx.query.code}`);
+ code = await Axios.get(`http://${process.env.NUCLEUS_CALLBACK}/verify/${ctx.query.code}`);
} catch (e) {
return {
redirect: {
diff --git a/todo/rolemenu/index.js b/todo/rolemenu/index.js
index a057f9f..ca7e493 100644
--- a/todo/rolemenu/index.js
+++ b/todo/rolemenu/index.js
@@ -60,7 +60,7 @@
<Text>{item.description}</Text>
<div className={Styles.options}>
{
- item.options.map((props, optionIndex) => {return <div className={Styles.optionBox}>
+ item.options.map((props, optionIndex) => {return <div key={optionIndex} className={Styles.optionBox}>
<input
type={item.max === 1 ? "radio" : "checkbox"}
style={{borderRadius: item.max === 1 ? "50%" : "5px"}}
@@ -107,7 +107,7 @@
}
let code;
try {
- code = (await Axios.get(`http://localhost:10000/rolemenu/${ctx.query.code}`)).data;
+ code = (await Axios.get(`http://${process.env.NUCLEUS_CALLBACK}/rolemenu/${ctx.query.code}`)).data;
} catch (e) {
return {
redirect: {