#development
1 messages ยท Page 1145 of 1
Just generate a uuid and set it as the cookie's value and as the document's sessionId key
the document's sessionId key
the what
res.cookie('sessionID', ses, {secure: true, httpOnly: true})
cooki
(ses is uuid)
let ses = session()
console.log(user.id)
console.log(ses)
let thisSession = await UserSession.findOne({ userID: user.id })
if (!thisSession) {
let sessionDoc = new UserSession({ userID: user.id, sessionID: ses })
console.log(sessionDoc)
} else {
thisSession.updateOne({ sessionID: ses })
}
```update i assume this is good (after i set cookei)
looks good
and then on my /home i can get the userID by a UserSession query and then findOne of my User schema and display necessary info when needed
@quartz kindle are you busy by any chance?
exactly!
owo
res.cookie('sessionID', ses, { secure: true, httpOnly: true })
res.status(301).redirect('/home')
i assume this is good
Hello Iโm looking for someone who knows how to make a RCON like discord webhook bot so I can control my mcpe server from discord
its fine, it is still development related
you're just less likely to find help here, since this is a bot list
ugh fml
i'll ask just in case
its crashing when PRIVMSG is being emitted
index referencing the same chat instance
anyone got any idea why 2 listeners is causing the emitter to error?
when i do console.log(req.cookies) it logs as undefined
@pure lion are you using express?
try using the cookie-parser middleware
i think you can just do app.use(require('cookie-parser')());
lmao awesome
dont ask to ask
also i need help too, can i use the client to fetch users that it doesnt share any guilds with?

yep
If your making a bot just to get the badge, probably won't ever get the badge
not for that only
you'll need to worry about discord's developer privacy stuff tho
lol
a guy dont have a phone number and wants to talk here
he dmed me
@west shard
him
Probably should buy nitro then.
for your bot to get a verified bot badge, you must make a bot, have it in 75 or more guilds, and then get discord to verify it
what if you make fake servers?*
You get rejected
res.render('home.ejs', { user: client.users.fetch(findUser.userID).username || 'User not found' });
```it always renders as undefined
@opal plank that happens if you have 2 listeners to PRIVMSG?
whats the url for getting discord avatars?
Discord developer docs covers all that
you're using discord.js, right?
@quartz kindle indeed, as soon as theres a new message it crashes
i spent the past 2h trying to figure out whats happening
have you tried not adding something to the message object you get from it?
ngl, i gave up
i have not
lemme give that a try rq
it might break a ton of stuff though
<span class="bot-name">
Discord Bot List
</span>
</p>
<p class="bot-description">```
@quartz kindle yeah that was error'ing, though its still not getting it though
yep, still crashes

even with nothing attached to message?
indeed
im gonna log message rq just to triple check
definetly nothing attached
full error if it helps
i see command: in the bottom though im unsure if its related
what are you doing?
me? trying to listen to an event outside of the index
though it crashes once its emitted
its not even that small of a lib to be doing this shitty thing
Bot list ever nearing completion uwu
and literally the only difference is an extra .on("PRIVMSG")?
that is suppose to be the event name
I tried to include kick in my anti spam detection
if(message.member.kickable) {
message.member.kick({reason:"spamer"})
return
It doesnt work. It doesnt react and there is no error with try and catch
๐ค
...on("PRIVMSG", message => {
client.emit("MYMESSAGEHA",JSON.parse(JSON.stringify(message)))
})
lmao
can i do that? 
i was thinking of re-emitting
but that looks like one hell of a bad idea
re-emitting under the same event is probably a bad idea
but making a new event should be less bad
how to make this type embed
yeah, if you use a new event it's different so it doesnt loop
then listen of that new event under collector?
@faint zenith that's just markdown
like the black background and the number color
i cba
async def on_member_join(ctx, wgrole, member):
with open('wrole.json', 'r') as f:
wrole = json.load(f)
role = discord.utils.get(member.server.roles, id=f"{wgrole}")
await client.add_roles(member, role)```
its giving me errors
missing 2 required positional arguments: 'wgrole' and 'member'
@quartz kindle i'll give it a try, ty tim
why are you putting an ID in a string
so, i recently swapped to everything being in its own modules.
my mysql stuff is still in my index, with the stuff that handles disconnects.
previously, everything worked fine, if mysql disconnects, it reconnects no problem.
now, if mysql disconnects the bot crashes with a
Error: Cannot enqueue Query after fatal error.
https://hastebin.com/gihegomedo.js
^ mysql connection in index.
^ CON is a var, typed let whoops
but i already had the code
Remove ctx parameter
alsoooooooo........................
is that discord.py 0.16.12
how do i checl?
Why is there member.server
i got that from interwebs
smh
i had most of it
Advice for the future: don't just copy paste everything
i know
I copy code and it dont work, now what :(
it's wrong.
wow, i didnt know that
https://discordapp.com/channels/264445053596991498/272764566411149314/742864432601890867 i wish i could answer but idk mysql
I copy code and it dont work, now what :(
@amber fractal lmaoo
but yeah, to fix the error ITSELF,
Remove
ctxparameter
why you shouldn't and can't use json as a database:
- you're writing to a file. it isn't and doesn't support async, you can't do two operations on the same file at the same or close to the same time.
- it's a file, it's size will buff up to very huge sizes in a very shot timespan
- it's lacking with data types
- it has strict formatting rules, mess up one character and your ""database"" is invalidated
:pogu:
Anything that isn't a command doesn't have a ctx
o ook
async def on_member_join(wgrole, member):
with open('wrole.json', 'r') as f:
wrole = json.load(f)
role = discord.utils.get(member.add_roles('{wgrole}')
await client.add_roles(member, role)```
Oops
i know
i have a feeling ill have to make a connection in each module if i can figure it out, which isnt the best, but its not the end of the world
i ami
๐คทโโ๏ธ
u jsut had the code on hand
so ill use it for now
i alreadt started making the table
way
bruh i might learn py
so super wrong?
literally nothing you did was correct
well

apart from removing ctx
async def on_member_join(wgrole, member): with open('wrole.json', 'r') as f: wrole = json.load(f) role = discord.utils.get(member.add_roles('{wgrole}') await client.add_roles(member, role)```
role = discord.utils.get(member.add_roles('{wgrole}') this will not make sense, as you could've seen previously
on_member_join
member.add_roles('{wgrole}')
NameError: name 'member' is not defined
client.add_roles(member, role) you were supposed to edit this with member.add_roles stuff
async def on_member_join(wgrole, member):
with open('wrole.json', 'r') as f:
wrole = json.load(f)
member.add_roles('{wgrole}')
await client.add_roles(member, role)```
ppph
yeah right
oooh
what's wgrole
role to give upon welcome
so it's not a parameter
no
it's a variable you will create
so remove wgrole from function parameters
d.py only passes one parameter, which is supposed to be saved under member
async def on_member_join(member):
with open('wrole.json', 'r') as f:
wrole = json.load(f)
client.add_roles(member.add_roles('{wgrole}')
await client.add_roles(member, role)```
yes?
or no
How do you manage to fix one thing and break the rest even worse
where did I tell you to replace discord.utils.get with anything?
what's the full line
role = discord.utils.get(client.add_roles(member.add_roles('{wgrole}'))
....
๐ฉ
to no surprise
scroll up to your first code snippet and copy the line from there
scroll up
not "send your code"
role = discord.utils.get(member.server.roles, id=f"{wgrole}")
yes but replace server with guild and don't put wgrole in a string
const EventEmitter = require('events'),
collector = new EventEmitter();
client.collector = collector;
chat.on('PRIVMSG', (message) => {
message.chat = chat;
client.collector.emit('COLLECTOR', JSON.parse(JSON.stringify(message)));
});
``` crashes
await client.change_presence(game=discord.Game(name="on " + str(len(client.servers)) + " Servers.", type=0))
AttributeError: 'Bot' object has no attribute 'servers' how do i fix this?
ty
wait
so where do i put wgrole?
role = discord.utils.get(member.guild.roles, id=f"{wgrole}")
thats what i have
the role the bot gives
wgrole is the ID?
yes'
>>> my_id = 1234
>>> f"{my_id}"
'1234'
>>> my_id
1234
let's take a step back and think logically
ok
and what does just doing my_id return? A string or an integer?
int
if you want to add it, add it after cloning
so how do you pass wgrole as an argument to id=?
lemme give that a try
pretty much
that would error out
oh ye
>>> {yeet} = 1
File "<stdin>", line 1
SyntaxError: cannot assign to set display
bc you cant start with {}?
still nothing
though tbh it did emit it without issues this time, but when listening to it, it crashed
not like that lul
that'd just say "assign value under variable wgrole to variable wgrole"
how come?
which... doesn't do anything
the other way
the left part is where you are assigning something
the right part is what you assign
wgrole[strblabla- = wrole?
let clone = JSON.parse(JSON.stringify(message))
clone.chat = chat
client.collector.emit("COLLECTOR",clone)
Discord what the fuck
role = discord.utils.get(member.guild.roles, id=f"wgrole")
AttributeError: 'Member' object has no attribute 'server'
1 sec
nope
no
ill restart all instances
JSON.parse(JSON.stringify(object)) is a deep clone
a?
it will leave the original object untouched
aight, lets give that a try
id=wgrole, without any quote marks
you dont want to touch message, since its apparently crashing the lib
so you clone it, and then do your stuff to the clone
then that should work:
role = discord.utils.get(member.guild.roles, id=wgrole)
NameError: name 'wgrole' is not defined
same error
how are you defining wgrole
role = discord.utils.get(member.guild.roles, id=wgrole)
i technically dont need chat referenced in the clone since its only used in the collector
member.add_roles(role)
same error, even cloning
gimme 5 then, i gotta patch a couple commands
cuz ive been referencing almost everything in message
do the same, but with the cloned object instead
like whats your starting point? where is the message first received?
clone it there, then add chat to the clone, and send the clone forward to the rest of your code, instead of sending message
that is where the message is recieved
async def on_member_join(member):
with open('wrole.json', 'r') as f:
wrole = json.load(f)
role = discord.utils.get(member.guild.roles, id=wgrole)
await client.add_roles(role)```
on the index
so this?
client.on('PRIVMSG') is where message is created
i dont touch it anywhere else, i just append chat onto it, which contains client which contains a lot of jazz
just do this
.on("PRIVMSG", bad => {
let message = JSON.parse(JSON.stringify(bad))
message.chat = chat
...
})
im passing chat separated now
thats what im saying, dont pass message
pass the clone instead
make the original message die there
use the clone for everything
yes
well idk then
does it still happen if you just console.log it and do nothing else?
everything i tried thus far just lead to the same error
nah, it ONLY happens when its emitted
actually
not even
only when its listened to
this works
remove the two // and it doesnt
once the event is listened under collector it crashes
even added collector onto client to make sure it wasnt messing with it
collector is your own code right?
yes, this bit
const EventEmitter = require('events'),
collector = new EventEmitter();
client.collector = collector;
chat.on('PRIVMSG', (message) => {
message.chat = chat;
client.collector.emit('COLLECTOR', JSON.parse(JSON.stringify(message)));
});```
theres a lot of stuff in between but thats the collector bit
now i switched to the bad as you said to deep clone
nah thats before you told me to change
lemme get whats actually there now
const EventEmitter = require('events'),
collector = new EventEmitter();
client.collector = collector;
chat.client = client;
chat.on('PRIVMSG', (bad) => {
let message = JSON.parse(JSON.stringify(bad));
client.collector.emit('COLLECTOR', message);
message.chat = chat;
client.globals.get('global').execute(message, chat);
});
this is whats currently there
regarding the index on collector
function collector(filter, timer) {
return new Promise((resolve) => {
let collection = new Map();
let handler = (message) => {
console.log(message);
if (filter(message)) {
collection.set(message.id, message);
}
};
chat.client.collector.on('COLLECTOR', handler);
setTimeout(() => {
message.chat.client.removeEventListener('COLLECTOR', handler);
resolve(collection);
}, timer);
});
}
const filter = (m) => {
m.content.length > 1;
};
console.log(await collector(filter, 5000));
``` this is the collector
forgot to mention, client is attached to chat, which is attached to message up there fixed it
this error is not making any sense
twitch-js is written in ts from what I can see
does it still happen if you remove all 3 lines except the first?
I cant actually find the lib
lemme check
https://oliy.is-just-a.dev/doi4b_5573.png build error tho 
remove emitter, listener and what else?
chat.on('PRIVMSG', (bad) => {
let message = JSON.parse(JSON.stringify(bad));
// client.collector.emit('COLLECTOR', message);
// message.chat = chat;
// client.globals.get('global').execute(message, chat);
});
like this
but this i expected
that in itself doesnt crash it
im assuming its something when it listens to event. if i enable all those lines but comment out the listened on collector it wont crash either
thats from a timeout right?
async def on_member_join (member):
with open('wrole.json', 'r') as f:
wrole = json.load(f)
role = discord.utils.get(member.guild.roles, id=wgrole)
await client.add_roles(role)```
from waiting for the collector
remove the message from there
there is no message inside the collector timeout
chat.client.collector
my bad
same deal
chat definetly being sent over
im not quite sure i understand why that is there tbh
wouldnt it just be smarter to void the emitted events?
lemme dm you then
how much time can bots change their status in 60 seconds? what is the limit
There's no real limit defined, but last time I checked (months or a year ago), it was around once per 12 seconds. You should set it to something reasonable, like 1 or 2 times per minute.
thanks.
the least u can do is like every 5 or 10s
async def on_member_join (member):
with open('wrole.json', 'r') as f:
wrole = json.load(f)
role = discord.utils.get(member.guild.roles, id=wgrole)
await client.add_roles(role)```
wgrole not defined
You need to define it
how tho @honest perch
By defining it
What is the ID exactly. A user iD?
Are you using the command framework. And you should care about the docs
The docs will be your best friend.
ye command
Link them to docs 
Is the ID supposed to be you or just anyone you pick
doesnt care about docs? then why should we care about your questions ๐ค
me
You may be looking for a Check https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#checks
TypeError: str.replace is not a function
Its not a function
it is..
Thats what i dont know
then log it
Did you define a variable called str?
no
Okay, look at the stacktrace and go to where it points and you'll probably find where .replace(...) is coming from
probably should start with that.
will substring do
You should first know what it is
Yeah I know that part but the first priority should be solving the error by inspecting where the error is coming from. You can then decide if you need substring instead
can you share some of your code
Yeah
if (!phrase) return null;
phrase = Util.cleanContent(phrase.toLowerCase(), message);
const tag = await Tags.findOne({
where: {
guildID: message.guild.id,
[Op.or]: [
{ name: phrase },
{ aliases: { [Op.contains]: [phrase] } }
]
}
});
return tag ? null : phrase;```
this is one of the args
if (!phrase) phrase = '';
phrase = Util.cleanContent(message, phrase);
if (message.attachments.first()) phrase += `\n${message.attachments.first().url}`;
return phrase || null;``` this si that other
is replace possibly coming from Util.cleanContent()?
why do you have phrase,message on one and message,phrase on the other?
yeah that's probably the issue
if you inspect the code as well the first argument is being .replace(...)'d
nope its not it
wait
i forgot to restart
i think its message, phrase
nope
it worked
thank you

I'm currently in the process of creating a service called ForgeDiscord, and I have a question: "If you could see a plugin that is quick to install and that updates itself, and that makes the Discord experience endless, would you download?"
Everyone will have their own answers. For me, it depends on what it does.
sounds like client mods
it allows the creation of html element with a simple function (function which can be deactivated by the user because it is dangerous), and flawless functions which allow to create 2d or 3d games for the craziest. Alerts, notification like on the phone. And too much more.
currently I only do security because this kind of service has a lot of flaws
I works 10hours per day for this
sounds like client mods again 
Its possible with html element
(sounds)
how would i return this into a embed?
Create a while
Or includes this in description ?
(Of embed sure)
yes
just send request and get the body?
idk how lol
@client.command()
async def scan(ctx, host):
r = requests.get(f'https://api.hackertarget.com/nmap/?q={host}')
this is what i have so far
can i do like
if bla bla = true
or bla bla = true
say hi
else say no

not nearly done(will be making a canvas eventually), but its playable battleship
a = 200
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
else:
print("a is greater than b")
literally use or
...
else:
...
you should probably learn some python before doing a bot
imagine a bunch of js devs answering python devs questions
@welcome.command()
if @commands.has_any_role("adminperms","welcomeperms") or @commands.has_permissions(manage_messages=True)
?
the or doesnt seem to work
that looks not right
no, it doesnt
Im pretty sure that this is copy pasted code, i saw that before
https://oliy.is-just-a.dev/7vfa6_5574.png has_any_role is a decorator (or whatever they're called in python)
it's not something you can use in an if statement
it says if is invalid syntax
when you did it yourself why dont you know if it will work or not?
because it is invalid syntax
seems sus
@welcome.command()
if @commands.has_any_role("adminperms","welcomeperms") or has_permissions(manage_messages=True)
thats the benning
yea it is
Yeah you cant just put an if for decorators
so i would do or has permission?
like im lost
I tried python for a school project some years ago, but idk how it works probably
idk how d.py works, you'd probably have to put it in the command itself if you want to do that
ive been learning because of this channel
just send request and get the body?
@steel heath how
people ask questions that are super quick google searches
stackoverflow intensifies
^ pretty much
that just seems like more of a thing you'd want to actually put in the command itself instead. Idk if you can do ors for decorators
i forgot how to save guild settings
depends on the lib
What guild settings?
@steel heath how
@earnest phoenix don't really know that much about python, try google
use a database
should be the same way
@modern sable
oi
@magic night why did you randomly send that channel?
smh
agreed
people are something in 2020
bruh it's a fortnite channel
how would i return this response into an embed (asking again as i got no answer)
this si what I get for wanting to develop today https://cdn.if6-dev.tk/images/Code_Jy4mnlUDod 
send the link @quartz kindle
So i've made a few functions, but when the parameters are 0, they come out as false and trigger the if statement which leads to saying, no parameter was provided, how's possible to prevent this from happening?
depends what type the parameter accepts
Both parameters must accept a number
But when one of them is 0 it counts like that parameter doesn't exist for some reason
if(isNaN(number)) throw ...
if it needs to be integers, then
if(!Number.isInteger(number)) throw ...
if you have somewhere if(number) or if(!number), then 0 does count as false
How can i find
Oh
you need to catch your promises
otherwise its hard to find the origin
is there nothing in the stack? show the full error
its a discordapierror
[UNHANDLED REJECTION] 404: Not Found || DiscordAPIError: 404: Not Found
at RequestHandler.execute (C:\Users\sadie\OneDrive\Desktop\Dummy\node_modules\discord.js\src\rest\RequestHandler.js:170:25)
at runMicrotasks (<anonymous>)
dont mind
onedrive
quick heads up if you are responding to a question ping me
yeah you need to catch them
how?
process.on('unhandledRejection', err => {
Logger.error(`[UNHANDLED REJECTION] ${err.message} || ${err.stack}`);
});
thats my current code
all discord.js methods that interact with the rest api return promises, and these promises need to be caught
for example
message.channel.send("bla") // bad
message.channel.send("bla").catch(console.error) // good
same with .edit(), .add(), .remove(), .ban(), .fetch(), etc...
but i know its an event
you need to do this for everything
you need to review your code and properly handle promises
cant i use try
for example this happens if you try to fetch a user and give undefined as id
you can use try catch with await
try {
await message.channel.send("bla");
} catch(e) {
console.log(e)
}
if you dont use await, the try-catch doesnt work
i thought there was code inspectors?
the error code isnt effecting anything i can see
i try make an comand show your image with a text but dont working
but well see
because a promise is basically a function in a limbo,
code:
if you dont await or catch, when the error happens the promise doesnt know what it belongs to anymore, its lost in limbo
it doesnt know where it came from
@bitter carbon in discord.js v12 avatarURL is a function
@bitter carbon in discord.js v12 avatarURL is a function
@quartz kindle ok
@bitter carbon in discord.js v12 avatarURL is a function
@quartz kindle now its another erro
displayAvatarURL is also a function
@quartz kindle faster way?
oh thank you Tim you helped me indirectly, try{} catch{} wasn't working, couldn't figure out why, then i realized that i wasn't using await
how do i define a guild in the message its being set in?
discord.js bot.guilds.cache.get('Server ID').send('Message')
discord.py: bot.get_guild(Server ID).send('Message')
python @karmic compass
then look at discord.py above
cool
TheCatAPI 
does anyone have any good resources I can use to learn mongo?
imo youtube videos dont really teach you much
they're mostly copy this, paste this
unless you have a good video (which is basically what im asking for)
Catgirl API > CatAPI @ionic dawn
Flask if in Python @earnest phoenix
ยฏ_(ใ)_/ยฏ
?
does anyone have any good resources I can use to learn mongo?
:(
I mean, there is a Learn section on the front page of the MongoDB site: https://www.mongodb.com/what-is-mongodb
MongoDB is a document database with the scalability and flexibility that you want with the querying and indexing that you need.
okay
does anyone have any good resources I can use to learn mongo?
w3schools also
heeeyo
any database or any other external thing?
The thing I would have done is a Linux socket that your bot creates and your website can connect to
May be located at /tmp/yourBotName.socket for instance
or a normal TCP server on any port
or even easier, create an HTTP server in your bot itself that will be served as an API
last section pls
Your main website would be example.org
and your api api.example.org
i need urgent help
i mean there a lot of ways to do this anyway
plesse my bot won't go
@delicate shore what
at WebSocketManager.destroy (/rbd/pnpm-volume/d627e943-fbaa-4cab-abab-a4178d6f915d/node_modules/.registry.npmjs.org/discord.js/12.2.0/node_modules/discord.js/src/client/websocket/WebSocketManager.js:335:54)
at Client.destroy (/rbd/pnpm-volume/d627e943-fbaa-4cab-abab-a4178d6f915d/node_modules/.registry.npmjs.org/discord.js/12.2.0/node_modules/discord.js/src/client/Client.js:235:13)
at Client.login (/rbd/pnpm-volume/d627e943-fbaa-4cab-abab-a4178d6f915d/node_modules/.registry.npmjs.org/discord.js/12.2.0/node_modules/discord.js/src/client/Client.js:224:12)
at processTicksAndRejections (internal/process/task_queues.js:88:5)
(node:4310) UnhandledPromiseRejectionWarning: Response: Bad Gateway
at RequestHandler.execute (/rbd/pnpm-volume/d627e943-fbaa-4cab-abab-a4178d6f915d/node_modules/.registry.npmjs.org/discord.js/12.2.0/node_modules/discord.js/src/rest/RequestHandler.js:158:11)
at processTicksAndRejections (internal/process/task_queues.js:88:5)
(node:4310) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:4310) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
My bot isn't going uP!
"MANAGER_DESTROYED" dang
means?
?
enable-pnpm
what
@paper cliff i have no idea about create a api or like something
do you have any example
dk
@quartz kindle thank you
const Discord // ...
const bot // ...
// ...
const express = require('express')
const api = express()
api.get('/server_count', (req, res) => {
res.end(bot.guilds.cache.size.toString())
})
api.get('/user_count', (req, res) => {
res.end(bot.users.cache.size.toString())
})```
It's pretty simple actually
Like I said you can implement that in a lot of ways
@earnest phoenix ^
@paper cliff what should i do
wait a min
i did
what is your thing enable-pmnp,?
what
(node:4310) UnhandledPromiseRejectionWarning: Response: Bad Gateway
you sure you didn't break anything?
yo @paper cliff i cloned my project into new one on glitch and it's online now
lol
I would suggest using a rendering engine if you are building a complete website and not just an API, @earnest phoenix.
The author says this did not work for them. Contd. from private messages...
sorry for private
I meant that they're using the wrong variable
in the routing functions
should be client instead of bot
XD
wait what
const express = require("express");
const app = express();
const Discord = require("discord.js");
const client = new Discord.Client();
app.get("/server_count", (req, res) => {
res.json({"online": client.guilds.cache.size});
});```
https://discordonline.glitch.me/server_count
This can be previewed here.
we created new subdomain
we can't do it into main.js
we need login with token and post it to website
Air
for some reason idk why i made a bot which is kind of useless but no body has made it either
so uh im thes 1st one
ignore the styling as i cba to make bootstrap look nice but ๐
my own version of discord's dev portal in progress for my own app
damn neat

Looks neat!
ty
and it's fully functional ofc
all oauth2 apps loaded from the db, login is done using the oauth2 api i made w/ client_credentials flow
What rendering engine do you happen to use?
ejs, nothing fancy as its just a test run
why my wifi is so slowww ddadsfafa
EJS is very powerful. It can handle production builds too.
can't handle my final production app sadly, gonna use nuxt for that probably
because i like the smooth page loads
yeee
Oh. Well.
const express = require("express");
const app = express();
const Discord = require("discord.js");
const client = new Discord.Client();
app.get("/server_count", (req, res) => {
res.json({"online": client.guilds.cache.size});
});
client.login(process.env.token);
const listener = app.listen(3000, () => {
console.log("Online on " + listener.address().port);
});
Here is the complete code.
@earnest phoenix ^
https://glitch.com/~discordonline
Or just remix it.
Using JSON there is unecessary
Don't recommend him to use a redenring engine for an API (like wtf?)
That code looks weird
I would suggest using a rendering engine if you are building a complete website and not just an API, @earnest phoenix.
@still cliff
Read messages properly, @paper cliff.
if you are building a complete website and not just an API
/*
requires the following modules:
express, discord.js, helmet, compression
*/
const express = require('express');
const { Client } = require('discord.js');
let ready = false;
let port = 80; // change to modify port
const app = express();
const client = new Client();
app.use(express.json());
// adds a few extras to make it more safe
app.use(require('helmet')());
app.use(require('compression')());
client.on('ready', () => {
// make the api ready
ready = true;
console.log(`Connected to Discord`);
});
app.get('/servers', (req, res) => {
// error if not ready yet
if (!ready) return res.status(500).json({ error: 'Not connected to Discord yet' });
return res.json({ servers: client.guilds.cache.size || 0 });
});
app.listen(port, console.log(`Listening on port ${port}`);
client.login(process.env.TOKEN);
i know it's chunky for something so simple, lmao, but it's better ig
@still cliff and?
makes sure it can't error
And what, @paper cliff?
Read messages properly
He already have a website with php or whatever
He just want a way to embed usercount and guildcount
@sick cloud i think you can use client.ready ?
i think it's a variable you can use :)
(it's readyAt*)
I have happened to miss that because I received a private message from the author.
Excellent handling of common errors, @sick cloud!
Does SQLite work with heroku?
no iirc
if I remember correctly
What is that tho?
Iirc
its an acronym or whatever
check pins
O
Well Iโll get a actuall host
@drifting wedge
I know a good VPS it's free but not for huge bots as it only gives 250 mb memory
Bruh
@drifting wedge
I know a good VPS it's free but not for huge bots as it only gives 250 mb memory
@delicate shore what is it?
I can DM u
bruh
If you have a credit card, GCloud gives you 1 year or $300 credit for free
anyone know how to create a discord bot? i want it linked with google sheets
Are you asking for someone to make you one, or looking to find out how to make one? @fickle cloak
well i dont know how to make one and looking on utube i dont understand. also i want the bot linked with google sheets because from google sheet responses people will get roles
you need knowledge of a programming language to program your own bot
if (!message.member.hasPermission('MANAGE_SERVER')) {
message.channel.send('You do not have the `MANAGE_SERVER` permission.')
} else {
RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number.
can't figure it out man hecc its 2am and slepe boy
the thing says its this line
so/shrug
MANAGE_GUILD
oh ๐
๐
hey
how is everyone doing
I had a question regarding a command
the command is called roleall it gives roles to all
I wanted to ask how much limit will this use out of 1000

"how much limit will this use"? What is "limit"? What exactly are you using?
Trying to add roles to everyone in a server or large group is typically prone to hitting a rate limit when done unproperly
NodeJs Eval method is called eval or evaluate?
@pallid igloo eval
ok
Hey
I cannot export my bot to github
is there any other way i can do so ?
pls tell kthnx
What have you tried to do
are there any good free vps options?
are there any good free vps options?
@worthy glacier your own pc
Is it connected to your GitHub account?
yes it is
no
problem is it was earlier imported from github but i changed whole code so can it be reason?
it already has a gitgnore should i delete that?
any """""""""""free""""""""""" hosting is either:
- not intended to be used as hosting
- not actually suitable for hosting
- not actually free
@worthy glacier not really, you won't find many free hosts that are good.
problem is it was earlier imported from github but i changed whole code so can it be reason?
it already has a gitgnore should i delete that?
You can try DanBot ig
U can use Dum host
@delicate shore glitch should send it to a glitch branch in the repo
no it didn't
I said should
Can you show what comes up when you try send it? Or send like a video of what happened
Can you show what comes up when you try send it? Or send like a video of what happened
@golden condor nothing
it keeps loading
then it says
Weโre sorry, something went wrong! Please try again, or try refreshing the editor
try a different repo
i have been trying for over 30 days now
try a different repo
@golden condor over 6 tried
yes
i found it
Copy that url
done
Hello
Do you have "git" installed your computer?
Can you try just typing git in a console
I am Making a website for my team's bot.
I wanted to show the number of servers and members the bot serves on the website but am not sure on how to do it.
Can anyone help me out?
:+1:
u can leave here i will see and thanks in advance
No if you don't know how to use git, I'll happily run you through it and I can explain what it means
okie
kk
Just lemme know once u did that (u can use mkdir)
yeh my pc turning on
@dusty shale How did you make your website and your bot?
Website is html and bot is js
You can make a small API for communication
Could you help me out with it?
@golden condor back
Ok
i cd into my folder
@dusty shale something simple inside your bot would work. Like getting /guilds returns the guilds and /members returns members
now do
cd ../
And
git clone <git url from glitch> <folder name>
So it goes inside the folder you just made
oh ok
Look above
ok
it says cloning into sheep
Ok
holy crap its 300 mb
Just wait for that to finish
k
Is there a node modules folder inside there now?
it's installing
ok
should i open folder?
Yes
now ?
Open your terminal
Yes
i had a env folder
