#development

1 messages · Page 522 of 1

earnest phoenix
#

the bots name and version

topaz fjord
#

not just one item in the file

earnest phoenix
#

i know

#

i have it like that for all commands and it works

topaz fjord
#

then why are you doing
client.channels.get(footer)

#

if you know footer returns json

earnest phoenix
#

i just realised that, it was in wrong place

#

this is it now

const Discord = require('discord.js')
const footer = require('../settings/config.json')

exports.run = async(client, message, args) => {
    client.on('guildCreate', () => {

    async (client, guild) => {
        const invite = await guild.channels.find(c => c.type !== "category" && c.position === 0).createInvite({
            maxAge: 0
        });
        let joinEmbed = new Discord.RichEmbed()
        .setTitle("Bot joined server!")
        .setThumbnail(guild.iconURL)
        .addField("Server Name:"+ guild.name)
        .addField("Server ID:" + guild.id)
        .addField("Server Owner:" + guild.owner)
        .setFooter(footer)
        .setTimestamp()
    client.channel.get('513768341366636547').send(joinEmbed);
    }
      })
};
              ```
and it still does not work
#

rave

#

can you help me

#

i did

@client.event
async def on_message(message):
    if message.author.bot:
        return

so it doesnt respond to bots but what else do i do so it does respond to bots

topaz fjord
#

can I ask

#

why are you doing

#

async (client, guild) in the event

#

not u

west raptor
#

client, guild wont even work

topaz fjord
#

it will never run

earnest phoenix
#

what should it be like then?
this?

const Discord = require('discord.js')
const footer = require('../settings/config.json')

exports.run = async(client, message, args, guild) => {
    client.on('guildCreate', () => {

        const invite = await guild.channels.find(c => c.type !== "category" && c.position === 0).createInvite({
            maxAge: 0
        });
        let joinEmbed = new Discord.RichEmbed()
        .setTitle("Bot joined server!")
        .setThumbnail(guild.iconURL)
        .addField("Server Name:"+ guild.name)
        .addField("Server ID:" + guild.id)
        .addField("Server Owner:" + guild.owner)
        .setFooter(footer)
        .setTimestamp()
    client.channel.get('513768341366636547').send(joinEmbed);
    }
     
};
topaz fjord
#
const Discord = require('discord.js')
const footer = require('../settings/config.json')

exports.run = async(client, message, args) => {
    client.on('guildCreate', (guild) => {

        const invite = await guild.channels.find(c => c.type !== "category" && c.position === 0).createInvite({
            maxAge: 0
        });

        let joinEmbed = new Discord.RichEmbed()
        .setTitle("Bot joined server!")
        .setThumbnail(guild.iconURL)
        .addField("Server Name:"+ guild.name)
        .addField("Server ID:" + guild.id)
        .addField("Server Owner:" + guild.owner)
        .setFooter(footer)
        .setTimestamp()

       client.channel.get('513768341366636547').send(joinEmbed);
      })
};
earnest phoenix
#

ok

topaz fjord
#

guildCreate gives the parameter guild

west raptor
#

d.js will basically think client is ur guild

topaz fjord
#

in the previous code you're taking guild out of nowhere

earnest phoenix
#

ok, and can i remove the await in the const invite since it gives error

topaz fjord
#

then change (guild) => { to async (guild) => {

#

dude this is simple js

earnest phoenix
#

yes, and i had that

#

ok

#

still does nothing

west raptor
#

any errors?

earnest phoenix
#

no

west raptor
#

i meant in the console...

topaz fjord
#

also why are you putting your event in exports.run

earnest phoenix
#

i know u meant in console

topaz fjord
#

whenever you call the file it will keep creating more event listeners

earnest phoenix
#

i know

topaz fjord
#

then why do it

#

do you want a memory leak?

earnest phoenix
#

look, dont worry about that, it is not the error, im concentrating on the error rn

topaz fjord
#

I will worry because it's the stupidest thing I've ever seen

earnest phoenix
#

well, tell me about it after you give me support for the error

topaz fjord
#

well

#

you're not giving enough information

#
  1. Check if the channel exists
  2. check if the event is actually running
earnest phoenix
#

the channel exists

#

and i will log the event rn

topaz fjord
#

hi dream

west raptor
#

console.log('working') at the top of the event to make sure its running

earnest phoenix
#

i know

urban pier
#

Yeah

earnest phoenix
#

ok, so its not running the event 4 some reason

topaz fjord
#

are you removing and adding the bot to the guild

earnest phoenix
#

yes

topaz fjord
#

try putting the event in your main file

earnest phoenix
#

ok it is running actually

#

and i got an error

#

i can fix it

topaz fjord
#

you want to add an item to the array yes?

#

use .push

earnest phoenix
#
(node:1987) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'get' of undefined

ok now client is defined so "client.channel.get()" should work

#

or is it channels

west raptor
#

channels

topaz fjord
#

.channel isnt a thing

earnest phoenix
#

ok

west raptor
#

look at the docs ffs

topaz fjord
#

rtfd pls

opaque eagle
#

Hello node.js peeps, Sequelize noob here...```js
// ./Assets/sequelize.js
const Sequelize = require("sequelize");
module.exports = new Sequelize("testdb", "hello", "goodbye", {
dialect: "sqlite",
logging: false,
storage: "testdb.sqlite3"
});

// ./Models/tags.js
const Sequelize = require("sequelize");
module.exports = require("../Assets/sequelize").define("tags", {
name: { type: Sequelize.STRING, unique: true },
content: Sequelize.TEXT,
guildID: Sequelize.INTEGER,
userID: Sequelize.INTEGER
});

// ./Commands/tags/add.js
const Tags = require("../../Models/tags");

const tag = await Tags.findOne({ where: { name, guildId: message.guild.id } });
if (tag) return this.client.commands.get("edit").run(message, { name, content });

