#development
1 messages ยท Page 1695 of 1
it stays online. Unless it's not logged in or it throws an error
Have you ever gotten your bot online?
yea but then after like 30 seconds it went offline :I
it didn't say anything in the log?
in the script
in the java script
how can i check if a client is till active?
uh i dont think so?
and after that it doesnt say anything anymore?
nope
Repl 
afaik if the red > appear in the end of console it means it's stopped
what does it mean if its stopped?
OH ITS ONLINE NOW
ohh
it has to say something, it cant just do offline and not say anything
Its back online now lols
thats why scroll up until you see what happened
the terminal, not the code
scroll up the terminal until the previous logged in message
to see what happened to the previous attempt
wait hold on did you use client.login()?
uh i somehow fixed it?
Good morning
I need some help
I'm creating a bot but I can't add commands to it
If anyone can help me
I will be so pleased :emoji_39-14:
Was you talking to me ๐
yea lol
Okay thanks anyway
well also if your online editor isn't open
and also it seems your bot won't do much other than replying to Hi
if you're the only one coding your bot then it's much better doing it offline
dude
this discord websocket heartbeat shit is so complicated
ive been trying to figure it out for half an hour and this is what i have rn: https://paste.mod.gg/abirezoluk.js
where is your break
oh f
Lol i can't with that shit
ikr
Brain would explode
guys, I put this in my code to not allow people using it with bots, but it is still working.
if (user === user.bot) return message.reply("You can't rep a bot.")```
Hello
Can someone tell me what the alternative to discord.js that use less ram ? (not Eris ๐ )
oh and also i cant use await in a constructor so i had to do this bullshit to get the correct gateway url from discord:
this.ws = new WebSocket((() => {
let url = "wss://gateway.discord.gg";
(async () => (await (await fetch("https://discord.com/api/v8/gateway")).json()).url)().then(_url => _url != "wss://gateway.discord.gg" ? (() => {this.ws.close(); this.ws = new WebSocket(_url)})() : null);
return url;
})() + "?v=6&encoding=json");
read your if condition again, but slowly
you are checking if the user object is equal to user.bot
you should check if user.bot is true
so
if (user.bot) return message.reply("You can't rep a bot.")```
?
binary

@rare oasis detritus or discord-rose
try it and see
ok
berry crying rn

