#development

1 messages ยท Page 382 of 1

clear hill
#

wait GTG

trim plinth
#

oOf

frail harness
#

oof

clear hill
#

done

#

HELP Me

trim plinth
#

what do you need help with

clear hill
#

dblapi!

trim plinth
#

do you have shards or not, if no, take out the shards posting and it should be good

earnest phoenix
#
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your discordbots.org token');

client.on('ready', () => {
    setInterval(() => {
        dbl.postStats(client.guilds.size);
    }, 1800000);
});
clear hill
#

no

earnest phoenix
#

Make it look like that

#

That is also for a discord.js bot

clear hill
#

cant

trim plinth
#

why not

clear hill
#

Nothing Happend When I Node .

trim plinth
#

you don't do node ., you do node ___.js bloblul

clear hill
#

caant too

trim plinth
clear hill
#

๐Ÿ˜ข

trim plinth
#

wdym

#

by "caan't too"

clear hill
#

pls

trim plinth
clear hill
#

NDIwOTIwNzQ5MzE0ODAxNjg0.DYG0qp-qrk

earnest phoenix
#

?

zealous tangle
#

whose bot ?

#

:p

trim plinth
#

if thats a token then I suggest taking that out of there

zealous tangle
#

too late for that

#

lol

earnest phoenix
#

It's not

#

not all of it, at least

trim plinth
#

wait no its not

#

yeah it doesn't have all parts of it

clear hill
#
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL(``, client);

client.on('ready', () => {
    setInterval(() => {
        dbl.postStats(client.guilds.size);
    }, 1800000);
});

client.login("")```
#

??

trim plinth
#

only has one period so I'm guessing its either the 1st part of a token or the 1st and 2nd part

earnest phoenix
#

Yes. client.login("your discord token")

#

Anyways, if you dont know how to code, you should learn that

#

instead of coming and expecting to be spoonfed

clear hill
#

dbl.postStats(client.guilds.size);??

trim plinth
#

oml

clear hill
#

?

trim plinth
#

did you install the node module

clear hill
#

ye

#

dbl.postStats(client.guilds.size); Whaat This Function/

earnest phoenix
trim plinth
earnest phoenix
#

You see, we have docs and very well-documented lib code on Github

clear hill
#

๐Ÿ˜ข

earnest phoenix
#

If you want to know what the function is, just look on Github

clear hill
#

no

#

xD

earnest phoenix
#

if you want to know how to use it in a more conventional manner, then read the docs

clear hill
#

k

earnest phoenix
#

If you think there truly is a bug with the lib, however, it's best to go to #topgg-api

trim plinth
earnest phoenix
#

but only if you really think it's a bug, which it's 99% surely not

clear hill
#

oh

#

oh kk

#

post stats On DBL

#

๐Ÿ˜ฆ

trim plinth
#

check docs before asking anymore questions about the library

clear hill
#

Hey

clear hill
#

``: treating /ping from #testing-1 as command

: State changed from up to crashed

: Process exited with status 1``

#

WHY?

surreal peak
#
public ProtocolType ProtocolType {
            get {
                return protocolType;
            }
        }
#

oops

#

Erlite - Today at 10:17 AM
because your code has a flaw
good luck finding it
#

there

clear hill
#

when my bot muted i send /ping:
State changed from up to crashed Process exited with status 1

trim plinth
#

that means you have an issue in your code

#

so show your code

clear hill
#

bot.on('message', function (msg) { if (msg.content.startsWith( config.prefix + 'ping')) { msg.channel.send(" pong!");

trim plinth
#

if your bot is muted, it most likely doesn't have permissions to speak in the channel so you can't fix that unless it is unmuted

#

so that is probably the error

clear hill
#

and how to bot auto restart?

trim plinth
#

thats your own can of worms to do mmLol

clear hill
#

?

clear hill
#

๐Ÿ˜ฆ

solemn obsidian
#

Also may want to look into error handling + what is catch

clear hill
#

fuc

bright karma
#

yea with this

const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL(``, client);

client.on('ready', () => {
    setInterval(() => {
        dbl.postStats(client.guilds.size);
    }, 1800000);
});

client.login("")

I have moved it out of my ready listener because everytime the stats got posted it would create another ready listener event, to reduce it I had to remove it out of any listeners and changed the setTimeout to client.setTimeout just letting y'all know that't how I fixed my possible memory leak warning with my ready listener

trim plinth
#

if you do const dbl = new DBL('token', client), you don't need to do the stats post inside the ready event I'm pretty sure

bright karma
#

I don't use ^ that either, I just have 1 variables to let the bot know when it is finished logging in and ready to execute the rest of the listeners

trim plinth
heady zinc
#

not sure why would that create another ready listener ZoomEyes

trim plinth
#

ยฏ_(ใƒ„)_/ยฏ

bright karma
#

Idk I went through my listeners and from the array key #1 was the ready listener and key 2-42 was the stats event

#

when I moved it out of the ready listener it bumped down to 2 events the stats and the ready event

heady zinc
#

stats event?

bright karma
#

the one that posts the stats to the DBL site
setInterval(() => { dbl.postStats(client.guilds.size); }, 1800000);
this one

trim plinth
#

ok so you use the Interval

heady zinc
#

that's an interval not an event ZoomEyes

bright karma
#

you know what I mean, anyways it was listed 41 times under the bot's Ready Event in client.actions._events when I used my eval command to see why I had so many ready events

heady zinc
#

inb4 you did js setInterval(() => { client.on('ready', () => { dbl.postStats(client.guilds.size); }); }, 1800000);

trim plinth
bright karma
#

no I would never do that I am not that much of a noob with making a bot to do something like that

trim plinth
#

well you must've did something wrong because the interval done correctly shouldn't create more ready events

bright karma
#

it might have been something else in my ready listener but it's fixed after I moved it out, and this is before I fixed it.

trim plinth
#

wait why are you posting stats outside of the interval GWczeWhat

bright karma
#

that snippet is how it looked in the ready event it isn't how I put it in my script.

trim plinth
#

@bright karma uhh yeah you posted stats outside of the interval

#

I doubt that was the issue though

clear hill
#
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL(`Token`, client);

client.on('ready', () => {
    setInterval(() => {
        dbl.postStats(client.guilds.size);
    }, 1800000);
});

client.login("Token!")```?
#

How To Host Bot?

languid dragon
uncut slate
#

rude

clear hill
#

LoL

raw wharf
#

@languid dragon I have a question, how can I know if my bot has committed an infraction or an error due to not being able to enter the server? I tried to see the channel #mod-logs and I did not find anything about my bot. Thank you

languid dragon
#

did u search the bots id in the channel

raw wharf
#

look with the id and there is no mistake or something like in kick or mute

clear hill
#

lol

raw wharf
#

;-;

glossy saddle
#

node.js

prisma radish
#

hm

glossy saddle
#

who can help me in node.js

prisma radish
#

me

#

im god of node js

glossy saddle
#

but

#

i am start

prisma radish
#

ye

glossy saddle
#

I started learning programming just a few weeks ago

#

@prisma radish

#

ho kik

#

lol

prisma radish
#

uh

#

ye

#

so what

glossy saddle
#

I'm pretty hard to learn

prisma radish
#

yea

#

so?

glossy saddle
#

you can?

#

who can help me in node.js

earnest phoenix
#

wat u mean?

glossy saddle
#

?

#

what do not you understand

glossy saddle
#

who can help me in node.js

glossy saddle
#

who can help me in node.js

old glade
#

@glossy saddle Someone will answer no need to spam