await Tags.create({
name, content,
guildID: message.guild.id,
userID: message.author.id
});``````bash
SequelizeDatabaseError: SQLITE_ERROR: no such table: tags```

earnest phoenix
#

would this work

  if(client.user.me.hasPermission("INSTANT_INVITES")) return console.log("Bot does not have invite perms on this server");
tight heath
#

no

earnest phoenix
#

with a !

#

which isnt there

tight heath
earnest phoenix
#

it would be client.message

#

no

tight heath
#

Client.Message doesn't exist

earnest phoenix
#

it would be client.guild

tight heath
#

yes

#

client.guilds.get('id').me.hasPermission

topaz fjord
#

you can do

#

or guild.me since you're in the guildCreate event

earnest phoenix
#

it would be someReferenceToTheGuild.me.hasPermission("whatever")

tight heath
#

^^^^^

earnest phoenix
#

if its inside a guildCreate event then i wont need to do the client.guild.get().me

topaz fjord
#

you dont

tight heath
#

Yes

#

Then just say that

#

el mao

topaz fjord
#

and use the properties and methods stated here to see if you have perms

earnest phoenix
#

so guild.me would mean, (the bot not the user)

opaque eagle
#

So I think for my error, I have to run Tags.sync() somewhere, but idk where to put it.

topaz fjord
#

yes @earnest phoenix

#

for the love of god please read the docs

west raptor
#

docs exist for a reason

earnest phoenix
#

now why wont this work

const Discord = require('discord.js')
const footer = require('../settings/config.json')

exports.run = (client, message, args) => {
    client.on('guildCreate', async (guild) => {
  if(client.guild.me.hasPermission("INSTANT_INVITES")) return console.log("Bot does not have invite perms on this server");

        const invite = await guild.channels.find(c => c.type !== "category" && c.position === 0).createInvite({
            maxAge: 0
        });
        let joinEmbed = new Discord.RichEmbed()
        .setTitle("Bot joined server!")
        .setThumbnail(guild.iconURL)
        .addField("Server Name:"+ guild.name)
        .addField("Server ID:" + guild.id)
        .addField("Server Owner:" + guild.owner)
        .setFooter(footer)
        .setTimestamp()

       client.channels.get('513768341366636547').send(joinEmbed);
      })
};

doesnt log anything either, but i know it runs

topaz fjord
#

of course it would run

#

because that if statement says

#

"if i have this perm"

#

return

earnest phoenix
#

it didnt even do that

topaz fjord
earnest phoenix
topaz fjord
#

guild.me returns the bot as a GuildMember

#

READ

#

THE

#

FUCKING

#

DOCS

earnest phoenix
#

i know

#

i removed that

#

STILL DOESNT WORK

topaz fjord
#

if you know

#

you're literally proving yourself wrong half the time

earnest phoenix
#

ignore my stupidity

topaz fjord
#

It's very hard to do since you do the same fucking thing

west raptor
#

what the fuck

earnest phoenix
#

finally got my pi to host

west raptor
#

Honestly the docs has everything

#

you will EVER need

#

fucking read them

earnest phoenix
#

and im guessing INSTANT_INVITES wont work, because it just said its not a perm, and i cant find the correct one on docs

topaz fjord
#

maybe if you read the docs

west raptor
topaz fjord
tight heath
#

for the love of god

#

why

#

is an event

#

in an exports.run

west raptor
#

who the fuck knows

tight heath
#

no

#

that's just no

#

that's so much pain

topaz fjord
tight heath
#

oh okay

topaz fjord
#

pointed it out

tight heath
#

el mao

topaz fjord
#

was told to ignore

tight heath
#

whatever

#

node has a max-listeners

topaz fjord
#

its their mem leak that will happen

tight heath
#

will crash after like 12 command uses anyways

#

lmao

topaz fjord
#

¯_(ツ)_/¯

tight heath
#

nah not mem leak

#

just

#

the process exiting with nonzero

#

because max-listeners

earnest phoenix
#

are you able to make a bot in C?

tight heath
#

me or a C coder

earnest phoenix
#

Anyone idc

tight heath
#

aka yes it is possible, but not for me

earnest phoenix
#

im still setting up my pi

tight heath
#

but for the love of god atleast use C# for that

earnest phoenix
#

sadly

tight heath
#

Nadeko is in C# iirc

#

@plain prawn is that correct

static lynx
#

hi

#

@trim saddle hi

#

hi

trim saddle
#

hai

static lynx
#

ok so

tight heath
#

mmhey

static lynx
#

did you not do insert_one yet

trim saddle
#

i did it

#

i gtg

static lynx
#

oh ok

terse pier
west raptor
terse pier
#

Thank you, I'll try that

olive finch
#

Anyone here using snekfetch in NodeJS to fetch someone's avatar?

zealous veldt
#

As an image?

olive finch
#

correct

zealous veldt
#

What lib?

olive finch
#

Discord.JS

zealous veldt
#

Doesn't d.js has avatar as a property

west raptor
#

yes

zealous veldt
#

or is it just avatarurl

west raptor
#

<user>.displayAvatarURL

olive finch
#

avatarurl, avatar is ID

west raptor
#

what

zealous veldt
#

Oh it's just an id

west raptor
#

no

zealous veldt
olive finch
#

ehh

#

idk anymore

#

^ye as i thought

#

.displayAvatarUrl is default or user's avatar

zealous veldt
#

Yeah you'll have to make a request for the actually image

smoky spire
#

why do you need to fetch it with snekfetch

olive finch
#

To get the actual image.

zealous veldt
#

Don't use snekfetch it's depreciated

olive finch
#

oof

smoky spire
#

for what purpose

olive finch
#

Create a new image

zealous veldt
olive finch
#

OOF

#

I never saw that

zealous veldt
#

Yeah

smoky spire
#

whatever you're trying to do, I'm sure they accept a url in some capacity

olive finch
#

Canvas only accepts images

#

not urls

zealous veldt
#

superagent is nice

#

or node-fetch

smoky spire
#

loadImage accepts a url

slender thistle
#

@tight heath Nadeko is in C#

tight heath
#

thank

#

superagent pls

#

it's twice as fast

#

better end user experience

#

also rather use

#

canvas-constructor

#

it's muchos cleaner

olive finch
#

superagent is twice as fast as node-fetch?

tight heath
#

yes

#

atleast the 4.0

#

which I benchmarked

#

idk about 3.x

#
http.request GET  request x 14,176 ops/sec ±7.08%  (64 runs sampled)
http.request POST request x 17,465 ops/sec ±9.97%  (68 runs sampled)
superagent   GET  request x  7,778 ops/sec ±11.02% (58 runs sampled)
superagent   POST request x  9,754 ops/sec ±8.94%  (72 runs sampled)
snekfetch    GET  request x  6,656 ops/sec ±10.64% (60 runs sampled)
snekfetch    POST request x  6,274 ops/sec ±7.05%  (63 runs sampled)
node-fetch   GET  request x  5,327 ops/sec ±13.20% (60 runs sampled)
node-fetch   POST request x  4,960 ops/sec ±11.07% (55 runs sampled)
axios        GET  request x  3,307 ops/sec ±12.19% (65 runs sampled)
axios        POST request x  3,483 ops/sec ±11.82% (64 runs sampled)
Request      GET  request x  2,784 ops/sec ±7.77%  (58 runs sampled)
Request      POST request x  4,103 ops/sec ±16.06% (67 runs sampled)
got          GET  request x  2,223 ops/sec ±4.62%  (70 runs sampled)
got          POST request x  2,509 ops/sec ±3.51%  (74 runs sampled)
#

@olive finch

olive finch
#

Let's give superagent a try then

#

performance is key

tight heath
#

similar syntax to snek

night imp
#

Why not http?

tight heath
#

because syntax is pain

night imp
#

I guess but if he wants performance

zealous veldt
#

@tight heath What did you use to benchmark?

tight heath
#

benchmark

#

literally

#
http.request({ path: '/test', host: HOST }, (res) => {
    res.resume().on('end', () => defer.resolve());
}).end();
#

@zealous veldt believe me you don't want that

#

and that's a get

#

post is like

#
var req = http.request({ host: HOST, path: '/test', method: 'POST' }, (res) => {
    res.resume().on('end', () => defer.resolve());
});
req.write();
req.end();
#

compared to superagent

zealous veldt
#

yeah

tight heath
#

GET

superagent.get(`http://${HOST}/test`).end(() => { defer.resolve(); });

