This commit is contained in:
DjDeveloperr 2020-11-07 08:02:14 +05:30
parent 3a3af635c6
commit 7ead2c2ea6
7 changed files with 15 additions and 15 deletions

View file

@ -7,7 +7,7 @@ client.on("ready", () => {
});
client.on("messageCreate", (msg: Message) => {
if(msg.content === "!ping") {
if (msg.content === "!ping") {
console.log("Command Used: Ping");
msg.reply("pong!");
}
@ -16,23 +16,23 @@ client.on("messageCreate", (msg: Message) => {
console.log("discord.deno - ping example");
const token = prompt("Input Bot Token:");
if(!token) {
if (!token) {
console.log("No token provided");
Deno.exit();
}
const intents = prompt("Input Intents (0 = All, 1 = Presence, 2 = Server Members, 3 = None):");
if(!intents || !["0", "1", "2", "3"].includes(intents)) {
if (!intents || !["0", "1", "2", "3"].includes(intents)) {
console.log("No intents provided");
Deno.exit();
}
let ints;
if(intents == "0") {
if (intents == "0") {
ints = Intents.All;
} else if(intents == "1") {
} else if (intents == "1") {
ints = Intents.Presence;
} else if(intents == "2") {
} else if (intents == "2") {
ints = Intents.GuildMembers;
} else {
ints = Intents.None;

View file

@ -13,7 +13,7 @@ export const channelUpdate: GatewayEventHandler = async (
if (oldChannel !== undefined) {
await gateway.client.channels.set(d.id, d)
let guild: undefined | Guild;
if('guild_id' in d) {
if ('guild_id' in d) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
guild = await gateway.client.guilds.get((d as GuildChannelPayload).guild_id) as Guild | undefined
}

View file

@ -17,7 +17,7 @@ export const messageCreate: GatewayEventHandler = async (
const user = new User(gateway.client, d.author)
await gateway.client.users.set(d.author.id, d.author)
let guild
if(d.guild_id !== undefined) {
if (d.guild_id !== undefined) {
guild = await gateway.client.guilds.get(d.guild_id)
}
const mentions = new MessageMentions()

View file

@ -232,7 +232,7 @@ class Gateway {
}
}
if(this.client.bot === false) {
if (this.client.bot === false) {
// TODO: Complete Selfbot support
this.debug("Modify Identify Payload for Self-bot..")
// delete payload.d['intents']

View file

@ -182,7 +182,7 @@ export class RESTManager {
method: method.toUpperCase()
}
if(this.client.bot === false) {
if (this.client.bot === false) {
// This is a selfbot. Use requests similar to Discord Client
data.headers['authorization'] = this.client.token as string
data.headers['accept-language'] = 'en-US'
@ -252,7 +252,7 @@ export class RESTManager {
let urlToUse =
method === 'get' && query !== '' ? `${url}?${query}` : url
if(this.client.canary) {
if (this.client.canary) {
let split = urlToUse.split('//')
urlToUse = split[0] + '//canary.' + split[1]
}
@ -328,7 +328,7 @@ export class RESTManager {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.logErrors(response, errorStack)
if(status === HttpResponseCode.Unauthorized) throw new Error("Request was not successful. Invalid Token.")
if (status === HttpResponseCode.Unauthorized) throw new Error("Request was not successful. Invalid Token.")
switch (status) {
case HttpResponseCode.BadRequest:

View file

@ -88,7 +88,7 @@ export class Message extends Base {
this.flags = data.flags
this.channel = channel
// TODO: Cache in Gateway Event Code
// if(!noSave) this.client.messages.set(this.id, data)
// if (!noSave) this.client.messages.set(this.id, data)
}
protected readFromData (data: MessagePayload): void {

View file

@ -14,8 +14,8 @@ export const getBuildInfo = (client: Client) => {
let browser_version = '83.0'
let browser_user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 ' + browser + '/' + browser_version
// TODO: Use current OS properties, but also browser_user_agent accordingly
// if(Deno.build.os === 'darwin') os = 'MacOS'
// else if(Deno.build.os === 'linux') os = 'Ubuntu'
// if (Deno.build.os === 'darwin') os = 'MacOS'
// else if (Deno.build.os === 'linux') os = 'Ubuntu'
return {
os,