glossy saddle
#

but

old glade
#

?

glossy saddle
#

bamba?

old glade
#

tf you talking about ?

glossy saddle
#

wait

#

where you from

old glade
#

lol ?

glossy saddle
#

where

#

say

old glade
#

Can you speak english ?

glossy saddle
#

so so

#

Which country do you live in

old glade
#

I don't think so l8

glossy saddle
#

oof

old glade
#

well anyway stop spam this channel now

onyx pebble
#
if(args[0] == null) {
            event.getTextChannel().sendMessage("-fancytext <Text>").queue();;
        }else{
            int i = args.length;
            String text = "";
            for(String i2 = args[i]; i2 != null;) {
                i--;
                if(i == 0) {
                    i2 = null;
                }
                text = text + i2 + " ";
                
            }
            text.replace("a", "๐”ธ");
            text.replace("b", "๐”น");
            text.replace("c", "โ„‚");
            text.replace("d", "๐”ป");
            text.replace("e", "๐”ผ");
            text.replace("f", "๐”ฝ");
            text.replace("g", "๐”พ");
            text.replace("h", "โ„");
            text.replace("i", "๐•€");
            text.replace("j", "๐•");
            text.replace("k", "๐•‚");
            text.replace("l", "๐•ƒ");
            text.replace("m", "๐•„");
            text.replace("n", "โ„•");
            text.replace("o", "๐•†");
            text.replace("p", "โ„™");
            text.replace("q", "โ„š");
            text.replace("r", "โ„");
            text.replace("s", "๐•Š");
            text.replace("t", "๐•‹");
            text.replace("u", "๐•Œ");
            text.replace("v", "๐•");
            text.replace("w", "๐•Ž");
            text.replace("x", "๐•");
            text.replace("y", "๐•");
            text.replace("z", "โ„ค");
            event.getTextChannel().sendMessage("text").queue();;
#

where is the error?

hushed oyster
#

I am not familiar with whatever language that is, but I am sure that there is a much simpler way to make every letter uppercase

onyx pebble
#

i dont make it uppercase

hushed oyster
#

oh

onyx pebble
#

it make it fancy

hushed oyster
#

nevermind

earnest phoenix
#

xD

onyx pebble
#

๐”ธ๐”นโ„‚๐”ป๐”ผ๐”ฝ๐”พโ„๐•€๐•๐•‚๐•ƒ๐•„โ„•๐•†โ„™โ„šโ„๐•Š๐•‹๐•Œ๐•๐•Ž๐•๐•โ„ค

earnest phoenix
#

what even is the error?

muted oxide
#

does this make sense :

Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_hackrun/iiec_hackrun.py", line 29, in <module>                start(fakepyfile,mainpyfile)                              File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_hackrun/iiec_hackrun.py", line 28, in start                   exec(open(mainpyfile).read(),  __main__.__dict__)         File "<string>", line 95                                      @bot.command()                                              ^                                                       IndentationError: unexpected unindent                       [Program finished]

it straight up makes zero sense because there is no reason there is something wrong, first, the indents are correct, and second, everything is written fine.

#

I lost my laptop

onyx pebble
#
[JDA MainWS-ReadThread] ERROR net.dv8tion.jda.core.JDA - One of the EventListeners had an uncaught exception
java.lang.ArrayIndexOutOfBoundsException: 3
    at Commands.cmdfancytext.action(cmdfancytext.java:26)
    at Core.commandHandler.handleCommand(commandHandler.java:23)
    at Listener.CommandListener.onMessageReceived(CommandListener.java:19)
    at net.dv8tion.jda.core.hooks.ListenerAdapter.onEvent(ListenerAdapter.java:406)
    at net.dv8tion.jda.core.hooks.InterfacedEventManager.handle(InterfacedEventManager.java:84)
    at net.dv8tion.jda.core.handle.MessageCreateHandler.handleInternally(MessageCreateHandler.java:122)
    at net.dv8tion.jda.core.handle.SocketHandler.handle(SocketHandler.java:37)
    at net.dv8tion.jda.core.requests.WebSocketClient.handleEvent(WebSocketClient.java:990)
    at net.dv8tion.jda.core.requests.WebSocketClient.onTextMessage(WebSocketClient.java:664)
    at net.dv8tion.jda.core.requests.WebSocketClient.onBinaryMessage(WebSocketClient.java:1038)
    at com.neovisionaries.ws.client.ListenerManager.callOnBinaryMessage(ListenerManager.java:368)
    at com.neovisionaries.ws.client.ReadingThread.callOnBinaryMessage(ReadingThread.java:270)
    at com.neovisionaries.ws.client.ReadingThread.handleBinaryFrame(ReadingThread.java:990)
    at com.neovisionaries.ws.client.ReadingThread.handleFrame(ReadingThread.java:749)
    at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:108)
    at com.neovisionaries.ws.client.ReadingThread.runMain(ReadingThread.java:64)
    at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45)
#

@earnest phoenix

earnest phoenix
#

yeh i can read

#

no need to ping

#

discord.jda

#

line 26 i think?

onyx pebble
#

that is the discord api

earnest phoenix
#

ah

hushed oyster
#

but

onyx pebble
#

line 26 is the for section

hushed oyster
#

with the JDA wrapper

#

so it is using JDA

onyx pebble
#

The JDA is working but the Command not

#

-osu MarcUPlayOsu

hushed oyster
#

well

#

the array seems to be out of bounds

onyx pebble
#

But do you know how to fix

hushed oyster
#

no

onyx pebble
old glade
#

@onyx pebble How do you put a background image in the discord Client/webapp ?

onyx pebble
#

I use a special modded Discord Client

old glade
#

teach me senpai

#

oh

#

which one ?

onyx pebble
#

BetterDiscord

old glade
#

working well ?

karmic parcel
old glade
#

How do I auto erase my bot's latest message after x sec ?

gusty topaz
#

what lang

#

@old glade

topaz fjord
#

With d.js just use message.delete

old glade
#

.py

gusty topaz
#

ah

#

sorry, I am not able to help with that

old glade
#

but I think I found something

gusty topaz
#

I may try

#

question

#

are you using rewrite

#

or no?

old glade
#

nope

gusty topaz
#

sorry, I have no idea then

old glade
#

thank you anyway ๐Ÿ˜ƒ

gusty topaz
#

I could help more with js but eh

#

everyone uses what they use

old glade
#

yep ^^

frail harness
#

@onyx pebble. BetterDiscord is against the ToS and can result in acct termination

old glade
#

@gusty topaz got it working

onyx pebble
#

@frail harness I dont care

gusty topaz
#

๐Ÿ‘Œ

topaz fjord
#

@onyx pebble so you wouldn't care if I report kek

prime geyser
#

@old glade it's not author, it's message.author

old glade
#

yeah i know

#

I format message.author

frail harness
#

Then I'll report you then lmao

gusty topaz
#

I wanted to suggest a simmilar thing but dont have much experience with python

old glade
#

to include it into a var

onyx pebble
#

Yes report me and waste your Time c:

topaz fjord
#

Ok

onyx pebble
#

I have a Backup Acc ๐Ÿ˜‚

topaz fjord
#

@frail harness u have sharex?

ruby dust
#

@frail harness BD isn't really strictly against tos, but selfbots are

#

modded clients are just not prefered, that doesn't mean it's not allowed under any circumstances

real beacon
#

i'm setting how many users are using the bot using bot.users.size when the bot is ready but each time the bot resets it changes by a few numbers. am i doing it right?