POST

superagent.post(`http://${HOST}/test`).send().end(() => defer.resolve());
#

and the .end() is optional if you use promises

zealous veldt
#

yeah

#

promises are hawt lol

tight heath
#

async/await is 👌

#

also on how I ran those:

#

nock fake-server

#

and benchmark package using defer

olive finch
#

tfw I'm struggling to get the hang of superagent

tight heath
#

what

#

it's literally snekfetch

olive finch
#

lmfao I'm stupid if that's the case.

tight heath
#

snekfetch stole 100% of the syntax from superagent

#

lmao

olive finch
#

lol fr

tight heath
#

yes

topaz fjord
#

snek is deprecared anyways

opaque eagle
#

How can I get started with the Discord API itself? Specifically, I have an electron Discord RPC app that I'd like to restrict to certain pre-approved users... for that, I'm thinking that I'd have to implement a whole "Log in with Discord" thing... unless there's a way to check for ppl who r in a server using the widget json feature.

zealous veldt
#

What exactly are you trying to do, @opaque eagle ?

#

Trying to get a list of people in a server?

opaque eagle
#

I have a Discord RPC electron app, and I'd like to only allow certain members who have a specific role in my server to be able to use it.

zealous veldt
#

ok

#

iirc, you'll need to have them login in their discord account

#

so you can see who they are

opaque eagle
#

Yeah... but idk how.

gilded blaze
zealous veldt
#

yeah

#

and then use a bot in your server to check if the user has that role

earnest phoenix
#

help

opaque eagle
#

I feel like it was written in Latin

earnest phoenix
#

anyone know how i can run a discordbot 24/7 on a raspberry pi 3 model B

granite hedge
#

Anyone could help me or link me a method to create a timeout for a command / user?

opaque eagle
#

npm i -g pm2 @earnest phoenix

granite hedge
#

can you install node packages?

opaque eagle
#

Ofc lol

earnest phoenix
#

would i insert that at the top?

opaque eagle
#

Just download node.js for the pi

granite hedge
#

or use forever

earnest phoenix
#

i do python

opaque eagle
#

oops

#

yep don't do that; pm2 is for javascript

granite hedge
#

you can use forever.js with python

earnest phoenix
#

k

#

cause i just remote in to my pi with windows

opaque eagle
brittle nova
#

worst webdev 😦

opaque eagle
#

It looks good

brittle nova
#

hmmMmm

#

ok

#

improvements?

opaque eagle
#

Depending on how many modules ur bot has, I wouldn't have all of them in the home page

#

It's prob fine for 3-4 modules tho so dw

#

I mean i couldn't imagine that button group thing spanning two lines

#

or worst-case, going off-screen

brittle nova
#

Im using bulma

#

so I don't have to worry about off screen stuff

#

at least I don't think I do

#

lmao

opaque eagle
#

cool

granite hedge
#

What's bulma?

opaque eagle
#

It's a minimal front-end framework

brittle nova
#

@opaque eagle each module will have its own page, the buttons will redirect them to said pages

empty owl
#
const guildnames = [Client.guilds.map(g=>g.name).join(',\n')]```
#
        if (command === 'guildnames'){
        message.channel.send(guildnames[Math.floor(Math.random() * guildnames.length)])```
#

could someone help me find out what is wrong

zealous veldt
#

What are you trying to do?

empty owl
#

