satella
Advanced tools
Comparing version 1.4.1 to 1.4.2
@@ -218,3 +218,3 @@ import events from "events" | ||
export class Embed { | ||
export class Embed { | ||
title?: string | ||
@@ -229,2 +229,12 @@ description?: string | ||
image?: Image | ||
setTitle(string: string): Embed | ||
setDescription(string: string): Embed | ||
setUrl(url: string): Embed | ||
setTimestamp(Date?: string): Embed | ||
setColor(color: string | number): Embed | ||
setFooter(text: string, url: string): Embed | ||
addField(name: string, value: string, inline: boolean): Embed | ||
setThumbnail(url: string, options: ThumbnailOptions): Embed | ||
setImage(url: string, options: ImageOptions): Embed | ||
setAuthor(name: string, icon: string): Embed | ||
} | ||
@@ -231,0 +241,0 @@ |
{ | ||
"name": "satella", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"description": "Satella - A wrapper for the Discord API made in JS", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -17,12 +17,3 @@ /* eslint-disable no-undef-init */ | ||
if(!client.ws.ready) return; | ||
const guild = new Guild(client, payload.d); | ||
if(client.guilds.has(guild.id)){ | ||
client.guilds.remove(guild.id) | ||
client.guilds.set(guild.id, guild) | ||
}else{ | ||
client.guilds.set(guild.id, guild) | ||
client.emit("NewGuild", guild) | ||
} | ||
const { d } = payload; | ||
@@ -50,2 +41,11 @@ | ||
}); | ||
const guild = new Guild(client, payload.d); | ||
if(client.guilds.has(guild.id)){ | ||
client.guilds.remove(guild.id) | ||
client.guilds.set(guild.id, guild) | ||
}else{ | ||
client.guilds.set(guild.id, guild) | ||
client.emit("NewGuild", guild) | ||
} | ||
}; |
@@ -27,4 +27,6 @@ const DMChannel = require('../Structures/DMChannel'); | ||
}) | ||
} else if (channel.type != 1) { | ||
} else if (channel && channel.type != 1) { | ||
const message = new Message(client, payload.d) | ||
if(!message.channel) return; | ||
if(!message.channel.messages) return; | ||
message.channel.messages.set(payload.d.id, message); | ||
@@ -31,0 +33,0 @@ return client.emit('MessageSent', message); |
@@ -25,7 +25,2 @@ /* eslint-disable array-callback-return */ | ||
this.members = new Chest(Member); | ||
data.members.map(e => { | ||
this.members.set(e.user.id, new Member(client, data)) | ||
}) | ||
this.roles = new Chest(Role); | ||
@@ -35,2 +30,6 @@ data.roles.map(e => { | ||
}) | ||
this.members = new Chest(Member); | ||
data.members.map(e => { | ||
this.members.set(e.user.id, new Member(client, e)) | ||
}) | ||
this._client = client; | ||
@@ -46,2 +45,3 @@ | ||
}) | ||
} | ||
@@ -67,3 +67,3 @@ | ||
async kick(id){ | ||
async kick(id) { | ||
return new Promise((resolve, reject) => { | ||
@@ -83,3 +83,3 @@ const userAgent = `DiscordBot (https://github.com/bryzzen-kibador/Satella, ${require('../../package.json').version})`; | ||
}).then(res => { | ||
if(res.status !== 204) throw new Error("An error has happened!") | ||
if (res.status !== 204) throw new Error("An error has happened!") | ||
resolve(null) | ||
@@ -90,3 +90,3 @@ }) | ||
async ban(id, reason){ | ||
async ban(id, reason) { | ||
return new Promise((resolve, reject) => { | ||
@@ -100,5 +100,5 @@ const userAgent = `DiscordBot (https://github.com/bryzzen-kibador/Satella, ${require('../../package.json').version})`; | ||
method: "PUT", | ||
body: JSON.stringify({reason: reason || ""}), | ||
body: JSON.stringify({ reason: reason || "" }), | ||
headers: { | ||
"Authorization": "Bot "+this._client.token, | ||
"Authorization": "Bot " + this._client.token, | ||
"User-Agent": userAgent, | ||
@@ -108,3 +108,3 @@ 'Content-Type': 'application/json' | ||
}).then(res => { | ||
if(res.status !== 204) throw new Error("An error has happened!") | ||
if (res.status !== 204) throw new Error("An error has happened!") | ||
resolve(null) | ||
@@ -111,0 +111,0 @@ }) |
@@ -45,2 +45,3 @@ /* eslint-disable prefer-const */ | ||
constructor(client, data) { | ||
//console.log(data) | ||
this.nick = data.nick ? data.nick : data.user.username; | ||
@@ -47,0 +48,0 @@ this.id = data.user.id; |
@@ -16,7 +16,8 @@ /* eslint-disable padded-blocks */ | ||
this.subject = data.content; | ||
if(data.author && data.author.id !== client.user.id){ | ||
this.guild = client.guilds.get(data.guild_id) | ||
this.channel = client.channels.channels.get(data.channel_id) | ||
this.user = client.users.get(data.author.id) | ||
this.member = this.guild.members.get(data.author.id) | ||
if(data.author) this.user = data.author.id == client.user.id ? client.user : client.users.get(data.author.id) | ||
if(data.author) this.member = client.guilds.get(data.guild_id).members.get(data.author.id) | ||
} | ||
this.mentions = new Mentions(client, data); | ||
@@ -35,4 +36,3 @@ } | ||
data = JSON.stringify({ content: subject, tts: false, message_reference: { message_id: this.id, guild_id: this._data.guild_id } }); | ||
} else if (typeof subject == 'object') { | ||
subject = new Embed({subject}) | ||
}else if (typeof subject == 'object') { | ||
data = JSON.stringify({ embed: subject, tts: false, message_reference: { message_id: this.id, guild_id: this._data.guild_id } }); | ||
@@ -39,0 +39,0 @@ } |
51458
1431