ruby dust
#

include a library so that people know how to help

real beacon
#

discord.js

#

forgot

uncut slate
#

@ruby dust BD and modded clients are most definitely strictly against ToS

south finch
#

They released a statement saying that it is against tos now and can result in your account being removed hmmm

hushed oyster
#

@earnest phoenix zoomeyes

karmic parcel
#

It literally has it in the ToS

#

Modified Clients

#

reeee

heady zinc
#

i wonder

#

if you make an app that uses the API to literally behave like the discord client

#

would it be against the ToS

#

as it wouldn't be a modded client technically ZoomEyes

inner jewel
#

it'd count as a selfbot

heady zinc
#

oh guess that make sense

dire kettle
#

What is a self bot?

lethal sun
#

its like a bot but

#

its an user

#

you leak ur own accounts token and use it to send embeds or something like that.

frigid sierra
#

@heady zinc i started doing that a long time ago before selfbots got banned

#

it was all command line based

heady zinc
#

noice

earnest phoenix
#

@dusty kettle should I

let allUsers = client.users.array();
allUsers.forEach(u => console.log(u.id));
```?
dusty kettle
#

should do

earnest phoenix
#

it doesn't work

#

idk why

dusty kettle
#

weird

#

@earnest phoenix Ask in the discord.js support server

solemn obsidian
#

.array returns an object

#

client.users.forEach is already a thing

severe glen
#

oh great lol I always wondered what that was and what the "Works only for non-bot account" on api means

#

thats cool

slim heart
#

Alright, I was really attempting to avoid this whole situation, but this is just what i gotta do to advance my bot further, I would like to create a toggle-able control that will add server id's to a variable, or something like that idk, but I have litterally no idea where to start...

quasi marsh
#

What would you need this for?

slim heart
#

I'm gonna be making it so it toggles a specific part of my bot for the server

#

it's a censor bot

quasi marsh
#

Ah

slim heart
#

Ik my code is really crappy, but that's besides the point

quasi marsh
#

Do you have a database

slim heart
#

nope

quasi marsh
#

It might be useful

#

Basicly when a server admin presses the button, you'll want to put their guild in a list with guilds that have the setting enabled

#

And when he does it again it should be removed

slim heart
#

yeah

quasi marsh
#

I use redis myself, so you can look into smembers, sadd and srem for that

slim heart
#

I was guessing like adding the server as the serverid variable.enabled and yada yada idk

dusty kettle
#

You'll need a DB to store that info about the guilds though

slim heart
#

like sqlite?

#

or am i way off lmao

quasi marsh
#

Usually my DB is structured like guild:ID:setting_name: , true

heady zinc
#

sqlite can be a choice

quasi marsh
#

sqlite is an option

heady zinc
#

there is plenty of dbs out there

quasi marsh
#

So is Rethink, MySQL, PostgreSQL, Redis, Mongo

heady zinc
#

^

quasi marsh
#

I use Redis, but be aware it is limited in the fact that you cannot search the DB

dusty kettle
#

enmap

quasi marsh
#

You need to know the key beforehand to get the value

heady zinc
#

enmap and enmap-level may be a good choice for beginners

dusty kettle
#

Ye it's also local so you dont need a server

quasi marsh
#

I'm not experienced with enmap but from what i've heard it's a good base

slim heart
#

i have litterally no clue, what most of this is, but okie

heady zinc
#

but at some point you would need a real database

dusty kettle
#

It is simply a map but persistent

#

@quasi marsh

quasi marsh
#

ah

heady zinc
#

google all of that

#

you're maybe even going to fall on tutorials ZoomEyes

#

google is much useful nowaways eh

slim heart
#

I mean ik how to make a database technically, but, i don't really know how to use it...

dusty kettle
#

Well if you know how to work with the d.js collections you know how to work with enmap. You only have to know how to set it up

#

Which is done in like 3 lines

slim heart
#

seeeee, i'm not the best with js or d.js, so really i have no clue how to set, and retrieve data from a db

trim plinth
#

Search up a tutorial then

dusty kettle
#

@slim heart Enmaps github is really clear, first you should learn what a map in javascript is though. When you know how those work you can look into how to create an enmap which again is super simple.

slim heart
#

wait how exactly do i use this db locally since all of this is requiring like a host port username and password

trim plinth
#

which db are you using

slim heart
#

idek at this point it's just a db file lmao

#

sqlite

#

probably

trim plinth
#

sqlite is not a file

dusty kettle
#

Well most DB's are hosted on a server which gives you access to it from wherever you want. But level-db based databases like enmap are stored locally.

heady zinc
#

as for sqlite you just have to launch it on localhost

slim heart
#

it says SQLite Format 3 idk

dusty kettle
slim heart
#

๐Ÿ˜ฎ

dusty kettle
slim heart
#

:>

#

wats wrong w/ dat?

dusty kettle
#

Nothing it's perfect

trim plinth
#

logchannel.send GWczeWhat

slim heart
#

it's a channel in my discord serverf

dusty kettle
#

@trim plinth logchannel is a var with a channel as value

trim plinth
#

mk

slim heart
#

it's just a nice thing to have

dusty kettle
#

Ye it's pretty clever

trim plinth
#

not really clever, its just searching for a id of a channel using a variable

#

or its looking for the name

slim heart
#

i think he means the concept :>

#

i didnt do it the best

#

but like, you have a timestamp for everything instead of if you restart the console clears, atleast for me

dusty kettle
#

@trim plinth it saves having to paste the id everywhere every time you want to log to his log channel

trim plinth
#

either way the concept isn't that advanced and/or clever

#

yeah thats just saving time not really clever

dusty kettle
#

K then

#

If you say so

trim plinth
#

I mean, everyone has their own opinions but if you think thats clever then thats ok

slim heart
#

right, i just need one bit of help, how do i connect to a local db...

dusty kettle
#

@slim heart Well, have you chosen your db?

slim heart
#

in terms of....

trim plinth
#

in terms of a database

dusty kettle
#

^

slim heart
#

cuz im just using sqlitebrowser and just made one lmao

earnest phoenix
#

sqlite lib

slim heart
#

sure

#

xd

dusty kettle
#

oh wait that seems like pretty cool software

#

But not what you need

slim heart
#

๐Ÿ˜ฎ

dusty kettle
#

probably

slim heart
#

i mean i've made a .db file and like i can add fields and crap

trim plinth
#

.db file

slim heart
#

So i mean i've figured out how to db.open(blahstupidstuffhaha)

#

but idk how to set db

trim plinth
#

google is your best friend

earnest phoenix
#

sql statements

slim heart
#

i've used google

dusty kettle
#

@slim heart But can nodejs communicate with that software you are using then?

earnest phoenix
#

what lang and which lib

dusty kettle
#

discord.js

slim heart
#

i mean, it doesnt have to use the software im pretty sure, if it's just a file then it should be readable by any mysql communication

trim plinth
#

a db isn't a file

earnest phoenix
#

mysql is db server software

slim heart
trim plinth
#

no thats not how it works

earnest phoenix
#

you should be able to supply a connection string somewhere

#

hes using sqlite

slim heart
trim plinth
#

oh

#

nvm

earnest phoenix
#

why are you using a mysql lib for sqlite

slim heart
#

idk what im doin

earnest phoenix
#

they are two completely different things

trim plinth
slim heart
#

i just already had sqlitebrowser installed

#

so ๐Ÿ˜ฎ

earnest phoenix
#

get an sqlite lib and follow their documentation

trim plinth
#

@slim heart use the sqlite lib, not the mysql one

dusty kettle
slim heart
#

okay...

#

alriiight, i see

#

okay i got all of that stuff running in my code, i think ๐Ÿ˜ฎ

#

:/ i have no idea lmao, isn't there an easy way where i could like, make json files for each server, and then it would be like
{ "cursing": true }

heady zinc
#

there is but i wouldn't recommend making a file/server

#

i wouldn't recommend using JSON files at all tbh

slim heart
#

is there a way to like when looking for a something like channel.sendMessage(file.variable)
but like, make it so that search for a var in the js file instead of "variable" so like,
const variable = actualvariable channel.sendMessage(file.variable)
but like it'll search for "actualvariable"

inner jewel
#

no

slim heart
#

uuf

inner jewel
#

that'd add a huge level of unneeded complexity

slim heart
#

okay ๐Ÿ˜ฎ

earnest phoenix
#

umm, one question here: how can I shape an image to any shape in jimp?

example: you have a round circle, and you have a square picture.
transform the square picture to a round circle, so that you have a round circle picture.

#

Should always use canvas

topaz fjord
#

@earnest phoenix but it's hard on windows

#

To install

#

So many people go to jimp

earnest phoenix
#

Could be a bit of a pain yeah, but honestly it's so much better it's worth it

slim heart
#

alright i've decided to use mysql cause i've already gotten it all set up etc. But now i need a way to call it, what i wanna do is test for if (based on serverid) if "censor" is true or false

#

and then () return; if it is false

#

so like something where i can do like, if(message.server.id IDK WHAT GOES HERE, censor=false) return;

topaz fjord
#

One question

#

Did you read the mysql node.js module docs

#

@slim heart

#

It states it there

slim heart
#

i read a little bit of it

#

obviously not enough ๐Ÿ˜ฎ

slim heart
#

okay, well that really didnt help much at all unless SELECT is what you use to actually find it, cause i can't find anyway to actually find a entry in a row...

earnest phoenix
#

SELECT censored FROM Servers WHERE id = ?

topaz fjord
#

it is based on the mysql commands

slim heart
#

alright nvm, i did a mistake

#

i am able to pull variables from a row

#

etc

#

But idk how to set the specific result to a variable

ripe blade
#

@slim heart wdym

slim heart
#

i got the return

#

but i want to turn "censor" into a variable that the rest of the js will acknowledge

ripe blade
#

umm

#

Like a global scope?

slim heart
#

i guess?

ripe blade
#

i mean

#

yourGlobalVar = (therowobj).censor ?

#

But why?

slim heart
#

like i wanna be able to do
if(censor = 1) return;

#

alright

ripe blade
#

reject the promise instead

#

don't use global vars

gilded blaze
#

JS can't really interpret RowDataPackets

slim heart
#

wait what would (therowobj) be?

ripe blade
#

I don't even know what database your using

slim heart
#

alright well i can bump it down to just containing "censor"

#

cause i can do SELECT censor FROM etc...

#

im using mysql

gilded blaze
#

convert to JSON

slim heart
#

i've been told to stay away from json lmao

trim plinth
#

I think you've been told to stay away from json for databases, not code

inner jewel
#

json is fine

#

json files to save data are not

trim plinth
#

^

slim heart
#

not on this discord snarky

#

on discordapi

trim plinth
#

LOL

slim heart
#

And either way i still have no clue how to move it to json

gilded blaze
#

google

trim plinth
#

google is a nice guy

#

helps you in situations like this

slim heart
#

But there should be away to define a result from
``connection.query('SELECT censor FROM censorbot WHERE serverid = ' + message.guild.id, function (error, results, fields) {

})``

trim plinth
#

nah just convert to JSON

earnest phoenix
#

something something callbacks or await

slim heart
#

And i've tried googling it

trim plinth
#

easy way

slim heart
#

Idk how to word it lmao

trim plinth
#

or @earnest phoenix's suggestion

slim heart
#

what exactly do i google to use that suggestion ๐Ÿ˜ฎ

inner jewel
#

google "node.js mysql access column from a row"

earnest phoenix
#

wrap your query statement into a function

#

call that function whenever you want to access a server's db data

slim heart
#

i need a true or false result from "censor" when dealing with a row

#

im finding the row with serverid, then trying to retrieve 0 or 1 from censor

glossy mason
#

Somewhat related, but you should always use prepared statements, never concatenation in queries

slim heart
#

well, i just figured out that sqlite and mysql are different things, i dont think im in any position on trying to do something more advanced ๐Ÿ˜ฎ

glossy mason
#

It's very simple

connection.query('SELECT censor FROM censorbot WHERE serverid = ?', [message.guild.id], function (error, results, fields) {
//your code
})
slim heart
#

that's what i have

#

but i need to be able to identify the value of censor

#

i can console.log it all i want and see it

#

but i need to see what it is in the code

glossy mason
#

You were doing 'SELECT censor FROM censorbot WHERE serverid = ' + message.guild.id

slim heart
#

there is no troubles rn with []

#

Everything returns fine in console.log

#

AYY

#

i just figured it out

inner jewel
#

that's an array

slim heart
#

results[0].censor

glossy mason
#

The reason you should never concatenate is anything in that variable becomes part of the query. It may seem fine if it is the guild id where you know Discord will always give you a number but let's say you were getting user input and adding a swear word or something to your table like:

"INSERT INTO swears VALUES ('" + swearWord + "')"

Sure if swearWord was normal text, it would be fine. But say the user said their swear word is ';DROP TABLE swears-- it would add that to the query to yours and drop the table. But if you made a prepared statement like

"INSERT INTO swears VALUES (?)"

and used the whole bracket thing I mentioned, it would add that directly to the table, not executing it as part of the statement.

#

This can explain it better than my quick example: https://www.w3schools.com/sql/sql_injection.asp
There's no reason anyone should be using concatenation, even when you are 'sure' inputs will be safe, because you can never be sure and it is not a whole lot of work anyways to do it the correct way.

earnest phoenix
#

yes

#

your bot will be memed if you concat

slim heart
#

i've already figured everything out with what i had to do :>

#

But now i got another question ๐Ÿ˜ฎ how would i avoid getting double entries of the same server, like, can i test for if it exists somehow?

glossy mason
#

UPSERT, you'll have to lookup how to do it in MySQL but the idea is to try to insert but on collision update. You can do it as a single statement.

#

(And still, don't concatenate.)

earnest phoenix
#

primary key for server id

inner jewel
#

primary key for censor

rain tulip
#

:theMadman:

#

xD

#

I'm not sure how to use react.remove

clear hill
#

๐Ÿ–•

#

where i can host my bot?

rain tulip
earnest phoenix
#

I like Vultr for small bots

shy flicker
#

Well what solace said if you have some money to spend, but what fire.ajit.pai(please) if you are trying to host it for free. (imo)

clear hill
earnest phoenix
#

Welp, if you dont have money then you're not going to find a good host

#

Lol

shy flicker
#

well my bot runs over glitch.com atm @clear hill
And you get a mentionable nickname

idle grail
#
gl: {
    a: ["guildleaders"],
    d: {
      desc: "Guild Leaderboard! One of the main bot functions.\n`[gl:r]` displays all the new guilds\n`[gl:a]` displays all active guilds(still making)\n`[gl:mem]` displays guilds with the most members\n`[gl:msq]` displays guilds with the most messages recorded by the bot.",
      usage: "gl(:r, mem, msg, a)",
      perms: "everyone",
    },
    f: (message, mess) => {
      if(mess === "a") return message.reply("Still in production");
      
      let l = "";
      switch(mess){
        case "r":
          sql.all("SELECT * FROM guilds ORDER BY created")
            .then(guilds => {
              for(var i = 0; i < guilds.length; i ++) {
                l += `[**${client.guilds.get(guilds[i].id).name}**](${guilds[i].invite === "" ? "" : guilds[i].invite})\n**Members:** ${client.guilds.get(guilds[i].id).memberCount}\n`;
              }
              console.log(l);
            })
            .catch(err => console.log(err));
          break;
        case "":
        case "mem":
          sql.all("SELECT * FROM guilds")
            .then(guilds => {
              guilds.sort(function(a,b) { return parseInt(b.points) - parseInt(a.points) });
              for(var i = 0; i < guilds.length; i ++) {
                l += `[**${client.guilds.get(guilds[i].id).name}**](${guilds[i].invite === "" ? "" : guilds[i].invite})\n**Members:** ${client.guilds.get(guilds[i].id).memberCount}\n`;
              }
              console.log(l);
            })
            .catch(err => console.log(err));
          break;
        default:
          return message.reply("Not a valid leaderboard type");
      }
      embed.setAuthor("Everyone Bot Guild Leaderboard", client.user.avatarURL);
      console.log(l);
      embed.setDescription(l);
      message.channel.send({embed}).catch(console.log);
    },
    t: 3,
    del: false
  },```