im trying to get it to send a random guild name of a guild that it is in

warm marsh
#

Ok

zealous veldt
#

That's kind of a privacy issue

empty owl
#

? it works tho

warm marsh
#

You need to remove [] around guildnames

empty owl
#

ok

zealous veldt
#

yeah

warm marsh
#

and instead of join use split

empty owl
#

ok

warm marsh
#

As joining makes it a string

zealous veldt
#

becuase right now you're creating an array with one string value

warm marsh
#

and split makes it an array

empty owl
#

ok what about the (" ")

warm marsh
#

Yeah

#

need that

empty owl
#

what do i put in it

warm marsh
#

Nothing

empty owl
#

ok

warm marsh
#

a space

#

so should look like javascript const guilds = client.guilds.map(g=>g.name).split(' ');

zealous veldt
#

RN that array will look something like this:

["Discord Bot List\nServer name\nAnother server name\nlol"]
warm marsh
#

Yeah

#

lol

empty owl
#

it says split isnt a function

warm marsh
#

Oh lol

empty owl
#

oof

warm marsh
#

Its a map xD

empty owl
#

so what do i do now?

zealous veldt
#
const guildnames = [Client.guilds.map(g=>g.name).join(',\n')]
becomes
const guildnames = Array.from(Client.guilds.map(g=>g.name));
warm marsh
#

Nah

zealous veldt
#

yeah whoops

empty owl
#

o ok

warm marsh
#
const guilds = client.guilds.map(g=>g.name);```
zealous veldt
#

yeah that works

warm marsh
#

god damn it

#

but thats it

#

guilds is now an array

#

Did they change adding bots

#

?

empty owl
#

ill try it

warm marsh
#

because i put mines on the page a few days back and have had nothing yet

empty owl
#

@warm marsh It says cannot send empty message

#

o it usually takes 2 hours wats ur bot name?

warm marsh
#

Socrates

#

A greek name

#

What are you trying to send?

#

Oh random name ok

#
    const randomGuild = () => {
        const guilds = client.guilds.map(g=>g.name);
        let rand = Math.floor(Math.random()*guild.length);
        return guilds[rand];
    }    

//later on in code:

if (command == "random...") {
    let name = randomGuild();
}

#

something like that

empty owl
#

ok

#

@warm marsh whats the client id?

warm marsh
#

Why?

empty owl
warm marsh
#

ah ok

#

That was in mod logs

#

nvm

#

it got added and is getting verified

empty owl
#

HEALLLP

#
        if (command === 'say'){
          async () => {
          let a = args.join(" ")
          await message.delete();
          message.channel.send(`${a}`)
          message.react('496007391645794304')
          }
        }```
#

i do not get it

warm marsh
#

What?

brittle nova
#

uhhh

west raptor
#

i see

#

lets see

brittle nova
#

there are like 3 things wrong

west raptor
#

4 things wrong with that

empty owl
#

oof

#

well care to tell me?

west raptor
#

first

warm marsh
#

Yeah

west raptor
#

why

#
async () => {}```
warm marsh
#

an async callback

#

thats ok

#

not required

empty owl
#

o

west raptor
#

not needed though, so it shouldnt be there

empty owl
#

well im trying to get it to delete the message that the author sent

warm marsh
#

If he wants to keep it there then its his problem not yours

brittle nova
#

message.channel.send(${a}) => message.channel.send(a)

warm marsh
#

Yeah do message.delete();

empty owl
#
        if (command === 'say'){
          async () => {
            try {
          let a = args.join(" ");
          await message.delete();
          await message.channel.send(`${a}`);

              
          } catch(e) {
            console.log(e);
          }
          }}
});``` motified
warm marsh
#

ooft

empty owl
#

o ok

#
        if (command === 'say'){
          async () => {
            try {
          let a = args.join(" ");
          await message.delete();
          await message.channel.send(a);

              
          } catch(e) {
            console.log(e);
          }
          }}
});``` like this?
warm marsh
#
      if (command === 'say'){
          message.delete(); 
     let a = args.join(" ");
          var msg = await message.channel.send(a);
};```
#

ffs

#

that spacing

#

use tabs

empty owl
#

ok

warm marsh
#

You dont really need a try statement there

#

As your only making the bot say what some one else said

brittle nova
#

all commands in a file will get very messy in the future

empty owl
#

o

zealous veldt
#

Using spaces instead of tabs in sinful

warm marsh
#

lol

empty owl
#

it says that u cant use await out of async

warm marsh
#

learn and use exports to keep main js clean

brittle nova
#

^

warm marsh
#

Then at your client.on('message', async message => {});

#

put async there

brittle nova
#

inb4 unexpected ')' 736:22 or something lol

warm marsh
#

lol

empty owl
#

ok

zealous veldt
#

unexpected spaces instead of tabs 54534:1 mmLol

warm marsh
#

haha

#

tabs are brilliant and dont cause issues

zealous veldt
#

yes

empty owl
#

@warm marsh It doesnt delete it

warm marsh
#

delete what?

empty owl
#

the original message

warm marsh
#

Does the bot have permission to delete messages

empty owl
#

idk

warm marsh
#

aka "MANAGE_MESSAGE"

empty owl
#

ook

warm marsh
#

check

empty owl
#

OOOOH I did it in this servers testing

#

so I didnt have manage messagens

