cleaning up code and ditching .owner
This commit is contained in:
@@ -45,7 +45,13 @@ class channel{
|
|||||||
this.lastmessageid=JSON.last_message_id;
|
this.lastmessageid=JSON.last_message_id;
|
||||||
}
|
}
|
||||||
isAdmin(){
|
isAdmin(){
|
||||||
return this.owner.isAdmin();
|
return this.guild.isAdmin();
|
||||||
|
}
|
||||||
|
get guild(){
|
||||||
|
return this.owner;
|
||||||
|
}
|
||||||
|
get localuser(){
|
||||||
|
return this.guild.localuser;
|
||||||
}
|
}
|
||||||
readStateInfo(json){
|
readStateInfo(json){
|
||||||
this.lastreadmessageid=json.last_message_id;
|
this.lastreadmessageid=json.last_message_id;
|
||||||
@@ -58,7 +64,7 @@ class channel{
|
|||||||
}
|
}
|
||||||
get canMessage(){
|
get canMessage(){
|
||||||
for(const thing of this.permission_overwrites){
|
for(const thing of this.permission_overwrites){
|
||||||
if(this.owner.hasRole(thing.id)&&thing.deny&(1<<11)){
|
if(this.guild.hasRole(thing.id)&&thing.deny&(1<<11)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,7 +94,7 @@ class channel{
|
|||||||
thing.parent_id=thing.move_id;
|
thing.parent_id=thing.move_id;
|
||||||
thisthing.parent_id=thing.parent_id;
|
thisthing.parent_id=thing.parent_id;
|
||||||
thing.move_id=undefined;
|
thing.move_id=undefined;
|
||||||
console.log(this.owner.channelids[thisthing.parent_id]);
|
console.log(this.guild.channelids[thisthing.parent_id]);
|
||||||
}
|
}
|
||||||
if(thisthing.position||thisthing.parent_id){
|
if(thisthing.position||thisthing.parent_id){
|
||||||
build.push(thisthing);
|
build.push(thisthing);
|
||||||
@@ -191,7 +197,7 @@ class channel{
|
|||||||
}
|
}
|
||||||
get myhtml(){
|
get myhtml(){
|
||||||
const search=document.getElementById("channels").children[0].children
|
const search=document.getElementById("channels").children[0].children
|
||||||
if(this.owner!==this.owner.owner.lookingguild){
|
if(this.guild!==this.localuser.lookingguild){
|
||||||
return null
|
return null
|
||||||
}else if(this.parrent){
|
}else if(this.parrent){
|
||||||
for(const thing of search){
|
for(const thing of search){
|
||||||
@@ -222,7 +228,7 @@ class channel{
|
|||||||
body:JSON.stringify({})
|
body:JSON.stringify({})
|
||||||
});
|
});
|
||||||
this.lastreadmessageid=this.lastmessageid;
|
this.lastreadmessageid=this.lastmessageid;
|
||||||
this.owner.unreads();
|
this.guild.unreads();
|
||||||
if(this.myhtml!==null){
|
if(this.myhtml!==null){
|
||||||
console.log(this.myhtml.classList)
|
console.log(this.myhtml.classList)
|
||||||
this.myhtml.classList.remove("cunread");
|
this.myhtml.classList.remove("cunread");
|
||||||
@@ -256,7 +262,7 @@ class channel{
|
|||||||
if(that.parrent){
|
if(that.parrent){
|
||||||
that.parrent.children.splice(that.parrent.children.indexOf(that),1);
|
that.parrent.children.splice(that.parrent.children.indexOf(that),1);
|
||||||
}else{
|
}else{
|
||||||
this.owner.headchannels.splice(this.owner.headchannels.indexOf(that),1);
|
this.guild.headchannels.splice(this.guild.headchannels.indexOf(that),1);
|
||||||
}
|
}
|
||||||
that.parrent=this.parrent;
|
that.parrent=this.parrent;
|
||||||
if(that.parrent){
|
if(that.parrent){
|
||||||
@@ -270,23 +276,23 @@ class channel{
|
|||||||
that.parrent.children=build;
|
that.parrent.children=build;
|
||||||
}else{
|
}else{
|
||||||
const build=[];
|
const build=[];
|
||||||
for(let i=0;i<this.owner.headchannels.length;i++){
|
for(let i=0;i<this.guild.headchannels.length;i++){
|
||||||
build.push(this.owner.headchannels[i])
|
build.push(this.guild.headchannels[i])
|
||||||
if(this.owner.headchannels[i]===this){
|
if(this.guild.headchannels[i]===this){
|
||||||
build.push(that);
|
build.push(that);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.owner.headchannels=build;
|
this.guild.headchannels=build;
|
||||||
}
|
}
|
||||||
div.after(channel.dragged[1]);
|
div.after(channel.dragged[1]);
|
||||||
}
|
}
|
||||||
this.owner.calculateReorder()
|
this.guild.calculateReorder()
|
||||||
});
|
});
|
||||||
|
|
||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
createChannel(name,type){
|
createChannel(name,type){
|
||||||
fetch(info.api.toString()+"/guilds/"+this.owner.id+"/channels",{
|
fetch(info.api.toString()+"/guilds/"+this.guild.id+"/channels",{
|
||||||
method:"Post",
|
method:"Post",
|
||||||
headers:this.headers,
|
headers:this.headers,
|
||||||
body:JSON.stringify({
|
body:JSON.stringify({
|
||||||
@@ -340,11 +346,11 @@ class channel{
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
getHTML(){
|
getHTML(){
|
||||||
if(this.owner!==this.owner.owner.lookingguild){
|
if(this.guild!==this.localuser.lookingguild){
|
||||||
this.owner.loadGuild();
|
this.guild.loadGuild();
|
||||||
}
|
}
|
||||||
this.owner.prevchannel=this;
|
this.guild.prevchannel=this;
|
||||||
this.owner.owner.channelfocus=this.id;
|
this.localuser.channelfocus=this;
|
||||||
this.putmessages();
|
this.putmessages();
|
||||||
history.pushState(null, null,"/channels/"+this.guild_id+"/"+this.id);
|
history.pushState(null, null,"/channels/"+this.guild_id+"/"+this.id);
|
||||||
document.getElementById("channelname").textContent="#"+this.name;
|
document.getElementById("channelname").textContent="#"+this.name;
|
||||||
@@ -457,7 +463,7 @@ class channel{
|
|||||||
get notification(){
|
get notification(){
|
||||||
let notinumber=this.message_notifications;
|
let notinumber=this.message_notifications;
|
||||||
if(+notinumber===3){notinumber=null;}
|
if(+notinumber===3){notinumber=null;}
|
||||||
notinumber??=this.owner.message_notifications;
|
notinumber??=this.guild.message_notifications;
|
||||||
switch(+notinumber){
|
switch(+notinumber){
|
||||||
case 0:
|
case 0:
|
||||||
return "all";
|
return "all";
|
||||||
@@ -469,10 +475,55 @@ class channel{
|
|||||||
return "default";
|
return "default";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
async sendMessage(content,{attatchmenets=[],embeds=[],replyingto=false}){
|
||||||
|
let replyjson=false;
|
||||||
|
if(replyingto){
|
||||||
|
replyjson=
|
||||||
|
{
|
||||||
|
"guild_id":replyingto.guild.id,
|
||||||
|
"channel_id": replyingto.channel.id,
|
||||||
|
"message_id": replyingto.id,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if(attatchmenets.length===0){
|
||||||
|
const body={
|
||||||
|
content:content,
|
||||||
|
nonce:Math.floor(Math.random()*1000000000)
|
||||||
|
};
|
||||||
|
if(replyjson){
|
||||||
|
body.message_reference=replyjson;
|
||||||
|
}
|
||||||
|
console.log(body)
|
||||||
|
return await fetch(info.api.toString()+"/channels/"+window.location.pathname.split("/")[3]+"/messages",{
|
||||||
|
method:"POST",
|
||||||
|
headers:this.headers,
|
||||||
|
body:JSON.stringify(body)
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
const formData = new FormData();
|
||||||
|
const body={
|
||||||
|
content:content,
|
||||||
|
nonce:Math.floor(Math.random()*1000000000),
|
||||||
|
}
|
||||||
|
if(replyjson){
|
||||||
|
body.message_reference=replyjson;
|
||||||
|
}
|
||||||
|
formData.append('payload_json', JSON.stringify(body));
|
||||||
|
for(const i in attatchmenets){
|
||||||
|
console.log(attatchmenets[i])
|
||||||
|
formData.append("files["+i+"]",attatchmenets[i]);
|
||||||
|
}
|
||||||
|
return await fetch(info.api.toString()+"/channels/"+window.location.pathname.split("/")[3]+"/messages", {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData,
|
||||||
|
headers:{"Authorization":this.headers.Authorization}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
messageCreate(messagep,focus){
|
messageCreate(messagep,focus){
|
||||||
const messagez=new cmessage(messagep.d,this);
|
const messagez=new cmessage(messagep.d,this);
|
||||||
this.lastmessageid=messagez.id;
|
this.lastmessageid=messagez.id;
|
||||||
if(messagez.author===this.owner.owner.user){
|
if(messagez.author===this.localuser.user){
|
||||||
this.lastreadmessageid=messagez.id;
|
this.lastreadmessageid=messagez.id;
|
||||||
if(this.myhtml){
|
if(this.myhtml){
|
||||||
this.myhtml.classList.remove("cunread");
|
this.myhtml.classList.remove("cunread");
|
||||||
@@ -482,31 +533,31 @@ class channel{
|
|||||||
this.myhtml.classList.add("cunread");
|
this.myhtml.classList.add("cunread");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.owner.unreads();
|
this.guild.unreads();
|
||||||
this.messages.unshift(messagez);
|
this.messages.unshift(messagez);
|
||||||
const scrolly=document.getElementById("messagecontainer");
|
const scrolly=document.getElementById("messagecontainer");
|
||||||
this.messageids[messagez.id]=messagez;
|
this.messageids[messagez.id]=messagez;
|
||||||
if(this.owner.owner.lookingguild.prevchannel===this){
|
if(this.localuser.lookingguild.prevchannel===this){
|
||||||
var shouldScroll=scrolly.scrollTop+scrolly.clientHeight>scrolly.scrollHeight-20;
|
var shouldScroll=scrolly.scrollTop+scrolly.clientHeight>scrolly.scrollHeight-20;
|
||||||
messages.appendChild(messagez.buildhtml(this.messages[1]));
|
messages.appendChild(messagez.buildhtml(this.messages[1]));
|
||||||
}
|
}
|
||||||
if(shouldScroll){
|
if(shouldScroll){
|
||||||
scrolly.scrollTop = scrolly.scrollHeight;
|
scrolly.scrollTop = scrolly.scrollHeight;
|
||||||
}
|
}
|
||||||
if(messagez.author===this.owner.owner.user){
|
if(messagez.author===this.localuser.user){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(this.owner.owner.lookingguild.prevchannel===this&&document.hasFocus()){
|
if(this.localuser.lookingguild.prevchannel===this&&document.hasFocus()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(this.notification==="all"){
|
if(this.notification==="all"){
|
||||||
this.notify(messagez);
|
this.notify(messagez);
|
||||||
}else if(this.notification==="mentions"&&messagez.mentionsuser(this.owner.owner.user)){
|
}else if(this.notification==="mentions"&&messagez.mentionsuser(this.localuser.user)){
|
||||||
this.notify(messagez);
|
this.notify(messagez);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
notititle(message){
|
notititle(message){
|
||||||
return message.author.username+" > "+this.owner.properties.name+" > "+this.name;
|
return message.author.username+" > "+this.guild.properties.name+" > "+this.name;
|
||||||
}
|
}
|
||||||
notify(message){
|
notify(message){
|
||||||
voice.noises(voice.getNotificationSound());
|
voice.noises(voice.getNotificationSound());
|
||||||
|
@@ -1,10 +1,11 @@
|
|||||||
class dirrect extends guild{
|
class dirrect extends guild{
|
||||||
constructor(JSON,owner){
|
constructor(JSON,owner){
|
||||||
super(-1);
|
super(-1);
|
||||||
|
this.message_notifications=0;
|
||||||
console.log(JSON);
|
console.log(JSON);
|
||||||
this.owner=owner;
|
this.owner=owner;
|
||||||
this.headers=this.owner.headers;
|
this.headers=this.localuser.headers;
|
||||||
if(!this.owner){
|
if(!this.localuser){
|
||||||
console.error("Owner was not included, please fix")
|
console.error("Owner was not included, please fix")
|
||||||
}
|
}
|
||||||
this.channels=[];
|
this.channels=[];
|
||||||
@@ -57,15 +58,15 @@ class group extends channel{
|
|||||||
constructor(JSON,owner){
|
constructor(JSON,owner){
|
||||||
super(-1);
|
super(-1);
|
||||||
this.owner=owner;
|
this.owner=owner;
|
||||||
this.headers=this.owner.headers;
|
this.headers=this.guild.headers;
|
||||||
this.messages=[];
|
this.messages=[];
|
||||||
this.name=JSON.recipients[0]?.username;
|
this.name=JSON.recipients[0]?.username;
|
||||||
if(JSON.recipients[0]){
|
if(JSON.recipients[0]){
|
||||||
this.user=new user(JSON.recipients[0]);
|
this.user=new user(JSON.recipients[0]);
|
||||||
}else{
|
}else{
|
||||||
this.user=this.owner.owner.user;
|
this.user=this.localuser.user;
|
||||||
}
|
}
|
||||||
this.name??=owner.owner.user.username;
|
this.name??=this.localuser.user.username;
|
||||||
this.id=JSON.id;
|
this.id=JSON.id;
|
||||||
this.parent_id=null;
|
this.parent_id=null;
|
||||||
this.parrent=null;
|
this.parrent=null;
|
||||||
@@ -91,8 +92,8 @@ class group extends channel{
|
|||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
getHTML(){
|
getHTML(){
|
||||||
this.owner.prevchannel=this;
|
this.guild.prevchannel=this;
|
||||||
this.owner.owner.channelfocus=this.id;
|
this.localuser.channelfocus=this;
|
||||||
this.putmessages();
|
this.putmessages();
|
||||||
history.pushState(null, null,"/channels/"+this.guild_id+"/"+this.id);
|
history.pushState(null, null,"/channels/"+this.guild_id+"/"+this.id);
|
||||||
document.getElementById("channelname").textContent="@"+this.name;
|
document.getElementById("channelname").textContent="@"+this.name;
|
||||||
@@ -100,13 +101,13 @@ class group extends channel{
|
|||||||
messageCreate(messagep,focus){
|
messageCreate(messagep,focus){
|
||||||
const messagez=new cmessage(messagep.d,this);
|
const messagez=new cmessage(messagep.d,this);
|
||||||
this.lastmessageid=messagez.id;
|
this.lastmessageid=messagez.id;
|
||||||
if(messagez.author===this.owner.owner.user){
|
if(messagez.author===this.localuser.user){
|
||||||
this.lastreadmessageid=messagez.id;
|
this.lastreadmessageid=messagez.id;
|
||||||
}
|
}
|
||||||
this.messages.unshift(messagez);
|
this.messages.unshift(messagez);
|
||||||
const scrolly=document.getElementById("messagecontainer");
|
const scrolly=document.getElementById("messagecontainer");
|
||||||
this.messageids[messagez.id]=messagez;
|
this.messageids[messagez.id]=messagez;
|
||||||
if(this.owner.owner.lookingguild.prevchannel===this){
|
if(this.localuser.lookingguild.prevchannel===this){
|
||||||
var shouldScroll=scrolly.scrollTop+scrolly.clientHeight>scrolly.scrollHeight-20;
|
var shouldScroll=scrolly.scrollTop+scrolly.clientHeight>scrolly.scrollHeight-20;
|
||||||
messages.appendChild(messagez.buildhtml(this.messages[1]));
|
messages.appendChild(messagez.buildhtml(this.messages[1]));
|
||||||
}
|
}
|
||||||
@@ -114,7 +115,7 @@ class group extends channel{
|
|||||||
scrolly.scrollTop = scrolly.scrollHeight;
|
scrolly.scrollTop = scrolly.scrollHeight;
|
||||||
}
|
}
|
||||||
console.log(document.getElementById("channels").children)
|
console.log(document.getElementById("channels").children)
|
||||||
if(this.owner.owner.lookingguild===this.owner){
|
if(this.localuser.lookingguild===this.guild){
|
||||||
const channellist=document.getElementById("channels").children[0]
|
const channellist=document.getElementById("channels").children[0]
|
||||||
for(const thing of channellist.children){
|
for(const thing of channellist.children){
|
||||||
if(thing.myinfo===this){
|
if(thing.myinfo===this){
|
||||||
@@ -126,15 +127,16 @@ class group extends channel{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.unreads();
|
this.unreads();
|
||||||
if(messagez.author===this.owner.owner.user){
|
if(messagez.author===this.localuser.user){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(this.owner.owner.lookingguild.prevchannel===this&&document.hasFocus()){
|
if(this.localuser.lookingguild.prevchannel===this&&document.hasFocus()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
console.log(this.notification);
|
||||||
if(this.notification==="all"){
|
if(this.notification==="all"){
|
||||||
this.notify(messagez);
|
this.notify(messagez);
|
||||||
}else if(this.notification==="mentions"&&messagez.mentionsuser(this.owner.owner.user)){
|
}else if(this.notification==="mentions"&&messagez.mentionsuser(this.localuser.user)){
|
||||||
this.notify(messagez);
|
this.notify(messagez);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -167,7 +169,7 @@ class group extends channel{
|
|||||||
div.append(buildpfp)
|
div.append(buildpfp)
|
||||||
sentdms.append(div);
|
sentdms.append(div);
|
||||||
div.onclick=function(){
|
div.onclick=function(){
|
||||||
this.all.owner.loadGuild();
|
this.all.guild.loadGuild();
|
||||||
this.all.getHTML();
|
this.all.getHTML();
|
||||||
}
|
}
|
||||||
}else if(current){
|
}else if(current){
|
||||||
|
@@ -46,7 +46,7 @@ class guild{
|
|||||||
this.owner=owner;
|
this.owner=owner;
|
||||||
this.headers=this.owner.headers;
|
this.headers=this.owner.headers;
|
||||||
if(!this.owner){
|
if(!this.owner){
|
||||||
console.error("Owner was not included, please fix")
|
console.error("localuser was not included, please fix")
|
||||||
}
|
}
|
||||||
this.channels=[];
|
this.channels=[];
|
||||||
this.channelids={};
|
this.channelids={};
|
||||||
@@ -196,8 +196,11 @@ class guild{
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
get localuser(){
|
||||||
|
return this.owner;
|
||||||
|
}
|
||||||
loadChannel(id){
|
loadChannel(id){
|
||||||
this.owner.channelfocus=id;
|
this.localuser.channelfocus=this.channelids[id];
|
||||||
this.channelids[id].getHTML();
|
this.channelids[id].getHTML();
|
||||||
}
|
}
|
||||||
sortchannels(){
|
sortchannels(){
|
||||||
@@ -210,7 +213,7 @@ class guild{
|
|||||||
const noti=document.createElement("div");
|
const noti=document.createElement("div");
|
||||||
noti.classList.add("unread");
|
noti.classList.add("unread");
|
||||||
divy.append(noti);
|
divy.append(noti);
|
||||||
this.owner.guildhtml[this.id]=divy;
|
this.localuser.guildhtml[this.id]=divy;
|
||||||
if(this.properties.icon!=null){
|
if(this.properties.icon!=null){
|
||||||
const img=document.createElement("img");
|
const img=document.createElement("img");
|
||||||
img.classList.add("pfp","servericon");
|
img.classList.add("pfp","servericon");
|
||||||
@@ -379,7 +382,7 @@ class guild{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
loadGuild(){
|
loadGuild(){
|
||||||
this.owner.loadGuild(this.id);
|
this.localuser.loadGuild(this.id);
|
||||||
}
|
}
|
||||||
updateChannel(JSON){
|
updateChannel(JSON){
|
||||||
this.channelids[JSON.id].updateChannel(JSON);
|
this.channelids[JSON.id].updateChannel(JSON);
|
||||||
|
@@ -248,82 +248,31 @@ typebox.addEventListener("keydown",event=>{
|
|||||||
});
|
});
|
||||||
console.log(typebox)
|
console.log(typebox)
|
||||||
typebox.onclick=console.log;
|
typebox.onclick=console.log;
|
||||||
|
|
||||||
async function enter(event){
|
async function enter(event){
|
||||||
thisuser.lookingguild.prevchannel.typingstart();
|
thisuser.channelfocus.typingstart();
|
||||||
if(event.key === "Enter"&&!event.shiftKey){
|
if(event.key === "Enter"&&!event.shiftKey){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if(editing){
|
if(editing){
|
||||||
fetch(info.api.toString()+"/channels/"+window.location.pathname.split("/")[3]+"/messages/"+editing,{
|
editing.edit(typebox.value);
|
||||||
method: "PATCH",
|
|
||||||
headers: thisuser.headers,
|
|
||||||
body:JSON.stringify({content:typebox.value})
|
|
||||||
|
|
||||||
})
|
|
||||||
typebox.value="";
|
|
||||||
editing=false;
|
editing=false;
|
||||||
}else{
|
}else{
|
||||||
let replyjson=false;
|
let replying=replyingto?.all;
|
||||||
if(replyingto){
|
if(replyingto){
|
||||||
replyjson=
|
|
||||||
{
|
|
||||||
"guild_id":replyingto.all.guild_id,
|
|
||||||
"channel_id": replyingto.all.channel_id,
|
|
||||||
"message_id": replyingto.all.id,
|
|
||||||
};
|
|
||||||
replyingto.classList.remove("replying");
|
replyingto.classList.remove("replying");
|
||||||
}
|
}
|
||||||
|
|
||||||
replyingto=false;
|
replyingto=false;
|
||||||
if(images.length==0){
|
thisuser.channelfocus.sendMessage(typebox.value,{
|
||||||
|
attatchmenets:images,
|
||||||
const body={
|
replyingto:replying,
|
||||||
content:typebox.value,
|
})
|
||||||
nonce:Math.floor(Math.random()*1000000000)
|
|
||||||
};
|
|
||||||
if(replyjson){
|
|
||||||
body.message_reference=replyjson;
|
|
||||||
}
|
}
|
||||||
console.log(body)
|
|
||||||
fetch(info.api.toString()+"/channels/"+window.location.pathname.split("/")[3]+"/messages",{
|
|
||||||
method:"POST",
|
|
||||||
headers:thisuser.headers,
|
|
||||||
body:JSON.stringify(body)
|
|
||||||
}).then(
|
|
||||||
function(out){
|
|
||||||
console.log(out,"here it is")
|
|
||||||
}
|
|
||||||
)
|
|
||||||
typebox.value="";
|
|
||||||
}else{
|
|
||||||
let formData = new FormData();
|
|
||||||
const body={
|
|
||||||
content:typebox.value,
|
|
||||||
nonce:Math.floor(Math.random()*1000000000),
|
|
||||||
}
|
|
||||||
if(replyjson){
|
|
||||||
body.message_reference=replyjson;
|
|
||||||
}
|
|
||||||
formData.append('payload_json', JSON.stringify(body));
|
|
||||||
for(i in images){
|
|
||||||
console.log(images[i])
|
|
||||||
formData.append("files["+i+"]",images[i]);
|
|
||||||
}
|
|
||||||
const data=formData.entries()
|
|
||||||
console.log(data.next(),data.next(),data.next())
|
|
||||||
console.log((await fetch(info.api.toString()+"/channels/"+window.location.pathname.split("/")[3]+"/messages", {
|
|
||||||
method: 'POST',
|
|
||||||
body: formData,
|
|
||||||
headers:{"Authorization":thisuser.token}
|
|
||||||
})));
|
|
||||||
//fetch("/sendimagemessage",{body:formData,method:"POST"})
|
|
||||||
|
|
||||||
while(images.length!=0){
|
while(images.length!=0){
|
||||||
images.pop()
|
images.pop();
|
||||||
pasteimage.removeChild(imageshtml.pop())
|
pasteimage.removeChild(imageshtml.pop());
|
||||||
}
|
}
|
||||||
typebox.value="";
|
typebox.value="";
|
||||||
}
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -238,7 +238,7 @@ class localuser{
|
|||||||
console.log(guild);
|
console.log(guild);
|
||||||
guild.loadChannel(location[5]);
|
guild.loadChannel(location[5]);
|
||||||
console.log(location[5])
|
console.log(location[5])
|
||||||
this.channelfocus=location[5];
|
this.channelfocus=guild.channelids[location[5]];
|
||||||
}
|
}
|
||||||
this.buildservers();
|
this.buildservers();
|
||||||
}
|
}
|
||||||
@@ -356,7 +356,7 @@ class localuser{
|
|||||||
}
|
}
|
||||||
messageCreate(messagep){
|
messageCreate(messagep){
|
||||||
messagep.d.guild_id??="@me";
|
messagep.d.guild_id??="@me";
|
||||||
this.guildids[messagep.d.guild_id].channelids[messagep.d.channel_id].messageCreate(messagep,this.channelfocus===messagep.d.channel_id);
|
this.guildids[messagep.d.guild_id].channelids[messagep.d.channel_id].messageCreate(messagep,this.channelfocus.id===messagep.d.channel_id);
|
||||||
this.unreads();
|
this.unreads();
|
||||||
}
|
}
|
||||||
unreads(){
|
unreads(){
|
||||||
@@ -367,7 +367,7 @@ class localuser{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
typeingStart(typing){
|
typeingStart(typing){
|
||||||
if(this.channelfocus===typing.d.channel_id){
|
if(this.channelfocus.id===typing.d.channel_id){
|
||||||
const memb=typing.d.member;
|
const memb=typing.d.member;
|
||||||
let name;
|
let name;
|
||||||
if(memb.id===this.user.id){
|
if(memb.id===this.user.id){
|
||||||
|
@@ -32,7 +32,7 @@ class cmessage{
|
|||||||
})
|
})
|
||||||
cmessage.contextmenu.addbutton("Edit",function(){
|
cmessage.contextmenu.addbutton("Edit",function(){
|
||||||
console.log(this)
|
console.log(this)
|
||||||
editing=this.id;
|
editing=this;
|
||||||
document.getElementById("typebox").value=this.content;
|
document.getElementById("typebox").value=this.content;
|
||||||
},null,_=>{return _.author.id==READY.d.user.id});
|
},null,_=>{return _.author.id==READY.d.user.id});
|
||||||
}
|
}
|
||||||
@@ -53,10 +53,19 @@ class cmessage{
|
|||||||
if(this.mentions.length||this.mention_roles.length){//currently mention_roles isn't implemented on the spacebar servers
|
if(this.mentions.length||this.mention_roles.length){//currently mention_roles isn't implemented on the spacebar servers
|
||||||
console.log(this.mentions,this.mention_roles)
|
console.log(this.mentions,this.mention_roles)
|
||||||
}
|
}
|
||||||
if(this.mentionsuser(this.owner.owner.owner.user)){
|
if(this.mentionsuser(this.localuser.user)){
|
||||||
console.log(this);
|
console.log(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
get channel(){
|
||||||
|
return this.owner;
|
||||||
|
}
|
||||||
|
get guild(){
|
||||||
|
return this.owner.guild;
|
||||||
|
}
|
||||||
|
get localuser(){
|
||||||
|
return this.owner.localuser;
|
||||||
|
}
|
||||||
messageevents(obj){
|
messageevents(obj){
|
||||||
cmessage.contextmenu.bind(obj,this)
|
cmessage.contextmenu.bind(obj,this)
|
||||||
obj.classList.add("messagediv")
|
obj.classList.add("messagediv")
|
||||||
@@ -77,6 +86,13 @@ class cmessage{
|
|||||||
}
|
}
|
||||||
return build;
|
return build;
|
||||||
}
|
}
|
||||||
|
async edit(content){
|
||||||
|
return await fetch(info.api.toString()+"/channels/"+window.location.pathname.split("/")[3]+"/messages/"+this.id,{
|
||||||
|
method: "PATCH",
|
||||||
|
headers: this.headers,
|
||||||
|
body:JSON.stringify({content:content})
|
||||||
|
});
|
||||||
|
}
|
||||||
buildhtml(premessage){
|
buildhtml(premessage){
|
||||||
//premessage??=messages.lastChild;
|
//premessage??=messages.lastChild;
|
||||||
const build = document.createElement('table');
|
const build = document.createElement('table');
|
||||||
|
Reference in New Issue
Block a user