#

Whats wrong with that

#

anyone

#

...

#

;-;

jagged birch
#

Whatโ€™s the error

frail kestrel
#

not gonna find it

#

show error

#

pls

clear hill
#

I Have Money xD

vale saffron
#

down at the screeen on the side

clear hill
#

Waiting Approved

trim plinth
#

@vale saffron the "Bot awaiting approval"?

clear hill
#

Waiting Mods Approved

vale saffron
#

i can't wait

trim plinth
#

Well everyone has to wait too

#

Theres a bot queue

clear hill
#
      setTimeout(() => {
                    bot.user.setPresence({ game: { name: prefix+"Secret", type: 3 } });
            }, 18000);``` Dint Works xD
vale saffron
#

oka

clear hill
#

Help

vale saffron
#

i guess it will take some days for me

topaz fjord
#

1 hour to a day

#

Asking delays

timber tree
#

guys

topaz fjord
#

What

timber tree
#

I keep getting defined bugs

trim plinth
#

@clear hill 1. Random Presence Timeout GWczeWhat 2. Setting Presence Twice GWczeWhat 3. You can just put what you want as the Presence, nothing extra needed

timber tree
#

irritates meh

topaz fjord
#

Show error @timber tree

trim plinth
#

show code too ^

topaz fjord
#

And the code where it happens

timber tree
#

const title = info.title
^

TypeError: Cannot read property 'title' of undefined

languid dragon
#

info isn't defined / doesn't exist

topaz fjord
#

info is undefined

timber tree
#

if(args[1].startsWith('https')) {
voiceChannel.join()
.then(connection => {
let stream = YTDL(args.join(" "), {audioonly: true});
YTDL.getInfo(args.join(" "), function(err, info) {
const title = info.title
console.log(${message.author.tag}, Queued the song '${title}.')
var embed = new Discord.RichEmbed()

topaz fjord
#

there is no info then

#

Info from the callback is undefined

timber tree
#

hmm

earnest phoenix
#

@timber tree probably err is not undefined/null if info is null so check err

topaz fjord
#

You should always check if there is an error whenever the callback includes it

clear hill
#

help

timber tree
#

hmm what I do know is there is another bug included

clear hill
#

how i can add badword? In My Bot Like !addbadword FUK FUCK Shit

timber tree
#

(node:6476) UnhandledPromiseRejectionWarning: TypeError: dispatcher.on(...).catch is not a function
at voiceChannel.join.then.connection

trim plinth
#

no spoonfeed here

topaz fjord
#

That's not the only way to catch an error

timber tree
#

hmm

clear hill
#

hey

timber tree
#

well gonna try to dig more into these errors

clear hill
#

how i can add badword? In My Bot Like !addbadword FUK FUCK Shit

#

how i can add badword? In My Bot Like !addbadword FUK FUCK Shit

trim plinth
#

no need to repeat it 3 times

languid dragon
#

@clear hill google it

#

we are not here to spoonfeed you code

clear hill
#

๐Ÿ˜ฆ

#

ho

mental willow
#

how do i get my python bot to play the next queued song

@bot.command(pass_context=True)
async def play(ctx, url):
    if playing = False
        author = ctx.message.author
        voice_channel = author.voice_channel
        vc = await bot.join_voice_channel(voice_channel)

        player = await vc.create_ytdl_player(url)
        player.start()
        playing = True
        new_vid = queue[0]
    else:
        queue.append(url)```