it worked, thx @earnest phoenix
erwin has left the chat
yw
true
You don't need a websocket connection in order to make an interactions client
Eris is .... different
@pale vessel rate code bro https://github.com/Million900o/example-rose
Than what I'm used to with Discord.js anyway
weebsocket is weebsocket
oh
guys what does it mean if ur bot doesnt work when the programing tab is closed and only works when its open? :I
you just need a webhook server
a webhook server is gonna use up less resources too
mhm. Only downside is that you don't get any info on guilds and stuff like that when you first connect
?
but you can always just make a request
ive already spent so much time on this shit, dont wanna rewrite
You'll only have to replace the websocket connection with an express server
or koa or fastify or whatever
Even better, you can just provide the middleware
let the user create the server
ok so this is what i have till now:
https://paste.mod.gg/ibabajanew.js
have i done a good job or did i f up
let url = "wss://gateway.discord.gg";
(async () => (await (await fetch("https://discord.com/api/v8/gateway")).json()).url)().then(_url => _url != "wss://gateway.discord.gg" ? (() => {
this.ws.close();
this.ws = new WebSocket(_url)
})() : null);
return url;
})() + "?v=6&encoding=json");
This is... something
looks very unnecessary to me
just use the correct ws url in the first place, no?
yeah
discord says you need to get a correct gateway url from their api (even tho it's the exact same shit everytime)
and i cant use await in the constructor
and if i use .then on the promise typescript will yell at me that public ws has no initializer
then make an async method
thats... exactly what i did
method not function
public ws!: ... is make TS stop yelling
class Something () {
constructor() {
// some code
}
public async somethingElse () {
// more code
}
}```
no
huh
you can have a static method (which you can make async) that acts as an initializer
cosnt something = await Something.createAsync();
honestly same
ight how bout this:
public ws!: WebSocket;
constructor() {
// ...
this._setupWebSocket();
}
async _setupWebSocket() {
let url = await (await fetch("https://discord.com/api/v8/gateway").json());
this.ws = new WebSocket(url);
this.ws.addEventListener("message", this._handleMessage);
}
there's an await in that line
correct
i could just put .catch on this._setupWebSocket();
classes that need to do async work in the constructor should be initialized in an async context
do you intialize discordjs clients in an async context
djs doesn't do what you do in the ctor afaik
my code doesnt even work lmao
error: TS2339 [ERROR]: Property 'json' does not exist on type 'Promise<Response>'.
let url = await (await fetch("https://discord.com/api/v8/gateway").json());
bc you're calling json directly on the result of fetch
not on the result of its awaiter
haha use another parentheses
why do you use 2 await
aaand i was right, what you do in the ctor, djs does in the connect method of the websocket manager
async _setupWebSocket() {
let resp = await fetch("https://discord.com/api/v8/gateway");
let { url } = await resp.json();
this.ws = new WebSocket(url);
this.ws.addEventListener("message", this._handleMessage);
}
is that why clients have a .login() function rather than just logging in when its created?
no
o
o
that would go against all sane OOP conventions
um
error: Uncaught TypeError: this._heartbeat is not a function
setInterval(_ => this._heartbeat(), this.heartbeat_interval);
but it is defined there
bind
wdym
bind the function
this.ws.addEventListener("message", this._handleMessage); <--- here
o
wtf
thread 'main' panicked
rest of the error:
'Error 'WebSocket protocol error: Sending after closing is not allowed' contains boxed error of unknown type:
Protocol("Sending after closing is not allowed")', cli/errors.rs:35:7
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
setInterval?
yeah
wasnt checking for ready state
but how the fuck is the function fired when it's not ready
Seems like the issue was too many reactions, I stopped getting the abort errors after disabling some reaction heavy commands and reaction autoclear
i still cant find the thing causing the error
You should be routing your reaction handler through 1 reaction add event instead of 1 per
we can't either
okay i was booting up my pc, but i wanted to show you why you should have a static async initializer
async _setupWebSocket() {
let resp = await fetch("https://discord.com/api/v8/gateway");
let {
url
} = await resp.json();
this.ws = new WebSocket(url);
this.ws.onopen = () => this.ws.addEventListener("message", this._handleMessage.bind(this));
this.ws.onclose = console.log;
}
_handleMessage(event: MessageEvent) {
let data = JSON.parse(event.data);
switch (data.op) {
// Hello
case 10:
this.heartbeat_interval = data.heartbeat_interval;
setInterval(_ => this._heartbeat(), this.heartbeat_interval);
break;
// Heartbeat ACK
case 11:
this.got_last_heartbeat_ack = true;
break;
}
}
Both of these functions are only fired when the websocket sends a message i.e. only after the socket is open
here's the reference code; https://paste.mod.gg/xulefulite.js
as you can see, the error is being swallowed where the async method is called implicitly, even if you added a catch there, you would still be allowing the creation of the class, even though a vital part of the class failed to initialize
the class which has an explicit async constructor boils the error to top level of the code, letting the user know that it had failed
look at the reference code
gay
you can also return the promise from the constructor afaik
and do await new Class()
that works
@vagrant prairie tl;dr the mongodb server said go away i dont like you and close the connection
you can directly return a promise in the constructor
like tim said
mongoose.connection.close() comes multiple times
so i'm guessing something like
constructor() {
return (async () => {
//async code and shit
return this;
});
}
damn there are so many interesting design patterns you can do with js
good idea
you're still not doing a proper pattern in the constructor
you're just catching the error thrown in the promise and... throwing it again
it won't error out the class
it will error the promise
Ghostbin is a website where you can store and share text online.
pwd : yes
i keep getting topology error
how bout this:
constructor(options) {
super();
return (async () => {
return await this.initialize();
}).bind(this)();
}
what are you trying to do?
i dont know
i figured
resolve the promise and return the resolved value?
k
also
constructors are sync only
you need to return this; in the initialize method
you have to return the promise and have the user resolve it
and if somebody wants to create an instance of the class theyll do await new InteractionsClient()
deno has top level await :)
ye
um
does anyne have mongo experience
top level await isn't correlated to ctors being sync
it's to resolve the promise returned from the constructor
oh right
let client: InteractionsClient = await (new InteractionsClient(options));
b o i
do i need the extra paranthesis
y e s
can someone help me with mongoose?
ive been getting the
error : Mongo topology error
code : https://ghostbin.com/paste/BtLvS/yes
Ghostbin is a website where you can store and share text online.
mongeese
why not use for(.. in ..)
ยฏ_(ใ)_/ยฏ
geese are assholes tho
are you people trying to make a slash commands handler?
yeah that's what i was implying
i am
forEach is horrid and slow
i actually thought for loops were slower
pls forgive me
are you using the api or the shitty npm packages
im making a shitty package
and it's not on npm
it doesnt even use node
it uses it's younger bro deno
tldr it's because forEach needs to recomputate the callback function for every element and then fire that function which adds overhead and just really doesn't scale well at all
when u keep getting ignored
forEach = for that creates functions
I love forEach loops, and the speed doesn't matter if the context is Discord bots
i kind of agree?
it doesn't?
sure thing, what's slowing you down are HTTP requests, not anything else in the code
you should still optimize your code though
especially for something like this, looping through commands etc
and especially in a library
the end user expects well performing code
the differences would be in miliseconds, or 2 seconds max
TS2740 [ERROR]: Type 'Promise<void>' is missing the following properties from type 'InteractionsClient<options>': commands, endpoint, ws, s, and 29 more.
return this.initialize(options);
i sometimes want to slap whoever made typescript
i have 69 errors
i have // @ts-ignore
gasp I have working code!
i'm guessing you don't return this; in the intialize method?
just dont use ts
;)
^
deno js moment
ts bad
exactly
๐ฆ
it makes simple complex stuff 9000 lines
sorry i dont use mongo
it's a way to fool proof code
its so nice just catching issues before they come up tho
those 2 hours you'd spend trying to find a bug in a production website because you forgot that a variable is actually a number... would be 2 minutes with typescript
yesterday i wrote a 200 line typing declaration and jsdoc for a single function
js is unfool proof if you give it to the right people
what
so no one
thats a dumb thing to say
sorry I meant js is unfool proof if you give it to the wrong people
i want to but i cant
c++ is unfool proof if you give it to the wrong people
vanilla js = bs
ts = bs
does deno not have js
everyone is bound to make a mistake of forgetting what type their variable is
it does
typescript screams at you
not me
but i want to use types and interfaces
there's your answer??
how ignorant
clearly you haven't worked on a large web/node project then
I made a web dashboard with complete css
๐ฑ
yes, i hack with notepad
just keep on plugging out the cables to your computer
if it doesn't work, scream at it
no matter how good you are, you still make dumb mistakes
if that doesn't work, punch your monitor
youll just find them faster if youre good
thus I use Quokka.js, Wallaby.js and webstorm
eslint's screaming at tsc's output
then nothing's gonna stop me from writing . this . code ( "ahha" ) ;
how do i exclude a folder
eslit pls exclude "folder" kthxbai owo
oh
reason: "Rate limited."
i reported you to the competent authorities
thank
eswint pws excwude "fowdew" kthxbai OwO
it won't listen
thanks discord for the rate limits
repowted
makes new botum
can someone help me with mongoose thou
yes use mongoose
shitty sql is shitty
orms
sqlite bae
everything that is sql based can go die in a hole
y
lmao
no
and so ez
how so
mongoose is ez
lmao
its shit
is not an argument my dude
mongoose is a clusterfuck
define every way
sql is a clusterfuck
xD
everything you've been saying so far is vague
i mean
best of both worlds
also that
mongoose itself is an orm
you cant really comoare sql dbs to mongoose
have ti comoare them yo mongodb
bUt TiM, SqL iS ShIT
also the fact that sql is a language
ur shit
ah that explains
yOu CHaNgED ๐
my toxicity is usually brought fourth due to poor TS coding
@Mr Master#1250
literally same, i start ripping my hair out when something in react has wrong types
and then i gotta do global augmentation
ikr!
i don't like
the worst is having to slap @obtuse osprey-ignore every fucking where cuz the types shipped with it are wrong
LOL
well, random ping
xD
ur fault for being named @ ts
I love when that happens

yea hoenstly
i think that person got pinged like 10 times in the past two days
here
just because of ts ignore
lmfao
gonna switch my nickname to @ gmail
lets see how many pings we get
i dont think it parses it anymore
nope
wasnt there something else that parsed into mentions?
i recall having another thing apart from ts-ignore that made quite a few accidental pings
but thats beside the point
I made @obtuse osprey-something my github alt name and I got spammed with emails
its funny
@obtuse osprey-ignore
ill show when I get into the email
its insanely infurating haivng to ts-ignore wrong interfaces
LOL
Guysss
pr it
i finally did it
yeah submit a pr or an issue
i'll pr you to go watch the anime
@earnest phoenix -ignore
cant be arsed to pr in all honesty
did you delete all code?

nope
shouldnt you?
gud 4 u
idk
yay ty
cant have bugs when there's no code in the first place :wesmart:
fuck, its 9am, but goddamn i need a beer, literally woke up to 21 errors in prod due to a bad parser in someones lib
we live in a society
the mitochondria is the powerhouse of the cell
Hotel? Shivaco
age is int
so i made a globalchat command
and i just have a question
i made it so you have to mention the channel that you want
hey
my bot was working totally fine till yesterday
now it stopped responding
i rebooted it
and its still off
(no changes made in the code)
but i don't want it like that
how can i make it so that it automatically adds the channel to json file?
right now you have to do p!gcstart #channel
but i want them to do p!gcstart
and it adds their channel
here is the code of that section
guild_id = ctx.message.guild.id
channel_id = int(channel.strip('<>#'))
# channel_id = ctx.channel.id
with open('global_chat.json', 'r') as file:```
i tried to do it already in the #channel_id part
(commented part)
just save the message channel id
sounds right
but like cry said, dont use json as a db, will give you more headache than setting up a proper database when it starts to corrupt
is it stateless?
kind of
all it does is store
the channel id
and when they run the stop command
it deletes it
(and since not the most people use my bot) it's normally empty
the code:
import System;
Console.log("Hello World");
can't you just store that in a list then
because it's for different servers
dictionaries
say its easier when it corrupts
skydiving without parachute is also easier than learning how parachutes work
it doesn't matter what the file contents are
you seem to not understand how r/w works
python has a built-in persistent storage
i mean if it "gets" corrupted there isn't much to replace
you're also slowing down your code by a significant margin
you have a really good point here tbh
lol
that's...actual help
i didn't ask for that portion
sucks to be you i guess
then ill go ask for help somewhere else
they'll say the same if you say you're using json-db
at least they'll bother to help
we are helping tho
just let their db corrupt, once it corrupts they'll regret everything
a.startbot
@opal plank
a.startboz
what are you even trying to do
you should ban/remove from the project whoever that person is

Can my bot still be approved when I include this warning
wait ...at least 18 years of age correction
You need to lock NSFW content so it only gets sent to NSFW typed channels
yes it does check it
then your warning isn't relevant in any way since Discord already has the barrier to entry of clicking the "Yes I'm 18 let me in" button
it has to be only nsfw channels, not if the user enabled nsfw for themselves :p
So, your setting and warning isn't necessary, though it is cool I guess
Why are you constructing strings in this way
if someone didn't want nsfw content they could just... not create NSFW channels ๐
yeah i didn't think about that.
haha im just used to
i usually create tables and that's the only clean way I know of
`text...\n...text`
That's not clean? ๐
its random people cuz the name of the profile
Or just, y'know, ```js
const ErrorMessage = Hey you didn't turn on NSFW, do ${prefix}config nsfw on to do it. Also you agree I'm going to send you boobs, because that's how NSFW works, kid.;
because template literals support line returns ๐
ohh
@waxen bough Remember you can't mention that your bot has nsfw content in the bot description
i didn't say i would mention it. I take a look at declined bots
and i know i can't mention nsfw feature there
wait what
why would you return without a response?
its fine to have nsfw in help menu and such
just not on the site
return (false) 
haha when i was a newbie i do that
I used to do return(0) in C++ and JS is c-like and 0 = false so I thought it'd be return(false) in JS
ummm..........
brackets work so anyway
let's move on
how 
welcome to JS (which I didn't learn)
let's move on
oh wait
hhaa
this is for ASI
what's ASI ?
The return statement ends function execution and
specifies a value to be returned to the function caller.
@summer torrent it works without brackets too btw
yes
but brackets look cooler (otherwise it'd look like python {without any brackets})
You can wrap any expression (or a list of expressions) in brackets, that's why they work
I don't really like it cause it looks like it's calling a function, I only do it when I'm returning a react component
what does thoose error means
I wanted to log out a file import (require) and wanted to log it out and it gives me this
what's the difference between git fetch and git pull
you should ban all of the ones who used ts-nocheck in that repo

yes
ok
what's ts-nocheck
it basically skips checking on that file
tells compiler to ignore iirc
ts-ignore is for the next line to ignore
well it defeats ts purpose
thats precisely why i said this
well ts defeats my sanity purpose
hahahehihohu
your sanity defeats the purpose of your coding life
i agree
thats for the weak
true man just retun 200 with the body containing the error
lmao christ
{
"code": 200,
"data": "Error: You don't have fuqing access token"
}
exactly
internet monetization when
{
"code": 200,
"data": "task failed successfully"
}
{
"code": 402,
"data": "Credit Card payload not available or invalid, please provide a valid credit card in order to request to this api"
}```
can anyone help me in node.js language for event that executes on variable change
I don't want to add Add Message even
nice pfp, I mean can you give a small example?
zero two
its not zero two...
its ME!ME!ME!
but anyway
The set syntax binds an object
property to a function to be called when there is an attempt to set that
property.
its like lol
thenks
its not like at all
Default prefix is ":" and it can be changed. Do I just write : (default)
this chick makes zero two look like an innocent child
lmao
@opal plank actually I saw this on phut hon
would send you the link, but highly NSFW, just google ME!ME!ME! on youtube

dont forget to study 420 code
ok lol np
I will ,thanks for recommendation tho
goodle
search synonyms: google, lookup, bing, googol, 10^100
what, explain
coders/programmers dont have sanity
yes ik that
there, i explained the joke, now its 1000x funnier
what does that mean
what's adelinquent account
Is there a problem by using those bot hosting sites instead of the whole coding thing? I'm a lazy person ;w; Also my bot needs to have admin permission, and this isnt because i want, the hosting website makes the bot request that, is it a problem? cause if it is i think i shall search for other bot hosting or try to make my own bot from 0.
jokes on you, Idek what that means
@opal plank :loli_dance: moment
can you extend MessageEmbed?
i know how to extend message but how do you extend message embed?
MessageEmbed.prototype = async function?
modifying the prototype chain manually 
Are those bot hosting sites bad ?
YES
Before you learn how to code ask yourself why do you need a bot for.
If you need a bot for your personal server or maybe to flex you can use those services.
But if you're actually series about making a bot (commercially) then DON'T USE EM
Take some time, learn to code then make one yourself. (Coding is not like rocket science or something, You'll only need 3 braincells to learn how to code)
coding's pretty easy actually
u just gotta be willing to learn
once u get the hang out of it you'll be coding bots in no time
i'll bite you
then you'll abandon them for years
and never come back
and turn into a white name bc some mf stole your co-owner's account and deleted the bot from top.gg
totally not me
@neat beacon
check this #development message
can someone help me with jda?
what's jda ?
ok prettier chill
5/7
@quartz kindle u know jda?
no
Someone?
@copper cradle
do you get any errors coming from maven? how do u know there's something missing
Can someone help me make my bot send embed links? (I use python)
just send the link 
embed links? do u mean markdown links?
to whom it may concern: the docs on top.gg for posting stats has the wrong response example ... --> https://docs.top.gg/api/bot/#example-response-3
what do you mean?
Thank you, it might help me if I read it.
the response for posting stats POST /bots/:bot_id/stats ... is not { "voted": 1 } is it? ๐
But the example response is for /bots/:bot_id/check?userId=:user_id
exactly .. its wrong
?
Ah, I see what you mean
It's under the wrong title
You can report the issue on github if you want
How will I be able to check if the entire message contains a word from the getResult variable (which is an array).
I have use : if(getResult.includes(message.content)){ but its only for the first word
how can i do please
Could use a for loop
for (var i = 0; i < getResult.length; i++){
if (getResult[i].includes(message.content)){
//CODE TO RUN
}
}
Did that on my phone so caution, lol
you can also use some
getResult.some(r => str.includes(r))
more like
Wait
getResult.includes(message.content) should already do the job, kinda?
You'll have to split the message.content so you don't detect stuff like h3ueh3uheworduwhd3uhe3
const wordsFromMsg = message.content.split(" ");
getResult.some(w => wordsFromMsg.includes(w));
explore_messages = [
"You explored the edge of town and made {} dollars and likes! "
]
How do I make another value show 8nbetween and^likes
document.getElementById("btn6").onclick = function() {
}```
i wanna if this button is clicked transfer me to next page(i have a second.html file)
can i introduce you to react
The Window.location read-only property returns a
Location object with information about the current location of the
document.
Yeah but just remember it's always good to have the basics ^_^
understanding why react is fucking awesome requires for someone to put in the time
does includes accept a fn? 
const Discord = require('discord.js')
module.exports = {
name: '42ball',
description: '42ball <mesage>',
run(message, args){
const sayMessage = args.join(" ")
message.channel.send(randomMessage);
}
}
const messages = [
"Yes you big dummy",
"No you sicko path",
"mmm... maybe?",
"Do what you have to do",
"Yep",
"Nope",
"Are you transgender?",
];
const randomMessage = messages[Math.floor(Math.random() * messages.length)];
was suppose to send random messages but it sends the same ?
put it in the function, not outside, so it selects a differetn random message every time
document.getElementById("btn6").onclick = function() {
location.assign("https://main.html")
location = "http://second.html";
}```
like this?
that would be redirecting to a domain called main.html
why do you need js for that
lol
ill put relative oath
didi it
thx just one last question is it possible to make it embed?
it workd
I know how to make embeds
Ok so just take the variable and put it in the embed?
if you know how to use a variable and you know how to make an embed, you know how to put 2 + 2 together
l
don't make me link to my learnjs message again
k
oop I meant some
code
3 "your laguage" code here 3
```js
your code here
```
^
TypeError: Cannot read property 'hasPermission' of null```
Have been toying with d.js and sms / tel links, apparently discord doesn't like to hyperlink sms:some number here or tel:some number here anyone got a workaround for that one.
i use this fo clear message but "spawn" this error...
Ok, so, fetch the member
message.guild.members.fetch(message.author.id)
it returns a promise so you have to await it
message.member will be null if it's a system message, no?
yeah but this is in a command so a system message's never gonna trigger it
ah
unless Discord started sending system messages in guild channels saying !clear 100 
i send here the code that i used but the text in " " are italian...
if(!message.member.hasPermission("MANAGE_MESSAGES")){
message.channel.send("non hai il permesso!")
return;
}
if(!message.guild.me.hasPermission("MANAGE_MESSAGES")){
message.channel.send("Non ho i permessi per farlo!")
return;
}
var clear_count = message.content.slice(7);
clear_count = parseInt(clear_count);
if(!clear_count){
message.channel.send("Inserisci un numero valido!")
return;
}
if(clear_count > 250){
message.channel.send("Massimo 250")
return;
}
message.channel.bulkDelete(clear_count, true);
message.channel.send("Ho eliminato " + clear_count + " messaggi")
.then(msg =>{
msg.delete({timeout:2500})
});
};```
return moment
Are you ignoring my solution or do you not understand it?
Gotta love when I give a straight answer and I get ignored.
ok i try but i have the previous error...
So you're saying you tried adding what I said here and you get the SAME error? #development message

because it doesn't show in that new code you just pasted
I'm not doing anything against TOS with this question but asking since we are clustering...
Can a bot DM a user if the user doesn't share a server with the bot?
Cluster 1 has shards 1, 2 ,3
Cluster 2 has shards 4, 5, 6
Can a bot still technically be able to dm a user from cluster 1 to a user in cluster 2? Idk if that makes sense. 
no, the bot cannot DM a user it does not share a server with.
Aight good to know ty.
However
ALL DMs are handled by Shard 0
And if your bot is in the same server it doesn't matter if they're not in the same shard
oh?
Actuallyyyyyyy
hello. does someone know how i can make a node.js file send the command npm start in a specific folder?
shard 0 only receives DMs though
๐ค
look into the exec function
hmm. okay
exported by the child_process module
is it possible a bot one to get into it?
yeah
...
I know it's possible I can't give you any more info because I've never tried doing it myself
const Discord = require('discord.js')
module.exports = {
name: 'quiz',
description: '42ball <mesage>',
run(message, args){
const sayMessage = args.join(" ")
const messages = [
"What is the most common colour of toilet paper",
"Henry VIII introduced which tax in England in 1535?",
"The average person does what thirteen times a day?",
"Who invented the word vomit?",
"What is Scooby Dooโs full name?",
"**True or false:** You can sneeze in your sleep",
"who was the first black president of United states",
];
const randomMessage = messages[Math.floor(Math.random() * messages.length)];
message.channel.send(randomMessage)
}
}
How do I make it so when the bot sends a random quiz after 15 seconds it sends the answer for the quiz
okay yea. im gonna need more than that. i have no idea what to do
but like... once the bot is ready.
i need it to go into the folder ./myapp and run the command npm start
Instead of storing only the questions in the array, store objects containing the question and the answer:
const questions = [
{question: "...", answer: "..."},
...
]
And then use a setTimeout which sends the answer to the channel
Make sure to cancel the timeout when the user answers
Anyone know if it's possible to make <a href="link">text</a> POST instead of GET.
only via js
ah ok
depending on what you want, you can maybe try html5 forms
cd path ; npm start should do it
pass that to the exec function, replace path with the actual path and you're done
i still have no idea how the exec function works
have you tried reading the docs
So you understand absolutely nothing?
basically
Nothing from the examples, too?
i looked at it. looked back at my code. and had no idea what to do
i still have no idea what im looking at or where to put it
That sounds like a you problem ๐
obviously
Well, anyone knows where I can learn to develop bots in python?
do you not know how to use a console?
Someone answer this
You should start with a general python guide / tutorial
and then move to bot development, it'll make your life a lot easier
That is if you don't know python of course
if you do then look up a bot tutorial
ok, but this code where paste and substitute??#development message
i don't understand it
I see... Thanks...
const Discord = require('discord.js')
module.exports = {
name: 'quiz',
description: '42ball <mesage>',
run(message, args){
const sayMessage = args.join(" ")
const questions = [
{questions: "What is the most common colour of toilet paper", answer: "white"},
{questions: "Henry VIII introduced which tax in England in 1535?", answer: "beards"},
{questions: "The average person does what thirteen times a day?", answer: "Laugh"},
{questions: "Who invented the word vomit?", answer: "Shakespeare"},
{questions: "What is Scooby Dooโs full name?", answer: "Scoobert Doo"},
{questions: "**True or false:** You can sneeze in your sleep", answer: "No you cant"},
{questions: "who was the first black president of United states", answer: "Barack Obama"},
];
const randomMessage = messages[Math.floor(Math.random() * messages.length)];
message.channel.send(randomMessage)
}
}
how to I use the setTimeout ?
const timeout = setTimeout(() => {
message.channel.send("...");
}, 60000); // 1 minute
For example
and you do clearTimeout(timeout) to prevent it from it getting executed
Also message.channel.send(randomMessage.question) and questions.length
Help, the user counter of my botinfo command does not count all the users I have, what do I do?
This is my code
Not all users get cached
use the built in embed class tho
yeah, and most people don't care about the user count of your bot anyway
You know what would be a cool metric, average users per guild
something like taco shack can say they have x users because you need to create a shack
do that instead
I'd rather know the command usage stats rather than my users
I've never used it
then you aren't a user
const Discord = require('discord.js')
module.exports = {
name: 'quiz',
description: '42ball <mesage>',
run(message, args){
const sayMessage = args.join(" ")
const questions = [
{questions: "What is the most common colour of toilet paper", answer: "white"},
{questions: "Henry VIII introduced which tax in England in 1535?", answer: "beards"},
{questions: "The average person does what thirteen times a day?", answer: "Laugh"},
{questions: "Who invented the word vomit?", answer: "Shakespeare"},
{questions: "What is Scooby Dooโs full name?", answer: "Scoobert Doo"},
{questions: "**True or false:** You can sneeze in your sleep", answer: "No you cant"},
{questions: "who was the first black president of United states", answer: "Barack Obama"},
];
const randomMessage = question[Math.floor(Math.random() * questions.length)];
const timeout = setTimeout(() => {
message.channel.send(answer);
}, 15); // 1 minute
message.channel.send(randomMessage)
}
}
question is undefined
It's questions
you've defined the array as questions
Also the second parameter of the setTimeout function is the time in milliseconds, not seconds
Also, you want to use awaitMessages to await the user's response and check if the answer is correct or not
And if the user has answered, cancel the timeout
is there a way to add a "copy to clipboard" in a discord embed?
no
sad
TypeError: methods.has is not a function
I'm wondering if branchless javascript is faster than regular ifs
const methods = ['test']
if(!methods.has(msg.content)) msg.reply('abhe saale')
error
TypeError: methods.has is not a function```
it's .includes
yes
ok thanks
how do I use the await message?
Read the docs
const moment = require("moment")
module.exports = (client, err) => {
client.channels.cache.get("825012560138076232").send("Date de l'erreur : `"+moment().format('MMMM Do YYYY, h:mm:ss a')+"`\n\nErreur : `"+err+"`");
}
All my events work but my error event doesnโt work, why?
you shouldn't log errors to discord anyway
Alright i have 3 questions ;w; , so i should remove my bot from the host site and start making tests? Also, is there a way to remove a submitted bot? Is it true that if your bot gets denied you get banned from inviting other ones?
tests with python language
I'm so freaking confused now

if your bot gets denied you just have to wait a few weeks to submit it again
What if i submit other bot instead of the denied one?
Same cooldown?
k
if it gets denied many times, you'll most likely be banned from adding bots
does anyone know why an on error event might not work
maybe it's not getting any error? lol
anyone know how to record audio from a voice channel in discord.js?
Does anyone know of a way to log categories I've tried message.category.id and a few other variations of that but no luck. I've looked on the docs as well but haven't found anything that looks like what I'm after
What category
Channel categories
then message.channel?
I'm trying to log their id's using a command
Doing channel.category.id just says channel is undefined
Nowhere I'm trying to set a category for the channel to be made in using a command
thats how the channel is being made
and thats how the category is being logged
im wondering if there is a more ideal way of logging it
what are you stuck on?
for ideal way, create the channel along with the category id
you can reduce your requests that way
I wouldn't advise using the username to create a channel
tag wasnt quite what i wanted thats why i use username
cuz, taking a username at random, what do you think the channel name's gonna be on ๐๐ฎ๐น๐ฎ๐
๐ถ ๐ฒ๐น ๐ฝ๐ฒ๐น๐ถ๐ด๐ฟ๐ผ๐ ?
because that ain't alphanumeric, which is the only thing that can go in channel names
hmm what would you suggest in place of username?
ID, usually
id
hold up one damned second since when do channels accept unicode 
So I have a array
so you have an array
yeah actually that's real interesting for unicode-like usernames, but... like what about that weird owo?
I did not expect that channel name
chosenroles = [];
for() {
chosenroles.push({label: role.name, value: role.id })
} //my loop stuff
How can I search for a role ID inside of that array?
i guess i could make a category then a channel and parent it that way. Not what im looking for but should stop any errors
so if I am doing a filter
guild.roles.cache.filter(r => r.id !== guild.id && chosenroles.find(role => role.value !== r.id))
yeah probably!
or actually in this case maybe .some instead of .find - same code, jsut different method
so you get a boolean
try running the bot in your own pc
try running a barebones version of it
try making a request to /gateway/bot with your bot's token in the authorization header and see what response it gives
ye
or even something like reqbin.com
Anyone here by chance used SelectPure before?
do custom authorization
and do it like this: Bot 7n38723n97y29c3y579237nc92735c
so you're cloudflare banned
what do the headers say?
show them all
theres nothing sensitive there
huh, theres no retry-after?
what was the value?
TypeError: this.client.on is not a function could mean what?
would mean this.client isn't actually a discord client
oh wait this is the actual discord app?
no confusing different things here
someone can help me ? (dm me pls)
this.client clearly isn't a discord client
no just ask your question here we'll help you here
no one wants to be responsible for single-handedly resolving all your issues in DMs, man.
(unless they're paid for it)
yeah but no one can afford my rates ๐
many can, they just dont want to
I need the bot to send a message to a different member every 30 sec
theres rich kids everywhere
:^)
what message, which members, which discord library
client.guilds.cache.forEach(guild => {
guild.members.cache.forEach(member => {
setTimeout(() => {
member.send("test")
}, 30000)
});
});
nonono
to don't do that
that will send thousands of messages at once
that's spamming everyone
yes :/
use setInterval and choose a member at random from the cache in that interval
thjough if you're gonna do that make sure they have a way to opt-out
use a recursive function or a for loop with async/await

// recursive function
function bla() {
doseomthing()
setTimeout(() => {
bla();
}, 30000)
}
// for loop with async/await
for(let member of guild.members.cache.values()) {
doseomthing();
await new Promise(r => setTimeout(r, 30000))
}
tell them you have been cloudflare banned but there is no retry-after information about when the ban will be lifted










