#development
1 messages ยท Page 351 of 1
...assuming you have a variable called promise that's a promise, I guess
wtf are you trying to do
Im creating a promise chain
With functions
The functions have promises inside them'
But as you said
They dont return anything
So im unsure what it needs to return
if they have promises in their bodies, just return the promises right
So I just return the whole code?
what
didn't you just say there is no variable called promise
Yes, there isnt
return whatever you call the variable you've stored the promise in
ahh it's JS
a function isn't a promise
``js
that doesn't even make sense
var Questions1 = () => {
message.guild.fetchMember(message.author.id).then(user => user.send(Question1))
.then(() => {
message.author.dmChannel.awaitMessages(response => response.content, {
max: 1,
time: 30000,
errors: ['time'],
})
.then((collected) => {
message.guild.fetchMember('376147022660632587').then(user => user.send(`${Question1} \n \`\`${collected.first().content}\`\``))
})
.catch(() => {
message.channel.send('There was no collected message that passed the filter within the time limit!');
});
});
}
Oh, okay!
For each function?
Or just the first
I assume each function okay
Because I have 24
...sure
again, I feel like your life would be a lot easier with async/await here
but whatever floats your boat I guess
Thank you good sir
Oh no its not waiting
Urrggg
Also idk how to use async/await >.>
it's never too late to learn
I tried
It makes no sense to me ;-;
Also apparently promises cant wait for other promises
Because i've tried literally everything

I did
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var firstMethod = function() {
var promise = new Promise(function(resolve, reject){
setTimeout(function() {
console.log('first method completed');
resolve({data: '123'});
}, 2000);
});
return promise;
};
var secondMethod = function(someStuff) {
var promise = new Promise(function(resolve, reject){
setTimeout(function() {
console.log('second method completed');
resolve({newData: someStuff.data + ' some more data'});
}, 2000);
});
return promise;
};
var thirdMethod = function(someStuff) {
var promise = new Promise(function(resolve, reject){
setTimeout(function() {
console.log('third method completed');
resolve({result: someStuff.newData});
}, 3000);
});
return promise;
};
firstMethod()
.then(secondMethod)
.then(thirdMethod);
This just looks like it uses Timeouts
I guess I can try it tho
Nope
Didnt work

I've been working at this for literally 6 hours
Im so annoyed
Its so stupid, like why cant they just make something that allows to easily chain promises
promiseFunc1().then(() => promiseFunc2().then(() => promiseFunc3().then(() => { /* ... */ })));
this is why they introduced await/async
this looks garbage
Which emote represents a server best?
@compact scaffold Wdym
Like # denotes channels
I'm adding emotes to a command