fleet mason
#

const team = require("../files/team/team.json")

let team1 = args.slice(0,1).join(" ");
let teamk = team1.toLowerCase();

if(!teamk) return message.channel.send("You have to specify a member");
else {
  message.channel.send(team[teamk]);
}
#

how do i make it find the right thing in the json file

#

like if i type xkijux it will find the "xkijux" in the jason file and output the info after as the message

frail harness
#

@mental willow line 3 would throw a syntax error; it should be if not playing

#

also, you should be checking if the bot is already in VC

old glade
#

I have this code

#

and this issue

clear hill
#

``Online: 2078

DND: 622

Idle: 614

Offline: 9159

Total: 12473``

^ How ^ Discord.js

languid dragon
#

figure it out yourself

clear hill
#

?

languid dragon
#

use the documentation and figure it out yourself

#

we're not spoonfeeding you

clear hill
#

๐Ÿ˜ฆ

#

I Search On Google No One Documentation Like This ๐Ÿ˜ฆ

languid dragon
earnest phoenix
#

How can i dm to all the users that in the servers that my bot in it?

#

d.js

south finch
#

why would u want to do that

languid dragon
#

u dont

restive silo
#

^

earnest phoenix
#

someone teach me how to use
invite.uses in discord.js

low rivet
#

docs

earnest phoenix
#

.

#

guys how made the listening status ? node.js format ?

inner jewel
#

click that

earnest phoenix
#

thx.

civic talon
#

What's the best Cloud hosting for Discord bots that also need to stream music?

gusty topaz
#

any VPS

#

Wait

#

Comprehensive list of hosting companies
Free
https://glitch.com/ - They can host node.js programs, needs some setup
https://heroku.com/ - They can host boats in almost any lang, needs some setup

Paid
https://www.ovh.com/ - Cheap servers, not very fast network, quite decent reliability
https://www.scaleway.com/ - Cheap servers, decent network, decent reliability
https://bakeryhosting.us/ - Cheap servers, no bandwidth limits, small company, decent reliability
https://www.vultr.com/ - Expensive, very good servers, excellent reliability
https://www.digitalocean.com/ - Expensive, extremely fast network, excellent reliability
https://vpsdime.com/ - Cheap, never have had experience with it
https://cloud.google.com/ - Expensive, scaleable, hosted by google, has free trial,
https://aws.amazon.com/ - Expensive, scaleable, hosted by amazon, has free trial
https://azure.microsoft.com/en-us/ - Expensive, scaleable, hosted by microsoft

civic talon
#

thank you @gusty topaz

gusty topaz
#

you're welcome

civic talon
#

I use Aruba cloud rn but the bot is not performing well

#

so I'm looking for an alternative

heady zinc
#

that should be pinned tbh

civic talon
#

^