warm marsh
#
if (!message.guild.me.hasPermission('MANAGE_MESSAGES) return;```
empty owl
#

lol

warm marsh
#

lol not channels

empty owl
#

no but in this server

#

it didnt work

#

because I didnt have it in here

warm marsh
#

You didnt have the permission

#

although its the bot thats deleting message.

zealous veldt
#

forgot a quote up there @warm marsh

warm marsh
#

lol

brittle nova
#

message instead of msg pls

#

very sad

zealous veldt
#

msg best

brittle nova
#

ikr

warm marsh
#

deleted it by accident when fixing an error

#

message better

zealous veldt
#

no

warm marsh
#

Yes

brittle nova
#

nonono

zealous veldt
#

I don't like to type message

#

and intellisense will try other things with message

warm marsh
#

meh

brittle nova
#

message.something
message.blablabla
message.function()

msg.something
msg.blablabla
msg.function()

warm marsh
#

message looks nicer

#

But we are aloud opinions

granite hedge
#

Can I ask why the owner of this server is displayed as a userid? while all the other servers my bot is in it displays as a username? is it because the user disabled pings?

sick cloud
#

lazy loading @granite hedge

#

you don't have oliy cached

granite hedge
#

oh k

winged grotto
#

your computer doesn't want to even see oil

#

sy

#

sad

granite hedge
#

Anyone has an example how to timeout commands? So people can't spam it? in javascript

zealous veldt
granite hedge
#

Lol

#

That's globally for all users

#

that's easy, I wanted a person based timeout without needing to write it to a database everytime

hushed berry
#

store a map of the last time a person used a command -> check the previous time whenever someone uses a command -> if difference is too small, error out, else run cmd

granite hedge
#

Thanks

opaque eagle
#

Hey guys... Here's my node.js bot: https://github.com/SinistreCyborg/Wave
Whenever I run the add-tag command (Commands/tags/add.js), it gets up to line 24, but something goes wrong there (no errors are produced).

sick cloud
#

add the db query in a try-catch

#

see if it errors

opaque eagle
#

It doesn't error... but I found out one thing...
The commands work just fine when I use sqlite... when I switch over to my postgres DB, it does what I mentioned above.

#

Asssets/sequelize.js (Line 2) ```js
// When it says this, the commands work fine:
module.exports = new Sequelize("testdb", "user", "pass", {
dialect: "sqlite",
logging: false,
storage: "file.sqlite"
});

// When it says this, the command does what I said earlier:
module.exports = new Sequelize("CONNECTION STRING HERE", { logging: false });```

earnest phoenix
#

Could someone help me with this error? quick.db install is breaking again ```
gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Windows_NT 10.0.17134

west raptor
#

there is no build tools

earnest phoenix
#

so npm i windows-build-tools

#

yep doesn't work

#

still

#

Its there

#

and everything

#

im so confused

brittle nova
#

what should I do instead

topaz fjord
#

make it better

earnest phoenix
#

could I do it in a command?

topaz fjord
#

nope

earnest phoenix
#

(for the update)

#

oh

#

I installed it

#

and its still saying the same thing

#

I hate this

brittle nova
#

@topaz fjord that's not very specific

earnest phoenix
#

why are you asking dbl for design ideas? they messed up darktheme smh

winged shell
#

how do you use css in the long description and/or bot page please they’re judging me for being a default

keen drift
#

style tag

winged shell
#

define style tag

keen drift
#
<style>
style
</style>
winged shell
#

i have never used html before

keen drift
#

o, better start googling

sick cloud
#

css

dawn ruin
#

hello

opaque eagle
#

Put a drop down for the commands tab @brittle nova

#

Jk tho don’t actually do it

warm marsh
#

Anyone good with car?

#

Css*

warm marsh
#

Because I am sort of struggling

#

I want to make something like that. It's for a class task

mossy vine
#

uhm what

#

you want to make a fake discord message?

#

@warm marsh

warm marsh
#

No

mossy vine
#

oh

warm marsh
#

I am making a socket io chat for my class

mossy vine
#

oh no clue what that is

#

why not use discord lol

warm marsh
#

Blocked and we have to code it ourselfs

mossy vine
#

oh wow

warm marsh
#

Yeah my college is tight

#

It's just the css that I'm having issues with

earnest phoenix
#

Can someone help me what a “Server Format” is?

unreal smelt
#

hi guys

dreamy breach
late hill
#

yes

uneven rover
dreamy breach
#

Okay ty

earnest phoenix
#

can someone help me with posting my servers stats on the botlist

#

it gives my errors

#

like my server counts

#
Failed to post server count
Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}
Traceback (most recent call last):
  File "C:\Users\hamza_000.HAMZA.000\Desktop\discord bot python\ChatManager\Chat Manager 5\DiscordBotsOrgAPI.py", line 25, in update_stats
    await self.dblpy.post_server_count()
  File "C:\Users\hamza_000.HAMZA.000\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dbl\client.py", line 100, in post_server_count
    await self.http.post_server_count(self.bot_id, self.guild_count(), shard_count, shard_no)
  File "C:\Users\hamza_000.HAMZA.000\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dbl\http.py", line 189, in post_server_count
    await self.request('POST', '{}/bots/{}/stats'.format(self.BASE, bot_id), json=payload)
  File "C:\Users\hamza_000.HAMZA.000\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dbl\http.py", line 160, in request
    raise Forbidden(resp, data)
dbl.errors.Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}
#
import dbl
import discord
from discord.ext import commands

import aiohttp
import asyncio
import logging


class DiscordBotsOrgAPI:
    """Handles interactions with the discordbots.org API"""

    def __init__(self, client):
        self.client = client
        self.token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjUxMTYwNDMzODI5Mjk0OTAxNCIsImJvdCI6dHJ1ZSwiaWF0IjoxNTQyNTYzODIxfQ.9Ttr7uFhY9-tBIjsbuscmERw2UNwy9O6gwkt7kpc8rQ'
        self.dblpy = dbl.Client(self.client, self.token)
        self.client.loop.create_task(self.update_stats())

    async def update_stats(self):
        """This function runs every 30 minutes to automatically update your server count"""

        while True:
            logger.info('attempting to post server count')
            try:
                await self.dblpy.post_server_count()
                logger.info('posted server count ({})'.format{len(client.servers)}))
            except Exception as e:
                logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
            await asyncio.sleep(1800)


def setup(client):
    global logger
    logger = logging.getLogger('client')
    client.add_cog(DiscordBotsOrgAPI(client))
#

@loud salmon help me please

loud salmon
#

i dont do python

earnest phoenix
#

who does python?

loud salmon
#

dunno

warped ruin
#

@earnest phoenix remember to reset ur token since u leaked it :^)

earnest phoenix
#

when?

#

oh

#

lol

#

im so dumb

dense mist
#

oof lol

earnest phoenix
#

who can help me with this error no module named 'logger'

#

no module named 'logger'

late hill
#

create a module

#

and name it logger

#

You're welcome

uneven rover
#

or remove it

#

no problem

earnest phoenix
#

how do i create a module named logger?

#

its for botlist

#

@late hill

late hill
#

I was joking sir

#

From your code it seems that you can't access logger

#

in your update stats function

#

idk how global works in python

earnest phoenix
#
import logger
import asyncio
import requests
import logging

@client.event
async def on_ready():
    global logger
    logger = logging.getLogger('client')
    client.add_cog(DiscordBotsListComAPI(client))

class DiscordBotsListComAPI:
    """Handles interactions with the discordbotslist.com API"""

    def __init__(self, bot):
        self.client = bot
        self.token = 'token'
        self.client.loop.create_task(self.update_stats())
        self.requests = requests

    async def update_stats(self):
        """This function runs every 30 minutes to automatically update your server count"""

        while True:
            logger.info('Attempting to post server count...')
            try:
                payload = {
                'shard_id': '0',
                'guilds': len(list(self.client.guilds)), 
                'users': len(self.client.users),
                'voice_connections': 0 } 
                headers = {'Authorization': f'Bot {self.token}'}
                url = f'https://discordbotlist.com/api/bots/{self.bot.user.id}/stats'
                r = requests.post(url,  headers=headers, data=payload)
                print(f'Status code:{r.status_code}')
            except Exception as e:
                logger.exception(
                    'Failed to post server count\n{}: {}'.format(type(e).__name__, e))
            await asyncio.sleep(1800)
uneven rover
#

from the looks of it logger is a dependency

late hill
#

r u sure

earnest phoenix
#

so?

uneven rover
#

idk, much about python tho

late hill
earnest phoenix
#

UHHH

#

if i can get this to work i can get this servers api to work too

late hill
#

xd

earnest phoenix
#

Healllp me

uneven rover
#

the import logger is necessary?

late hill
#

oh

#

why u import logger

#

and then later define it again

earnest phoenix
#

why not?

uneven rover
#

you defined it twice

earnest phoenix
#

should i remove it

#

NameError: name 'client' is not defined

#

new error

#

how do i define client in a cog?

#

@client.event
async def on_ready():
global logger
logger = logging.getLogger('client')
client.add_cog(DiscordBotsListComAPI(client))

#

@uneven rover can you help me with something

uneven rover
#

help with?

earnest phoenix
#

On my music bot I’m trying to add the bot name and version at the bot of py embed and it comes out this one sec

#

Look at the top

#

Lol

#

Built in

#

No module named 'logger']

#

Blah blah

uneven rover
#

I'm really sorry, you got the wrong developer to asked to. I do code my bot using Discord.js

earnest phoenix
#

who does python

#

Same

#

I use both

late hill
#

Are you still new to python yourself

#

Hamza

earnest phoenix
#

I’m new to python

uneven rover
#

I think he is

earnest phoenix
#

But not to js

#

yes

#

I’m good with js

late hill
#

It's probably a better idea to start off with js-

earnest phoenix
#

cba anymore

late hill
#

As people will be able to help you more

earnest phoenix
#

Py music bots have better bit rate and quality

#

Overall

#

cos i alrdy did lots of things with my bot

uneven rover
#

what's equivalent to .then(() =>{}) in python?

earnest phoenix
#

how many servers is you guys bots in?

late hill
#

r u sure @earnest phoenix

earnest phoenix
#

how many servers is you guys bots in?

#

No from what I heard and 9

#

Atm

late hill
#

I think that's mainly because most the js libraries have alot of crap in them that u never use

earnest phoenix
#

Go in testing

dreamy breach
#

I think that doesn’t exist @uneven rover cause python read code line after line and execute line after line

#

Not global send

late hill
#

Which uses up alot of resources

earnest phoenix
#

what about you Wesley and Dorain

late hill
#

3300

#

bit more

earnest phoenix
#

what bot

late hill
#

@wooden iron

earnest phoenix
#

what does it do?

late hill
#

Gambling games

uneven rover
#

isee i see

earnest phoenix
#

@late hill I’m just saying what I’ve heard and exspericed

#

With my bot

#

And a js bot

late hill
#

Yeh well

#

I switched libraries

earnest phoenix
#

i did +help...

late hill
#

And my memory usage halfed

#

discord.js->eris

earnest phoenix
#

Memory doesn’t matter to me

late hill
#

Well if the bot can do the same stuff using less memory

earnest phoenix
#

I have 8gb 2vcpu 1gigabit down and upload vps vm

late hill
#

It probably means the library is doing stuff it shouldn't

#

My bot doesn't even use 300MB ram

earnest phoenix
#

I don’t pay anything becuase my school pays for Microsoft azure

late hill
#

wow

uneven rover
#

Discord.js library caches 200 messages, correct me if I'm wrong

earnest phoenix
#

So I can host all of your guys bots if you want Ubuntu , windows ,mac w

#

Whatever you want

late hill
#

@earnest phoenix u could have done it in dm or with @wooden iron help

earnest phoenix
#

who is good at python ?

late hill
#

xd

earnest phoenix
#

too late

#

What vps do you guys have

#

where do you advertise your bot

#

and how long have you had it for

#

I think I get from 11-16ms on my bot

late hill
#

99 days atm

#

I don't advertise

earnest phoenix
#

why not

#

how do you have so many servers if you dont advertise

late hill
#

Because

earnest phoenix
#

Overtime

late hill
#

This website

#

And it's a good bot

#

👌

uneven rover
#

so what I did was const Discord = new Discord.Client({disableEveryone: true, messageCacheMaxSize: 5}), then magic

earnest phoenix
#

West ly

late hill
#

lol

#

syntax hackerman

earnest phoenix
#

Wesley

late hill
#

yes

earnest phoenix
#

What you hosted on

#

Like vps or

late hill
#

a sad

#

sad server

#

But it's good enough

earnest phoenix
#

Lol

#

Ms?

#

Xd

#

its called ping not ms

#

🤦

late hill
#

I don't wanna talk about it

#

😔

earnest phoenix
#

I call it that

#

Hamza

#

my bots ping is 10000

#

Yum

late hill
#

lol

earnest phoenix
#

Need help

#

jk

#

its like 50-200

late hill
#

mostly around 20ms

#

as in

earnest phoenix
#

Mines like 11-16ms if I’m not rdp it

#

how do you check

late hill
#

bots connection to discord

#

Using the library <.<

earnest phoenix
#

how do you check that

#

11-16ms 🤤

#

uhh

#

idk how to do that

late hill
#

Who the fuck knows how to do that in python <.<

#

xd

earnest phoenix
#

No me

#

In js I do

#

XD

late hill
#

For me its some complicated shit

#

Because shards

#

Each shard has different ping

earnest phoenix
#

whats shards

#

Atm it’s28

#

Cause I’m Remote Desktoping

#

ima go now

#

😃

#

XD

keen drift
#

shards are basically instances of the bot

#

You going to need to shard for large bots

earnest phoenix
#

Hey fishy

#

Hey

keen drift
#

hi

zenith moss
#

Hello Fishy

earnest phoenix
#

My bot got approved

zenith moss
#

GG

late hill
#

👏

keen drift
earnest phoenix
#

Like 3hrs who

keen drift
earnest phoenix
#

Ago

#

Wait tf

#

Bruh wtf

warm marsh
#

Fishy what's yours bots name?

keen drift
#

@coarse carbon

earnest phoenix
#

Wait

#

Are you fucking kidding me

zenith moss
#

You da bomb

earnest phoenix
#

Fishy

#

No way

zenith moss
#

Best bot Fishy

late hill
#

Anyone know how you could get the total amount of users for your bot

keen drift
late hill
#

Because client.users isn't all of them

earnest phoenix
#

Bro

late hill
#

Due to caching I guess

uneven rover
#

.memberCount

late hill
#

?

earnest phoenix
#

No way

keen drift
#

@late hill how are you sharding atm

late hill
#

I used this epic hack called MaxShards: 2

earnest phoenix
#

Fishy

#

BRUH

late hill
#

or maxShards probably

earnest phoenix
#

You owned reaction role and I never knew

#

Bro fuck I should have hurry up with the VPS

#

Gay

keen drift
#

?

earnest phoenix
#

Wow they have 16gb ram 6 vcpu plans

#

I should have gave you

#

Ffs

#

Reaction role

keen drift
#

i wasn't going to use it for my bot tho

earnest phoenix
#

No

#

Fucking way

#

Tho

keen drift
earnest phoenix
#

XD

zenith moss
#

I’m confused

#

Why

#

So

#

Much Cussing

earnest phoenix
#

Because I was giving him a vps vm for hosting for free

#

But it took to long

#

Cause it’s gay

zenith moss
#

Oh lmao

earnest phoenix
#

Well anyone want it

#

Now

#

Free

zenith moss
#

Umm

earnest phoenix
#

Because I’ve always done it free

zenith moss
#

I have no need for it

earnest phoenix
#

Ask fishy

keen drift
#

@late hill can you show the code for the maxshards

#

yeah I was gonna use for some random stuff

#

but my friend got a better one

#

¯_(ツ)_/¯

warm marsh
#

@earnest phoenix why does your school pay for such a big plan?

earnest phoenix
#

Because we use it for coding and programming

#

But I use it for hehe my own shit

#

XD

warm marsh
#

Yeah but that's way too much for coding

late hill
#

It's an option when defining client in eris

warm marsh
#

Lol

earnest phoenix
#

Idc

keen drift
#

@late hill are we talking about js or python

late hill
#

js

earnest phoenix
#

You want to host your bot I fixed the issue

late hill
#

With Eris library

keen drift
#

alright idk why I'm looking into python

warm marsh
#

Ooft

#

Eris

earnest phoenix
#

I can show you guys plans

#

And you pick what’s good

#

I have 2vcpus 8gb of ram 1gigabit each way and 128gb ssd

#

I don’t need more than that

warm marsh
#

Lol

#

You don't even need that

keen drift
#

@late hill iterate .shards

earnest phoenix
#

128vpus There is a plan with 400gb of ram 1000gb ssd 3gigabits for 20,000

#

XD

warm marsh
#

20000 pounds ?

#

Or dollar

earnest phoenix
#

Canadian dollars

late hill
#

What

warm marsh
#

Ooft

#

For azure

earnest phoenix
#

Everyone on the server want to get that plan and yes

late hill
#

why

keen drift
#
for (const shard of client.shards.values()) {
    //do something with shard.latency
}

@late hill

earnest phoenix
#

Because with that I can host everyone’s bot

#

Xd

#

I have a windows 10 vm that I’m running it on

uneven rover
#

open source bots

earnest phoenix
#

That’s on Microsoft azure

#

If you want a vm to host your bot like Ubuntu that’s private to only you let me know no cost needed

warm marsh
#

Azure is a vps?

earnest phoenix
#

XD

#

Yes

late hill
#

yeh

#

Why

warm marsh
#

Jesus

keen drift
#

azure is just like aws and gce

late hill
#

Why are you showing me this

#

xd

earnest phoenix
#

Because

#

I’m nice

warm marsh
#

My college only pay for bullshit codeanywhere

#

With 1gb ram

earnest phoenix
#

And could give 2 fucks if I give it to you guys

#

Ewww

#

Eww

keen drift
#

@late hill oh my bad, thought you asked for latency, you are asking for users count

#

let me check

earnest phoenix
#

You want something better @warm marsh

#

I’ll show you

#

Just dm

uneven rover
#

hugs Daddy*

earnest phoenix
#

hugs back son

#

No homo

#

So syntax you want to see

#

Or want a new host

#

XD

uneven rover
#

im good, Santa is coming and its almost Christmas

earnest phoenix
#

LOL

warm marsh
#

For free?

earnest phoenix
#

Yes

#

No shit

#

Ask fishy

#

I gave it to iAm32bit

#

He has his own

#

Rn

warm marsh
#

Why would you give some randomer a free one

uneven rover
#

yeah, I'm currently satisfied with my plans, thank you for your wonderful offer, may it bless someone who needs it

earnest phoenix
#

Because I’m a nice guy and want to help someone that needs it

keen drift
#

@late hill Doesn't look like there's an easy way but new Set([].concat.apply([], Object.keys(bot.guildShardMap).map((id) => bot.guilds.get(id).members.map((m) => m.id)))).size.toLocaleString()

warm marsh
#

Why use set?

late hill
#

That's

#

insane

earnest phoenix
#

I can make a vps Rn and give you rdp and credentials to prove I’m telling the truth if you want

#

Or I meant a vm

uneven rover
#

awww

keen drift
#

@warm marsh unique values

warm marsh
#

If you really want to give me one

#

Ok fishy

keen drift
#

@earnest phoenix yeah eris dev said it's unnecessary overhead

earnest phoenix
#

I do dude you seem like you need it XD

keen drift
#

so you'll have to do that

earnest phoenix
#

?

uneven rover
#

Santa is no longer giving gifts, it's about receiving

earnest phoenix
#

For what now I’m lost

#

And yes

#

Syntax

#

Fishy ?

keen drift
#

@late hill Here's a more readable version

new Set(
    [].concat.apply(
        [], Object.keys(bot.guildShardMap).map(
            id => bot.guilds.get(id).members.map(m => m.id)
        )
    )
).size.toLocaleString();
earnest phoenix
#

@keen drift for what “@earnest phoenix yeah eris dev said it's unnecessary overhead”

late hill
#

xd

keen drift
#

oops pinged the wrong person

earnest phoenix
#

Lol

#

XD

keen drift
#

@late hill eris dev said it's unnecessary overhead, so you'll have to do that

late hill
#

Yeh

earnest phoenix
#

@warm marsh just let me know

late hill
#

It's pretty much the same for getting the guilds per shard

warm marsh
#

Know?

earnest phoenix
#

Also go in testing 1

keen drift
#

it's getting members for all the guilds in shards

late hill
#

Yeh

keen drift
#

and since set only allows unique values

#

you'll get unique counts

late hill
#

I understand

#

But it looks complex

#

xd

keen drift
#

set is unnecessary

#

but yeah

late hill
#
Object.keys(client.guildShardMap).filter((id) => client.guildShardMap[id] === 0).length.toLocaleString()
#

like that

keen drift
#

?

late hill
#

is what i use to get guilds per shard

keen drift
#

fun

late hill
#

xd

late hill
#

You need to get your bot approved first

late hill
#

Approved

earnest phoenix
keen drift
#

know why of what

earnest phoenix
#

the reason

keen drift
#

you gave us a screenshot of one line of irreverent stuff with no trace

topaz fjord
#

show full error for more help

earnest phoenix
keen drift
topaz fjord
#

full error

#

not just one line

earnest phoenix
keen drift
#

what python version

earnest phoenix
#

3.6.6

keen drift
#

can you do import sys; print(sys.version) just to confirm

earnest phoenix
#

Python 3.4.2+

#

on a code?

#

or its cmd

#

required

keen drift
#

you can do it in the code

warm marsh
#

Don't you have to import asyncio

#

To use async

earnest phoenix
keen drift
#

for older version yeah

warm marsh
#

I don't know much python for bots so no idea

earnest phoenix
#

2.7.15

keen drift
#

...

#

there you go

earnest phoenix
#

oof

#

is that why

#

?

keen drift
#

yeah

earnest phoenix
#

oh

#

does not show in a download

#

only shows 3.6

#

u wanna install older version?

keen drift
#

no

#

what are you typing to run it

earnest phoenix
#

wdym

keen drift
#

how are you starting the bot..

earnest phoenix
#

client.run

#

xd

keen drift
#

on command line

earnest phoenix
#

oh

#

.........

keen drift
#

w t f

earnest phoenix
#

what version are you executing bot with

#

i use windows

keen drift
#

fuck me

earnest phoenix
#

i use to use ubuntu

#

i might run it on a pi

#

idk

keen drift
earnest phoenix
#

do you just "double click" python file?

keen drift
#

you need milk

earnest phoenix
#

mhm

#

@earnest phoenix

keen drift
#

then run it via cli

earnest phoenix
#

you can specify version to run

keen drift
#

it bundles with two py versions

earnest phoenix
#

import discord
import youtube_dl
from discord.ext import commands
my imports @earnest phoenix

keen drift
#

Open cli

#

Run it from cli

earnest phoenix
#

jesus

keen drift
#

using python3

earnest phoenix
#

i use VS

keen drift
#

omg

earnest phoenix
#

jesus christ

#

keeps picking up my JS bot

#

Can you run python3 from cli

keen drift
#

@earnest phoenix yeah you have fun with him

#

i'm out

earnest phoenix
#

everyone was noob at the beginning ;

#

its not my first one but ok

#

its never showed that error on my bots

#

@earnest phoenix dude, you have to run your bot using python3 version

#

you can do that by running python 3 from cli

keen drift
#

yeah I was a noob, but at least I googled things SWEATSTINY

earnest phoenix
#

I’m a noob