Ok
@glossy sand If your up for it, do you think you could show me an example of async/await?
Because that might be the only way to chain promises
async function a() {
// do something asyncronously
}
async function b() {
// do something else async
}
(async function() {
console.log('doing a and b...');
// execute a and wait for completion
await a();
// execute b and wait for completion
await b();
console.log('done!');
})();
Ah!
Yes thats exactly!
Thank you!
So I would do
(async function() {
Questions1()
Questions2()
await Questions1();
await Questions2();
//do something else here
}
async functions always return promises regardless of what you actually return
Oh good
Ah!
Okay!
Ah man this is amazing
This is exactly what I was looking for
Er
I do need the return
Because I got this error
When I have this'
(async function() {
await Questions1();
await Questions2();
await Questions3();
await Questions4();
await Questions5();
})();
I defined them all as async functions
Why is this so complex ;-;
Its saying then isnt a function
This is the code I put into each function
message.guild.fetchMember(message.author.id).then(user => user.send(Question1))
.then(() => {
message.author.dmChannel.awaitMessages(response => response.content, {
max: 1,
time: 30000,
errors: ['time'],
})
.then((collected) => {
message.guild.fetchMember('376147022660632587').then(user => user.send(`${Question1} \n \`\`${collected.first().content}\`\``))
})
.catch(() => {
message.channel.send('There was no collected message that passed the filter within the time limit!');
});
});
It says the first line isnt a function
Which makes no sense
Aaaaaaaaaaaaaa
maybe you missing brackets somewhere?
that could be an issue. I dont code it so i wouldnt know
@icy lynx also it would be cool if the server count example for python conformed to pep ๐
@glacial vale I'm not a pep guy :P
Na
Forgot how my style is called, but it's kinda like php's default style
But without braces :P
lol
@earnest phoenix Oh alright, heres the HTML:
<div id="snow">
</div>```
and here is the CSS:
```css
#snow{
background-image: url('https://raw.githubusercontent.com/Habchy/sethpage/master/s1.png'),
url('https://raw.githubusercontent.com/Habchy/sethpage/master/s2.png'),
url('https://raw.githubusercontent.com/Habchy/sethpage/master/s3.png');
position:absolute;
top:0;
left:0;
bottom:0;
right:0;
height:100%;
width:100%;
z-index:-1;
-webkit-animation: snow 10s linear infinite;
-moz-animation: snow 10s linear infinite;
-ms-animation: snow 10s linear infinite;
animation: snow 10s linear infinite;
}
@keyframes snow {
0% {background-position: 0px 0px, 0px 0px, 0px 0px;}
50% {background-position: 500px 500px, 100px 200px, -100px 150px;}
100% {background-position: 500px 1000px, 200px 400px, -100px 300px;}
}
@-moz-keyframes snow {
0% {background-position: 0px 0px, 0px 0px, 0px 0px;}
50% {background-position: 500px 500px, 100px 200px, -100px 150px;}
100% {background-position: 400px 1000px, 200px 400px, 100px 300px;}
}
@-webkit-keyframes snow {
0% {background-position: 0px 0px, 0px 0px, 0px 0px;}
50% {background-position: 500px 500px, 100px 200px, -100px 150px;}
100% {background-position: 500px 1000px, 200px 400px, -100px 300px;}
}
@-ms-keyframes snow {
0% {background-position: 0px 0px, 0px 0px, 0px 0px;}
50% {background-position: 500px 500px, 100px 200px, -100px 150px;}
100% {background-position: 500px 1000px, 200px 400px, -100px 300px;}
}```
someone go here

I have a problem with my code ;-;
Im using async
But its not running the promises async tho
Its running them at the same time
(async function() {
await Questions1();
await Questions2();
})();
async function Questions2() {
message.author.send(Question2)
.then(() => {
message.author.dmChannel.awaitMessages(response => response.content, {
max: 1,
time: 30000,
errors: ['time'],
})
.then((collected) => {
client.fetchUser('376147022660632587').then(user => user.send(`${Question2} \n \`\`${collected.first().content}\`\``))
})
.catch(() => {
message.author.send('There was no collected message that passed the filter within the time limit!');
});
});
Question1 is the same thing but with the numbers replaced
Im so confused
Does anybody know why it isnt working?
Are you missing a } ?
uh hu
Yes there is a }
Its just now shown
*not
I rlly dont get why this isnt working
It should be running them one after the other
Yet it runs both at the same time
All im legit trying to do
Is run promises in an order
One after the other
It appears awaitMessages is messing it up
@prime cliff ```css
#netneutrality {
display: none;
}
wew
lad
i couldnt figure out why my game was lagging
then i relized
im like
pumping
gigs of data
through 1 socket
lol
(not litteral gigs but a shitload of data)
my poor server:(
๐
Lmao
wew
Error: Cannot find module 'googleapis' googleapis don't work on heroku.. but in pc it works perfect why?
rip
upload the module ยฟยฟ
install the module?
deploy the module
@grim wedge
-bots @north fog
@cold vector
!help
for some reason its not loading my translations
[React Intl] Missing message: "TodoList.Description" for locale: "en"
but its definitely defined
hey
guys
I get an error for cannot send an empty message
but I have a message to send how??
if (message.content === (prefix + "cat")) {
let urlWithSize = randomCat.get({
width: 120,
height: 600
});
message.channel.send(urlWithSize);
message.channel.send("This is a cat link");
message.channel.send("CATS CATS");
}```
Error: OPUS_ENGINE_MISSING there exists a build for this on heroku?
Deni, maybe is the urlWithSize empty
how
maybe it fails to find a result, idk
@EแตแตแตliteDaMyth#3663 use await
i'm guessing randomCat.get returns a promise
await it
@shrewd field
or alternatively, "urlWithSize" probably doesn't return as a string or embed so
var server = servers[message.guild.id];
if (server.dispatcher) {
server.dispatcher.end();
}``` what is wrong with this?.. is skipping 2 songs.
// do something like this instead
switch (option) {
case "skip": return functionName(pass, any, variables)
}
function functionName (pass, any, variables) {
let server = servers[message.guild.id];
if (server.dispatcher) {
server.dispatcher.end();
}
}
aha.. ty
a timeout? 
He probably means using setTimeout() between changing songs. I had the same problem. Damn prism media.
yeah you can put a 1 second timeout
and... how i set ms?..
Seriously please don't they can Google it themselves
i also dont see why a timeout is needed
this is wrong
setTimeout(functionName(pass, any, variables), 1000)
what ken said is nicer, but if you have a single function to call, I would prefer setTimeout(functionName, 1000)
optionally setTimeout(functionName.bind(this), 1000)
arguments?
.bind(null, arg1, arg2)
kek
setTimeout(()=>{
//i prefer putting the function in the timeout cause im lame :(
}, 1000)```
anyone know how to run a node.js file in the backround without being in the terminal 24 / 7?
you can do a nohup node file.js
ctrl + c it
then it kills it
yeah you need to nohup <command> &
so nohup node file.js &
nohup just makes the process ignore sighup
can i do nodemon?
ill try :P
ok
how do i kill the nohup then
@glossy sand i want to stop the nohup, how i do it
er perhaps ps -A | grep node
done thx
yeah tmux is easier tbh
can you help me? i try the server count code:
request({
method: 'POST',
uri: 'https://discordbots.org/api/bots/'+ client.user.id,
headers: {'Authorization':tokens[0]},
json: {"server_count" : client.guilds.size}
});
and it doesn't work
someone please?
what error
@earnest phoenix add /stats to the end of your url
o
no error, just not updating
i don't?
doesn't work
I think it is 'https://discordbots.org/api/bots/'+ client.user.id +'/stats'
i added stats and it didn't work
id is not necessary
there must be some error if it's not updating
no error
haha fixed it, just had to change the token
Ya @earnest phoenix same name somewhat ๐
haha yeah
what is the specific issue you are having
I was unsure what the other developer was encountering but I will try and ask them
@winged osprey
ok so
say i have a banking system for my bot
(discord.net api)
and
i want to make it generate a data bin for every encountered user without a command
how to
I wouldn't recommend that
a public discord bot gets a ton of users
easily racking up to a few hundred thousand
which would flood your storage
ive got the storage space, each file is only ~ 0.1 kb
right i have a server with 1.6 tb
What are you planning to do by storing it?
bank
like there aren't 200million bots that do exactly that + 20 billion more features
shhhhhh
Well, is that bank like a level up system?
a little
hmmm
That's kinda how level-up bots are done
It also stores the time of when the post was made, to avoid spam
ok
xD
message.channel.send("๐ฅ | "+message.author.username+", the help menu has been sent to your PMs");
how can i embed that
create a new RichEmbed object
^
Just wonderinf
And pls use string literals
embed: {
color: 0xff9d00,
title: "BotTuber Help Menu",
author: {```
Why is there an emoji on the code? nvm it's a string
im using that kind of embed
oh
really?
ye
Yep
haven't tried it lol
no u so how can i embed it
channel.send('', embed); iirc
^ lol
I mean
channel.send({embed: embedname});
That works
Or
channel.send({embed}) if the embed is called embed
Haven't tried
Okay so I'm not the kind of person to really be desperate for help, but I might really need some shit explained
So gotta be fair, my database is pretty shit, consisting of 150+ ini files with configparser
So I want to switch to redis, and automatically backup to SQL everyday (but that's not important)
I've written a script that for each file in my database, will write it to redis using a `server_id:setting' approach
But for some reasons, even with the exact same database on my local machine vs the server, the results get completely buggered sometimes
Some settings seem to be perfectly transfered over, whilst others give strange results
For example
So for my migrating script, I use the following code to get a file
for file in os.listdir('.'):
if fnmatch.fnmatch(file, '*.ini'):
config.read(file)
file_name = file.replace(".ini", "")
And to retrieve a file and set it in Redis, I'm using
try:
r.set(name=config['settings']['server_id'] + ":prefix",
value=str(config['settings']['prefix']))
except KeyError as e:
r.set(name=config['settings']['server_id'] + ":prefix", value=";")
This especially seems to occur with non-required values
But when that value does not exist, it should throw a KeyError as configparser would
And set the value to it's default
I have an issue aswell
In my async function
Sometimes things arent running async
Which doesnt make sense
I did
Not everything is a coroutine
Some things are just natively blocking
Im using awaitMessages though
It works in small quantities
And im getting very few hiccups
But im puzzled on why im getting hiccups at all
By hiccups I mean slip-ups when the program runs
What kind of slip-pus?
Well
What it does is
It sends a question
waits for a response
Sends the response somewhere else
And etc
Over and over
But
Sometimes
The questions take their own questions and send them as a response
For example
YEAH
DONT USE PYTHON


anyone got good resources for passportjs or a related authentication system?
@obsidian sleet ๐
๐
if you google "passportjs example", there are a ton of example applications using express, restify, etc.
..
people, I have a problem with a person, he banned me from his server and I want to unban myself via my bot (it's in that guild, yes + it has admin perms) anyone who could help?
D.js? @crystal void
client.guilds.get(id).unban(ur id)
kk, thx โค
You know the server's id?
wait.... I don't have the id
I could get it
when they execute any command, I log the server id to the console ๐
I have the id of one of the channels in the guild
but that wouldn't help
:/
oh... good
:+1:
๐คฆ
@crystal void you sure they didnt remove your bot?
ye
I log everything into console
for now
it might become very bad when it's in 50+ guilds
lool
and now.. @thorny hinge how to delete an invite link via bot, how to execute a command from one server but the result is in another (what I want to do it delete the old invite link my bot created, and from my guild, create a new invite link for that guild (already made a command for creating instant invites))
I mean if u already know how to create invites for ur own server u can easily do
client.guilds.get("jsjsendjdjejd").doYourStuff
@thorny hinge sorry for the 100000 ping, but, how does the bot delete an invite (or all of them)
SSS jumps in...
I would get the invites and then run a loop or something that deletes them
and yeah I jumped in
deal with it
oh.. ๐คฆ
Try looking at the docs sometime ๐
I just don't read
screw reading that's not important
Can someone help me? I'm trying to make a userinfo command but it changes timezone so for me its GMT+0100 but for my bot its GMT+0000.
I want it to only be GMT+0000
And I'm using discord.js
docs
uhhhhhhhh
and lemme go to discord.js.org and start fucking reading
You can't make it GMT+0000 unless you teleport everyone to that timezone
xD
That's going to be hard
Yeah
Idea!
Make it check if the timezone is GMT+0000 and if it isn't, then ignore them!
problem solved, right?
๐คฆ
idk
docs
https://discord.js.org might just help
or CTRL+W and then search for it
yup..

I know ๐
I've looked through every doc type
Not a single one says anything about timezones
thats because you can't search for basics
agreed
this is going to take a while
enjoy
Yeah I guess, my fault
that is up to you
or use ctrl+f
Thank you guys, I found it
np ๐
ใ
Can somoene help with this ```JavaScript
module.js:538
throw err;
^
Error: Cannot find module '/app/bot.js'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Function.Module.runMain (module.js:676:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3```
Im using heruko
the file /app/bot.js doesn't exist
Pretty self explanatory
@hoary sphinx What is the dir of the file you want to access?
(From your main bot folder)
Idk if heruko is trying to aces it
Access*
My bot code dosen't want to access it
The file Bot.js is capitalized, while the file your code was trying to access (bot.js) is not
don't use it in the files
^
Posting here again
I own a website, it shows discord bots on my server. But right now, i have to add them manually. I would want it to add automatically when a bot joins, anyone know?
use a bot that listens to user join events
ok so like
use a bot you have created
for users in the discord check if user has the bot tag
if it does getElementById('your div ele').innerHTML += bot name
if you want to be really cool use sockets so it live updates
lik uh
mainjs```js
//assuming you already have a bot that has a function to fetch all users on discord
let fetch_user_bot = require('fetch_user_bot')
io.on('connection', (socket)=>{
socket.on('get-bots', ()=>{
let bot_array = []
let user_object = fetch_users_bot.fetch() //assuming it returns an object with username:boolean boolean being whether its a bot account or not
for(user in user_object){
if(user_object[user] = true){
bot_array.push(user)
}
}
socket.emit('bot_user_list', bot_array)
})
})```
something like that
if you want help setting up something like that dm me babe
fair
just an example for babe
i have a firm belief that sockets are the future
lol
var should be executed
let and const reign supreme
anyone know good resources for theming other then bootstrap/bootswatch
something similar
nah
i just use bootstrap
yea i guess
i have this horrilbe habbit on templating out all my programs or sites in ms paint
apposed to something more usefull like photoshop
i dont have money for photoshop
and its not needed for me
im about to publish the most advanced node library ever
bam
most advanced library
ever
most advanced mathmatics library ever
now hold up
watch this
Major update 2.0 out now @tawny lava
its a trick
you see
if you trick them into thinking its subtraction
it's still + wew
amazing
and i will be payed more then i should be
V2.1 out https://i.imgur.com/eCGxunR.png minor bug fixes
you might want to consider parseFloat
Do you know how i can show this
https://cdn.discordapp.com/attachments/346060603233796108/391697957608620032/unknown.png
Only the servers
i need to add that to my site
that looks like the wrong site 
kek
I need something like that ๐ @bitter sundial but indeed its the wrong site ๐
-bots @steel shoal
@simple hinge
-botinfo @simple hinge
its still muted
do you mean
you want to have your servers shown on this website?
yes pleas
i take a look thx
i did't know that
and you must know how i can and the status (online) to an server
@bitter sundial sorry for the tag...
wwhat do you mean
i know now how i can add the server count but the online butten thatc cool
that page already has that
go and edit your bot and scroll down ๐
i share the site
no need
you see the thing at the bottom of the edit?
hmm where?
go to your bot page https://discordbots.org/bot/348187123536494592
log in if you aren't
and click edit
and scroll down
wot
Get the complete details on Unicode character U+037E on FileFormat.Info
its not a semicolon
it iwll error out the code
i spent thousands of hours and im proudly introducing
my new math library
lol
https://i.imgur.com/GrjRBbR.png fixed the brackets and formatting
lol
hek
what the fuck
that indentation is probably the worst part
also, I don't think ^ is a thing in JS
you'll want Math.pow or **
OH GOD WHAT THE FUCK IS THAT BRACKET INDENTATION
hey
hi
yall making fun of my 1337 library indentation
how dare u
would u rather me write it on one line
everyone knows all your brackets go 5 tabs in
and your semi colons go on the next line
do you even code? its pretty obvious you write code in jsfuck and convert it to practical js
quality
Beautiful
the most beutiful is that one shakespearean code
http://shakespearelang.sourceforge.net/report/shakespeare/ the worst thin gi have ever seen
@tawny lava this is the hello world http://shakespearelang.sourceforge.net/report/shakespeare/#SECTION00091000000000000000
What the fuck
or you could go with the more modern http://www.emojicode.org/ for millenials
code entirely wrwitten in emojis
Some people have too much time on their hands
i mean all i see these as are a bunch of #defines
tbh
i make sure to convert all my code to jsfuck before i publish to github
Very good idea I'm gonna start doing that
msg.channel.send("this is invalid code")อพ
wanna know why
the "อพ" i used is a greek question mark!!!
I want to put Python code what are the bugs that I need but I do not want Red Bot
^
oh
and why am i in this channel how did i get here
lol
my razer synapse be fucked
same lol
trash software
my mouse isn't displaying any colors and the app doesn't open
hello
Uncaught Promise Error: TypeError: Cannot convert undefined or null to object
I have this error can someone help
Thanks
Something is undefined ofc
@here any devs willing to help meh?
Nice fake ponk
Can someone give me a CSS style for the discordbots bot page?
help
It can't open launcher.py
looks like there's no such file or directory
why
Yeah
but that's a guess
What is the solution
I have installed all the files
Yeah, launcher.py isn't doesn't exist
What is the solution
Read redbot docs
Make a file called launcher.py?
yes
AHHH REDBOT
can i get help please?
wuts wrong with this
}
if (msg.startsWith( prefix + 'SCAM ' + arg[1])) {
let scammer = args[0];
let reason = args[1];
const embed = new Discord.RichEmbed()
.setTitle('Scamming')
.setDescription('Reported By:' + message.author.tag)
.addField('Reason:', "${reason}")
.addField('Scammer:', "${scammer}")
.setColor(0x52c7d3)
message.channel.send(embed);
}
scam?
yeh

its for my server
What lang/lib is that?
ScamLib
java
is node.js
how
What's the error?
Try debug it :3
what is the issue
wut exactly am I trying to do
ok
K
Are we allowed to steal copy CSS code from other botpages ๐
I guess
yep
it's implicitly copyrighted
unless dbl has some weird ToS clause that says otherwise
theres no rule that says you can't copy it
I think the DMCA counts as a "rule"
and you can't just say ey this css is mine, it may happen how people would write the exact same css on accident
Indeed, it depends who owns the CSS once set. User or discordbots?
discordbots
wtf do you mean I can't
what if I accidentally rewrote the entirety of windows 10 from scratch
that doesn't stop microsoft from copyrighting their code
By using this website, you agree to give up your right to pursue legal action against www.discordbots.org or any of its affiliates, sponsors, partners, staff or entities.
wut
All material on www.discordbots.org is the sole property of www.discordbots.org , with some exceptions, including bot avatars, bot names, bot owner names, usernames of users of services provided by www.discordbots.org , and other user submitted content.
Meaning discordbots doesn't own user-submitted CSS
@fervent goblet Can you give me the necessary code to install Python on the Ubuntu system

๐ด๐ด
๐ฑ๐ช
๐
I'm sure an apt-get install python should be sufficient
Yeah google it
apt-get install python3 whatever
hm how run bot py
Any python developer who wants to collaborate on a new project? DM me if interested
python somePythonFile.py
or python3 somePythonFile.py I suppose
python3 file.py
@fervent goblet Actually I'm not English
maffie did you know you can help people without insulting them every 20 seconds?
well if I'm going to be honest you're an ahole
Also, it might be that you have an older version, use sudo apt-get update and sudo apt-get upgrade
but you're not going to catch me saying that offhand
how sweet of yo
Any python developer who wants to collaborate on a new project? DM me if interested
that looks better
Nice
@fervent goblet i would but im already working on my Snowflake bot
you can work on multiple
hmm
i have a host called glitch which i use for my bot and my website, but they are in different projects, now i want to get the post count from my bot to my website, how do i do this?
GET /api/bots/:idย - Get info of a certain bot
i'm not trying to get info from this website
i'm trying to get my bot's server count to MY website
If you use their API to add your bot's server count to their website, you can use their API to get the srrvercount to your website
isn't their api is for their website?
No you can use it for anything
oh, how so?
request({
method: 'POST',
uri: `https://discordbots.org/api/bots/${client.user.id}/stats`,
headers: {'Authorization':process.env.SERVER_COUNT1},
json: {"server_count" : client.guilds.size}
});
how can i do something like this to my website?
Pretty much all bot list sites have an API and i use all of them in my bot p/getbot
so how do i use this api on my website, example would be nice, because i have no idea
?
@brisk notch ```css
#bot-img>.bot-img>img {
border-radius: 50%;
animation-name: icon;
animation-duration: 3s;
animation-iteration-count: infinite;
animation-timing-function: ease-in-out;
}
@keyframes icon {
0% {
transform: translate(0, 0);
}
50% {
transform: translate(0, -20px);
}
100% {
transform: translate(0, 0);
}
}

thats how you do the css animations
let me try
@trim steppe am I in trouble o.o
Can I ask why is my bot subtracting wrong. I did parseInt(a) - parseInt(b)
its the correct value
ignore bot messages
how do I do that lol?
Hi is someone here a Discord.js god?
show codeee
I mean presumably you're trying to call split() on an undefined variable
maybe you mistyped something?
message.content.split(/[ ]/).slice(1).join(" ");
?
fixed @trim steppe
๐
@hallow wing
@client.event
async def on_message(message):
if message.author == client.user:
return
else:
do_command_handling_here()
or simplified
@client.event
async def on_message(message):
if message.author != client.user:
do_command_handling_here()
That's for looping
aexit means that the async code was closed, is your aiohttp being run in an async function?
So ```python
async def thing(arg):
pass
instead of
def thing(arg):
pass
yea
Can you send the code segment around line 1975?
async def on_ready(self):
token = 'censored'
post = {
'server_count': len(self.servers)
}
headers = {
'Authorization': token
}
url = 'https://bots.discord.pw/api/bots/366772786573869058/stats'
async with aiohttp.ClientSession as session:
resp = await session.post(url, data=post, headers=headers)
resp.close()
dbltoken = "censored"
url = "https://discordbots.org/api/bots/" + bot.user.id + "/stats"
headers = {"Authorization" : dbltoken}
payload = {"server_count" : len(bot.servers)}
async with aiohttp.ClientSession() as aioclient:
await aioclient.post(url, data=payload, headers=headers)
resp.close()```
ah
Okay first things first
Don't make new sessions
Just do at the bottom
async with aiohttp.ClientSession() as aioclient:
await aioclient.post(url, data=json.dumps(payload), headers=headers) as pw_resp:
pass
await aioclient.post(url2, data=json.dumps(payload2), headers=headers2) as dbl_resp:
pass
You can check my aiohttp example on #312614469819826177
Don't forget to import json and rename your headers for dbl.org to headers2, payload to payload2 and url to url2
Sorry bugs fixed
ty
To send the initial payload if you have to reboot your bot?
I use it in on_ready, on_guild_update and on_guild_remove
Ye
If it's open source and you do a forgetti moms spaghetti you're fucked
๐
can just regen a new token
Better safe than sorry
That's more work than just doing the right thing anyway
Exactly, I just use my test config locally and when I upload it it doesn't matter since it now uses the config on my server
lol
help
You forgot sudo
how
ok
It will prompt for your password
oh fuck maybe I should make it class Database instead of def Database
jeez
not the only mistake in all that code
fortunately I only wrote 200 lines yesterday
it was at 11pm
or I'd have 2000 issues to solve
Whats the difference between redis.Redis and redis.StrictRedis
not sure, but I think that one is more strict then the other (think like types)
@fervent goblet
In addition to the changes above, the Redis class, a subclass of StrictRedis, overrides several other commands to provide backwards compatibility with older versions of redis-py:
LREM: Order of num and value arguments reversed such that 'num' can provide a default value of zero.
ZADD: Redis specifies the score argument before value. These were swapped accidentally when being implemented and not discovered until after people were already using it. The Redis class expects *args in the form of: name1, score1, name2, score2, ...
SETEX: Order of time and value arguments reversed.
So you should stick to Redis class if you have used redis-py for a long time - it has some commands' argument's order changed to seem more Pythonic (or even by accident). ```
@fervent goblet took that from here V
https://github.com/andymccurdy/redis-py#api-reference
StrictRedis you ain't gonna need XD
hm I tried decode_responses while initializing the redis class
but apparently I need to do it while initializing the connection pool
why do we even use : in redis
because of basic py functions that have the same name
oh now I see
The colons have been in earlier redis versions as a concept for storing namespaced data. In early versions redis supported only strings, if you wanted to store the email and the age of 'bob' you had to store it all as a string, so colons were used:
SET user:bob:email bob@example.com
SET user:bob:age 31
yeah
nice