heady zinc
#

would personally recommend vultr

#

good servers and great network

#

had no issues with them

#

but yeah they're expensive af

dusty kettle
vale saffron
#

i can't wait anymore to invite my bot -_-

#

sorry

#

@bitter sundial i can't wait anymore

uncut slate
#

web SSH clients are pretty trash, I would just use an actual SSH client

quasi marsh
#

Also isn't google expensive

#

Make sure to secure your web ssh access

uncut slate
#

Google Cloud Trial is free for 12 months, with a 3GB 1vCore VPS

quasi marsh
#

SSH keys won't do shit if you can just use a password to get into your VPS dashboard

#

Ah

uncut slate
#

they also have an Always-Free thing

#

free forever but specs are a little worse I think

dusty kettle
#

No I dont think they have that,
Anyway cheapest thing is a quite shitty vps for 4 dollars/m
Next step is 15 dollars/m

topaz fjord
#

@vale saffron you do know that asking delays the process right?

#

have patience

dusty kettle
#

Also this ssh client allows easy file upload and some other cool settings @uncut slate

topaz fjord
#

what do u get in the 15/m

vale saffron
#

im not sure

dusty kettle
#

So pretty neat

earnest phoenix
#

Vultr > Everything

topaz fjord
#

@dusty kettle

dusty kettle
#

ye

earnest phoenix
#

I have experience with VPSDime

dusty kettle
#

@earnest phoenix Expensive

earnest phoenix
#

Very cheap and ran @cosmic shoal 24/7 for months

topaz fjord
#

i use Galaxy Gate

dusty kettle
#

@topaz fjord stuff

earnest phoenix
#

Havana runs VPSDime now

dusty kettle
#

I'll check

earnest phoenix
#

and it had an uptime of almost a month straight

#

and only went offline due to a rethinkdb error

dusty kettle
#

cloud.google is also nice because it handles all of my google api keys on the same dashboard

topaz fjord
#

$10 for 2 core cpu, 4gb ram, 60gb space, 500mbps netowrk, and unlim bandwith

#

pretty sexy

earnest phoenix
#

That's good, but I use VPSDime bc its $7 for 4 cores, 6GB of RAM, good network speeds 200-300mbps down/up, and 2TB bandiwdth

topaz fjord
#

wtf

earnest phoenix
#

and their servers are super reliable

dusty kettle
#

1 year free with 300 bucks to spend btw

topaz fjord
#

people told me vps dime has a shit tos is that true?

earnest phoenix
#

It's restrictive

#

They disallow targets of attacks

#

Like minecraft servers and gmod servers, things that are often targets of DOS/DDOS

dusty kettle
#

lol

quasi marsh
#

Look here

#

But still expensive

#

Premptive instances are cheaper, however, Google may shut them down if they need the resources

elder rapids
#

Targets of attacks?

#

#OVH#FreeAntiDDoS

topaz fjord
#

fortnite

earnest phoenix
#

i paid $7 for 1 year of a gay no-name vps service

#

so far only 1 day of downtime

uncut slate
#

language

west current
#

(node:4488) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: No supported ALPN protocol was negotiated
Code:

        const {body} = await snekfetch.get(`https://api.openweathermap.org/data/2.5/weather?zip=ZIP&appid=API_KEY`);
ruby gazelle
#
const Discord = require("discord.js");
const ms = require("ms");

exports.run = (client, message, args) => {

  let tomute = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
  if(!tomute) return message.reply("Couldn't find user.");
  if(tomute.hasPermission("MANAGE_MESSAGES")) return message.reply("Can't mute them!");
  let muterole = message.guild.roles.find(`name`, "muted");
  //start of create role
  if(!muterole){
    try{
      muterole = await message.guild.createRole({
        name: "muted",
        color: "123000",
        permissions:[]
      })
      message.guild.channels.forEach(channel, id) => {
        await channel.overwritePermissions(muterole, {
          SEND_MESSAGES: false,
          ADD_REACTIONS: false
        });
      });
    }catch(e){
      console.log(e.stack);
    }
  }
  //end of create role
  let mutetime = args[1];
  if(!mutetime) return message.reply("You didn't specify a time!");

  await(tomute.addRole(muterole.id));
  message.reply(`<@${tomute.id}> has been muted for ${ms(ms(mutetime))}`);

  setTimeout(function(){
    tomute.removeRole(muterole.id);
    message.channel.send(`<@${tomute.id}> has been unmuted!`);
  }, ms(mutetime));


//end of module
}

this command to mutate for a certain time, right?

#

because when I was running it did not show the error, but it did not work

west current
#

What's the error

ruby gazelle
#

when I run the command does not show, then turn off the bot on time

frail kestrel
#
  1. Pretty sure await comes in a pair with async so itโ€™d make sense to use async first before awaiting things
  2. await()?
#

iirc thatโ€™s not a function lol

jovial violet
#

This isn't bot development, but does anyone know what HTML code people use to make their bot icon look circular?

#

on the Discord Bots page

hushed oyster
#

@jovial violet it's css

#

not sure if this would count as spoodfeeding

#

but i can give you the css

jovial violet
#

Thanks

#

I'm still learning HTML and I'm not thinking about learning CSS soon

#

I'm guessing animations are CSS too right?

hushed oyster
#
  border-radius: 150px !important;
}``` put this in a ``<style>`` tag
jovial violet
#

Because it's a part of the style

hushed oyster
#

animations are CSS for non-certified bots

#

but

#

they could be JS for certs

jovial violet
#

ah

#

thanks for the code man

#

I appreciate it

hushed oyster
#

np

abstract mango
#

you can also use border-radius: 50% !important;

#

iirc

frail kestrel
#

whats the selector for the bg?

trim plinth
#

@frail kestrel background-image

frail kestrel
#

o ok

#

is that the dbl bot background selector?

trim plinth
#

yes

#

using it in css would change the background depending on what you do

frail kestrel
#

yes

karmic parcel
#
import LinkedListNode from "./LinkedListNode";

export default class LinkedList<T> {
  private head: LinkedListNode<T> | null = null;
  private tail: LinkedListNode<T> | null = null;
  private size: number = 0;

  public add (item: T): boolean{
    let temp = this.createNode(item);
    temp.next = null;
    if(this.head === null) {
      this.head = temp;
      this.tail = temp;
    }
    else {
      this.tail.next = temp;
      this.tail = temp;
    }
    this.size ++;
    return true;
  }

  private createNode(item: T): LinkedListNode<T> {
    return {
      value: item,
      next: null
    }
  }

  public toArray(): T[] {
    const array: T[] = [];
    let current: LinkedListNode<T> | null = this.head;
    while(current !== null) {
      array.push(current.value);
      current = current.next;
    }
    return array;
  }

  public display(): string {
    return this.toArray().join('\t');
  }

  public length(): number {
      return this.size;
  }
}
heady zinc
#

what language is that ZoomEyes

restive silo
#

TS

heady zinc
#

oh

karmic parcel
#

how sexy

#

is that code

restive silo
#

that looks sexy af

heady zinc
#

ts looks way uglier than i thought

restive silo
#

ngl

karmic parcel
#

wat, paradox

#

waaat

restive silo
#

what you mean ugly

heady zinc
#

like aetheryx

#

ugly

restive silo
#

that looks bae

karmic parcel
#

lol

restive silo
#

that code is like 20x cleaner than plain JS

#

and actuall has typings + scales

#

@karmic parcel ```
}
else {

#

whats that

#

who does that

trim plinth
karmic parcel
#

uh, meee obviously sadblobgery

restive silo
#

i mean thats kinda an opinion thing

karmic parcel
#

just a coding habit that I picked up

restive silo
#

yea

karmic parcel
#

yeah

restive silo
#

i blobheart TS

karmic parcel
#

I used to use C++/Java/Python heavily

restive silo
#

ngl

karmic parcel
#

and the OOP of TS just makes me moist

restive silo
#

same

#

and using keywords like export and import is Lewd

karmic parcel
#

yeeeeess

#

I think I'm gonna rewrite dickswordapp and my js lib in TS tbh

restive silo
#

lul

#

do that

karmic parcel
#

that way I can make a bucket a lot easier for rate limiting

restive silo
#

tru

karmic parcel
#

yeah making your own data structures is soooo much easier in TS

restive silo
#

thats true but its actuall quite hard to make good typings for a large JS app ablobsweats sometimes you get into some issues

#

because some stuff is other in TS

#

if you write it comletly in TS its neat ofc

karmic parcel
#

yeah, doing it half and half is kinda reeee

restive silo
#

same

karmic parcel
#

that's why I'm gonna rewrite my webhook service in TS because I started to do a smol rewrite of the data structures and it was icky

restive silo
#

i c

#

whats your bot?

karmic parcel
#

uhhhh I work with Dank Memer, but I have my own bot called HawkBot

#

it's not on the list

restive silo
#

o

#

Aeth, Melmsie and you owo

karmic parcel
#

mhmm

#

I haven't actually touched the bot code yet, I helped restructure and cluster the API server

#

and now I'm working on the website and dashboard

restive silo
#

interesting

willow socket
#

Is there a way to get a PrivateMessage if the PrivateChannel got closed and reopened(bot restart etc.) in jda

#

I tried saving the messageID, but throws a NullPointerException if I search the message with that ID

karmic parcel
#

I don't think bots keep DMs anymore

#

they used to

inner jewel
#

User#openPrivateChannel().queue(channel->doStuffWith(channel))

karmic parcel
#

but with v6 they don't keep history anymore eyers

inner jewel
#

you can still open i

#

it*

#

they keep 10 channels open at max iirc

willow socket
#

@inner jewel haha funny. Yeah I can open it but message still gone

karmic parcel
#

so it's a guessing game of which

inner jewel
#

that's why you always call open

karmic parcel
#

I just disregard DMs as reliable

inner jewel
#

JDA doesn't do any requests if the channel's ppen

karmic parcel
#

so I don't fucke with them

inner jewel
#

open*

willow socket
#

I want to edit a message. Works perfect until Bot restarts. Problem is that after the Bot restarts it cannot find that message anymore (Yes, the channel IS opened)

inner jewel
#

MessageChannel#editMessageById

#

also if it throws a NPE you gave a null argument to JDA

#

JDA never returns null

#

only on RestAction<Void>

#

or getting an entity not on cache

#

but in that case there's nothing nullable

willow socket
#

In detail its no NPE but basically the same

net.dv8tion.jda.core.exceptions.ErrorResponseException: 10008: Unknown Message
restive silo
#

Thats a Discord API error response tho

#

means that you try to edit an message what is not there or deleted already

willow socket
#

Yeah thats what I know already, thats why my question was is there a way either to keep dms when restarting the bot or if there was another way to get written dms after restarting the bot

analog walrus
#

Idk

#

I am not that advanced yet

restive silo
#

well then save message id in some kind of database => open DMChannel again => use editMessageById

#

that should work fine

analog walrus
#

Also check if id is null

willow socket
#

Thats what I already tried

analog walrus
#

Cuz that causes alot of stuff to nvm

#

He tried

restive silo
#

well sems like you passed a wrong id to editMessageById

#

or got the wrong DMChannel

willow socket
#

Rn bot does
Check if PrivateChannel is open -> Send Message -> Save MessageID to DB
And if it wants to edit this Message
Check if PrivateChannel is open -> Get MessageID out of DB -> Get Message by ID -> Edit Message
Bot even saves the PrivateChannelID. Everything works fine UNTIL Bot restarts.

analog walrus
#

Ur saying when bot restarts you cant edit?

willow socket
#

Thats what I said 4 times already

analog walrus
#

Chill

#

Probably MessageID that ur saving is empty or not correct

#

Trying logging it

#

To see what u saved

willow socket
#

I can see what I saved

low rivet
#

what is your db

willow socket
#

MySQL (MariaDB)

#

But the DB is not the Problem

#

Saved MessageID is correct

analog walrus
#

Im assuming ur db only HAVE THE MESSAGEID

#

If its that idk

#

Ask the other devs

willow socket
#

I am saving several things, but things that belong to the PrivateMessages are UserID, PrivateChannelID and PrivateMessageID

#

And thats everything you need to find the Message usually. You dont even need the userid

inner jewel
#

you do

#
channel.editMessageById(channel.sendMessage("a").complete().getIdLong(), "b").queue()``` this works perfectly fine for me
upper ember
#

Anyone can help me do it?

inner jewel
#

iterate through all users, checking discriminator

gusty topaz
#

iterate over all users

#

and check dis...

#

oh

#

natan said it faster

inner jewel
#

users.filter(_.getDiscriminator() == theOneYouWant).stuff()

gusty topaz
#

Note that the iteration approach may be slow

#

On larger guilds

willow socket
#

How can I link a word to a url in the footer of an EmbedBuilder?

quiet bobcat
#

What lib?

willow socket
#

JDA

inner jewel
#

you can't

#

discord doesn't allow markdown in embeds outside field values/description

willow socket
#

Sad

quiet bobcat
#

You can't? I thought you could lol

willow socket
#

I thought i have seen this aswell

#

I know you cant use markdown but thought there was another way

inner jewel
#

you can link the title (maybe author too, not sure on this one)

unborn stone
#

Can someone help me with this?

guild.channels.get(guild.id).message.channel.send({embed: {
                                ^

TypeError: Cannot read property 'message' of undefined
solemn obsidian
#

you are trying to get channel with guild id

unborn stone
#

Yes.

#

Why does it say it can't read the property?

restive olive
#

Probably because .message isn't a property? ๐Ÿค”

tender canopy
#

I have a question about the donate bot, is this where I can get an answer

quiet bobcat
#

what donate bot?

#

๐Ÿค”

#

and most likely not

solemn obsidian
#

channels.get(guild.id)

tender canopy
#

This donate bot

inner jewel
#

go there

#

it's the bot's support server

tender canopy
#

Thx!

#

Ugh, the invite is expired

tiny turtle
#

all the div

inner jewel
#

use an xml parser

heady zinc
#

that's not xml but just html ZoomEyes

tiny turtle
#

xpath

#

for changing values

#

so when a person uses the command it will change to any updated values

hushed oyster
#

๐Ÿคฆ

inner jewel
#

@heady zinc html is xml

heady zinc
#

not exactly the same thing ZoomEyes

inner jewel
#

BlobThonking actually it isn't

#

SO lied to me

obsidian stirrup
#

How would I cycle through a users roles and pull out the ones that were listed in a table I had made previously?

#

I'm working in discord.js

#

Any help is greatly appreciated. Tag me so I'll see the response.

old phoenix
#

How come I can't get the cards against humanity bot to work

#

Same any help would be greatly appreciated

hushed oyster
#

@old phoenix wrong channel & ask in the support server

old phoenix
#

Okay

floral stone
#

I feel like I'm putting too many shards, how many servers is it for each shard?

elder rapids
#

uhh..?

floral stone
#

Shard count

#

I got 5 shards for each 1,000 server

#

is that too much?

#

How many shards should I need?

uncut slate
#

a shard every 200 servers is way too much

floral stone
#

1,000 for each shard

uncut slate
#

1000 per shard is fine, but it depends on what your bot does

#

you can easily get away with 1800 per shard

elder rapids
#

My bot can't ๐Ÿ‘€

uncut slate
#

yeah, depends on what your bot does

elder rapids
#

It does a lot of automation work

floral stone
#

I'm trying to find documentation about it

#

Can you source that?

elder rapids
#

But yes 1,000 per shard is actually a sweet spot

uncut slate
#

discord recommends 1500, my numbers are just community consensus

floral stone
#

Probably with something official.

hollow abyss
#

iirc 1k/shard is the officially recommended, but it depends on other things

uncut slate
#

oh gotcha

hollow abyss
#

If you use the gateway endpoint to suggest shard counts, it goes by 1k

#

But starting at 500s, not 1ks

elder rapids
#

wait the gateway goes by a 1k?

hollow abyss
#

So ex. 20500 guilds == 21 shards recommended

#

6500 guilds == 7 shards recommended

uncut slate
#

yeah I didn't know it did either

floral stone
#

Can I get an official source?

#

Some sort of citation

elder rapids
#

So what if you have 2,500 then ๐Ÿ‘€

#

Will it say just 2

#

or 3

hollow abyss
#

And use whatever number the gateway gives you

#

They can change it with / without warning - they have before - so just follow this because it'll be the most accurate recommendation for the most part

floral stone
#

Doesn't explain how many. :/

frail harness
#

Lmao I use 2 shards on a bot with 6 guilds

hollow abyss
#

How do you think we all got our numbers?

elder rapids
#

What are you trying to get at

hollow abyss
#

We used this endpoint

frail harness
#

Rip RAM

hollow abyss
#

And did the math

floral stone
#

It's not that i don't believe ya, I just want documentation.

hollow abyss
#

There is none

elder rapids
#

2 shards on a bot with 6 guilds..?

floral stone
#

I remember it being 2500 then 1k afterwards.

hollow abyss
#

Use the endpoint

#

See what it says

#

ยฏ_(ใƒ„)_/ยฏ

elder rapids
#

First off that's not only pointless, second you probably won't even use more than 1 shard

hollow abyss
#

Arguing about it here when there's no official docs on it is pointless

elder rapids
#

why have 2 shards for 6 guilds

hollow abyss
#

memes

frail harness
#

For the laffs

elder rapids
#

What documentation do you want

floral stone
#

Just something official or close to it, like from discord or api languages.

hollow abyss
#

The most official is the gateway endpoint

#

x-x

elder rapids
#

for what was it exactly..?

floral stone
#

what's the link

#

Bookmarking

hollow abyss
#

There's no official "recommend X guilds / shard"

elder rapids
#

^

#

You are required to shard every 2,500 guilds though

#

+1 shard per 2,500 guilds

hollow abyss
#

^

#

Very bottom of this page

floral stone
#

Someone told me about 2,500

hollow abyss
#

2500 is the hard limit

floral stone
#

But @uncut slate said 1,500

hollow abyss
#

He was wrong

floral stone
#

Hard limit?

elder rapids
#

That's recommended

hollow abyss
#

^

elder rapids
#

He never said anything about max limit

hollow abyss
#

2500 / shard is the max

uncut slate
#

Yeah, you should be following the gateway endpoint, which suggests 1000

#

You can get away with 1800 if your bot isn't intensive, like I said, depends on your bot

hollow abyss
#

"2500 guild limit per shard (may be higher, but won't be lower)"

floral stone
#

Higher for shard count.

#

or guild count?

hollow abyss
#

They may consider allowing more than 2500 guilds / shard right now

#

But atm 2500 is the limit

floral stone
#

Ah, ok. I'll keep that age.

#

Thanks

hollow abyss
#

Beyond that there's really no docs

#

And you generally should just check what /gateway/bot says

floral stone
#

Thanks!

uncut slate
#

Your library might have an auto parameter for shards, which also follows /gateway/bot (probably)

hollow abyss
#

^

floral stone
#

d.py has audosharding, but there is specify count.

#

Not sure if that is required.

#

It's not

ruby dust
#

how would I ignore commands from bots without spamming same peace of code in every single command definition? ๐Ÿค”

inner jewel
#

have a command handler

#

or just add the bot check in the beginning of your message handler

ruby dust
#
    async def on_command(self, ctx):
        if ctx.author.bot == True:
            return
```this is what I have, and aparently this isn't enough
#

ah nvm, I'll do it tomorrow then, since it's 2 am already rip

#

I'm mainly doing this just to unmute my bot here tho ๐Ÿ˜„

hushed oyster
#

I believe that if you're using the commands extension, it automatically already ignores bots

ruby dust
#

from discord.ext import commands?

hushed oyster
#

well

#

you need that

#

but it takes a while to migrate

ruby dust
#

yeah well, I'll ask again tomorrow, in like 18 hours to be precise... and thanks I'll leave that opened in my browser

frail harness
#

@ruby dust actually, on_command is run after the command is invoked

#

So you'll have to do it in on_message

ruby dust
#

the thing is that I have all events on a separate cog (file), and I'm currently using on_message event to filter invite links in servers that have that filter enabled

#

unless there is a way to have more than 1 of the same event

hushed oyster
#

you can do both in the event

ruby gazelle
#

Like I do when someone mentions my bot he speaks?

frail kestrel
#

are you wanting your bot to respond when mentioned?

ruby gazelle
#

yes

hushed oyster
#

set the prefix to <@botid>

#

or

#

you can do this with d.py

#

not sure about others

#

make the prefix a list

#

and set it to ["<@botid>", "<@!botid>"]

ruby gazelle
#

thanks

primal adder
#

i'm trying to link my discord.py bot to the discord bot list api but it returns this error: py Failed to post server count Forbidden: Forbidden (status code: 403): {"error":"Forbidden"} Traceback (most recent call last): File "/home/ubuntu/AppBot/dcdbotcog.py", line 25, in update_stats await self.dblpy.post_server_count() File "/usr/local/lib/python3.6/dist-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 "/usr/local/lib/python3.6/dist-packages/dbl/http.py", line 189, in post_server_count await self.request('POST', '{}/bots/{}/stats'.format(self.BASE, bot_id), json=payload) File "/usr/local/lib/python3.6/dist-packages/dbl/http.py", line 160, in request raise Forbidden(resp, data) dbl.errors.Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}

#

what's wrong?

#

pls tag me if u got a response

low rivet
#

@primal adder send code

#

ยฏ_(ใƒ„)_/ยฏ

#

hide token

primal adder
#
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, bot):
        self.bot = bot
        self.token = '8===D'
        self.dblpy = dbl.Client(self.bot, self.token)
        self.bot.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(self.bot.guilds)))
            except Exception as e:
                logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
            await asyncio.sleep(1800)

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

that's the entire cog

low rivet
#

thats not yur token right? :p

primal adder
#

lmao ofc not

#

and my main code has this: py startup_extensions = ["dcdbotcog"] if __name__ == "__main__": for extension in startup_extensions: try: bot.load_extension(extension) except Exception as e: exc = f'{type(e).__name__}: {e}' print(f'Failed to load extension {extension}\n{exc}')

low rivet
#

verify your token aagin

#

if it still fails, regen a token

#

and the bot that's running all these is @slim moss right?

primal adder
#

yep lol