#development
1 messages · Page 1756 of 1
when the server name does match or doesnt
and i need to fix this
function intervalFunc() {
var server = bot.guilds.cache.get("801048326514409502");
if(server.name == 'Spooky Month')
{
bot.channels.cache.get('841977665672970240').send("Server name is Spooky Month :white_check_mark:")
}else{
bot.channels.cache.get('841977665672970240').send("Server name is Spooky Month :x:");
clearInterval();
}
}
setInterval(intervalFunc, 5000);
if someone can fix this pls do
i need it looping every 5s Unless the server name is The correct one
and if its false then loop again
loop check for the name to be Spooky Month again
and if someone is so good in javascript.....make it so it only loops at october
all rest of the months it doesnt loop no matter wat
so unless its october on ur machine
and in ur browser
the event would work and loop normally
why don't you execute the code in october
Idk
Bc i dont wanna
thats not professional
unless its in only one guild
so alot of guilds
in the future
rn its only 1
so that would be a lot to cache in that case
maybe
How to make a message which is sent when someone votes? Discord.js
votes what?
The bot
for the second time
I asked there but no one replied
then wait
im not using it, other people did this code for me
this ain't
this is
ain't
is
wanna see something complex?
no
then ain't
unless u talking about my code
you could do this
setTimeout(()=>{
// your code
}, //time in ms)
ok then aint
wat would this do?
caching the guild name everytime time period
hmm
here are my two cents: don't bother with professional stuff, you're not writing a commercial-grade software
ye sure for now
if u wanna go full professional then you shouldn't even be writing code to begin with
i want to
its fun
you should be documenting and gathering requirements
i kinda am
but a bot
that's what professional means
no bro
i just need to fix this 1 bug rn
I still think its kinda dumb, don't get me wrong, to be simultaneously caching something that's gonna be triggered in october
can someone help me
can you at least let us finish typing?
The october only thing is idk, IDK IF THATS EVEN POSSIBLE. rn its just gonna be every 5s forever until someone comes up w a better design
the bug is that it keeps spamming that the server name is correct or incorrect
how do i fix this
idk
don't go full professional on a bot, you'll waste a holy hell of time just by bothering with that, it's not worth it UNLESS you're making a commercial-grade software, which bots AREN'T
;-;
i like being perfect
hey, I mean I don't mind people doing something perfect
even if its something small
professional includes a shitton of stuff, not only "minor" stuff
its a good step to something better
then u don't want a solution
did I say command?
U made it seem so yes
^
you can use a setTimeout as a event too
I said code
"execute"
events
yes, you execute code
it will be going forever
execute
what does it do
and how do i do it
and can u FIX MY CODE
the way u mean
what
i d k
HOWEVER, I can show you the path
that's sadistic
as per #rules-and-info
now that you have the month, you can execute that part of the code ONLY on october (or whatever month u want)
now lets move on to the loop
I still don't understand why you would not not execute the code in october rather than forever
why not add the code in october
WHAT
THATS AN ACTUAL THING?
NO WAY
o ok
filter the guild cache by name, check if it equals "Spooky Month"
example...?
with the result of the filter, do a for loop and do whatever you want inside it
read my last link
TBH
i dont rrly know what this means
Without learning the basics you won’t get far.
want != can
Yea I would learn the basics of the language first...
wdym
also, don't let people write code for you UNLESS it's a co-programmer
THAT is unprofessional
But that is up to you
OKI 😮
wanting something doesn't mean you can have something
yes it is
I want a lambo
i know
me too
I would... just 50 bucks
d e a l
toy?
😂

lololll
anyway
anyway
leave that idea for later on
what idea
focus on learning js
but you cant
Or an even better idea learn something better than JS lmao
with the help of others
why
no
its in my list
so i have to learn it
no, that's called code vampire
idc
no
People who can help actually do.
oki
I mean you got your links to the docs already.
Go on with that and get back after writing your own code if it doesn’t work.
wat
tbf, listen to my words, that code you have WILL spam the hell out of that channel
whats tbf
to be fair
Warning: spoon-feeding is not allowed
what code?
it will
that's called "spam the hell out of that channel"
and idk how to fix it
you're not clearing the interval if the server matches
so it'll spam continuously
server*
server name
bruh
Don’t get me wrong but the way how you write and don’t read let me think you’re a little to young to code and should concentrate on your school first. 
literally no joke, you lack fundamental knowledge of programming
that's dangerous
schools are bad
That’s what I thought 15y ago, too but no they aren’t
they are
except pre school or whatever its called
MIDDLE SCHOOL
i think
u learn math
and ur language, how to speak
and how to write
bruh
yk schools are progressive right?
What? How old are you if we speak about pre-school?
no more good help
ye lmao
also wtf?
XD
they do
why here?
Mine did
mine does teach how to cook
on his status
You literally need to pick up the elective
agreed
the wut
Please keep the channel on topic ^_^
we are
Shh
ANYWAY
TL;DR: focus on learning fundamental stuff of programming, ONLY THEN try to make that idea you have
XD
Yes. Step 1: learn a programming language.
thats borinnggggg
aaaaaa
that's childish
Omg
html is not a prog lang
HTML isn't a programming language.
isn't
No it is not
then what is it
html is a structure for web pages
I feel physical pain.
It's a markup language, not a programming language.
It's used for formatting only.
yes
Then learn html to code your bot lmao
lol
no
same as asking if chicken is tastier than sodium
IS HTML EASIER THAN JS
It's not the same thing!
they can't be compared
Not really comparable
bruh
BRUH
OK HOW ABNOUT THUIS
Who was first, the chicken or the egg? 
IS CODING A WEBSITE EASIER THAN LEARNING JS
no
bruh
because it includes js
BRUH
Coding a website requires HTML, CSS and JavaScript. 3 different things.
Me who uses MVC 😎
aaaaaaa
Coding a bot only requires one programming language.
OK
the chicken
so can someone fricking fix my codeeee
they were dinos
AND MY BUG
lmao
which the is the same thingggg
no
bruhhhhh
please read: #development message
im pinning that lol
I KNOW
i cant click on it
yep, broken link
bruh
what the
XD
you added a 1 on the end
¯_(ツ)_/¯
bruhhhh
Embarrassing!
oh i thought u said children
😂
dot dot dot
Wth is this chat
sodium does have a taste
Well
but you won't feel it
Guys 
no
Learn JS dude.. stop that
No
Case closed. Next please.
no
Hello, im new here, i'd like to know how to unfreeze an object from a retarded package i installed
idk
uncompress it
wdym?
just jokin, nothing important

what do you mean by "unfreeze an object"?
Object.freeze()
the idiots that made the package did that to one of the entries
now i cant modify them, forcing me to clone them and cache them elsewhere
The Object.freeze() method freezes an
object. A frozen object can no longer be changed; freezing an object prevents new
properties from being added to it, existing properties from being removed, prevents
changing the enumerability, configurability, or writability of existing properties, and
prevents the values of existing properties from...
this
you can't as it seems
fuck, cloning it is
hi Erwin
Hello Erwin, all of our employees are currently unavailable, please hold the line.
rip to my code
2021 - 2021 R.I.P.
AHJAHHA
|NIO RIp
U SUCK GUYS
SOMEONE FIXED MY CODE
what
NO SPOONFEEDING HERE
stop
yes
bruh
…
Copy the message link as dot posts are not "allowed"
No
xd
God damn laziness anywhere
I hate taking code, takes the joy out of making something hard. But to each their own I guess
All programs borrow code
?
?
yo
someone help me
is there a way to do this: if u use the Spooky Month Name And then change it back it does a message in a channel
?
Rrly would be cool
and if i would know how to do that
i could do this to anything
like
Name Change to "Galaxy's Basement Christmas Edition"
and smth would happen
which i can do
with the code i have
but i also want to do a message when u change it back
from a specific name
U SUCK GUYS
SOMEONE FIXED MY CODE
like, are you really proud of being spoonfed a ridiculously simple code?
That’s all I remember
tsk tsk, don't tell me you're going to live with hardcoding server names
If the question even made sense, maybe we could have helped in the first place? Man, this kid sounds like an overexcited 6 year old screaming at mommy to get one of 58 candy in the display and being so hyper they can't speak right.
oh all that hope and joy will last very little, then it'll become despair and remorse for skipping steps in programming
holding....... holding..............holding.,.....
hi weeb
well
lemme explain
The "Normal Server Name" Would be "Galaxy's Basement
Now a Special Name Would be smth not "Galaxy's Basement"
and that would most likely happen bc theres a holiday or a special event
now i wanna make it so
mmmkay and that requires a bot, to change something like 12 times a year? 
fuck
when u change BACK from the Special Name into the "Normal Server Name" u would get a message in a channel
no lol
and i have a bot
i just need the code
lmao
yes
i do
... and you rather waste a few hours asking people for code, rather than just renaming the server yourself whenever you want...
You need the code for what exactly
its ridiculously hard code but yes
Detecting that the server name has changed?
that event
yes, sure
not exactly
I could do that blindfolded with turned off pc
that the server name has changed BACK from the special name
Right
so just like
so look for guildUpdate event
ye
;-;
@umbral zealot bruh, you don't understand how deep his case goes
not rn
jabbascript
xd
ya
Well we're not going to help you "right now"
bruh
Our help is, go learn the language.
no
i mean
It's not the help you want but it's the help you deserve and need.
hey can u help me?
yep
guildUpdate gives you 2 objects, a guild object before the update, and a guild object after the update
just use it to compare the guild names
ik that
professional
how?
like you use any other event?
By using a simple javascript compare condition. Which you'd know, if you knew the language.
;-;
and how do u do that
bc idk how events work lmao
do you even have any code
yes
show your existing code
yet you have a bot...
alot i would say
for what file?
a bot without events 
yessir
any file that has events
no it has events
lmao
thats the main.js
let me guess: someone made it for you?
question
can i put this event in another file?
did u make ANY code in your bot?
there it is tim, you know what you're handling with
xd
Then back to "go learn JS and stop being a Tyler!"
Lmao
can u??
well, first of all, if someone else coded for you, then you has to ask them to do these changes and additions for you. trying to do it yourself requires knowing how it works, or you will end up breaking stuff
and the answer is always "yes, if you do it right"
as in
it 100% depends how your current code looks like
why are you assuming his code has only 1 father?

lel
Frankenstein code
frankenstein but all pieces are from other frankesteins
code is a web of interconnected strings. if you change one, you need to update everything that has strings connected to it
except if u use typescript
you don't need to
its smart enough to change paths and warn you about changes
thats not ts

well ts does warn you
no, ts will pretty much screech at ur type errors
if something doesn't exist
it will scream at you yes, but your editor changes the paths, not ts
you can do that in js as well
well yeah
cof cof intellij cof cof
details, details
limão
laranja
huh
limão = lime(lemon) in portuguese, but it resembles the word lmao
ah
wouldn't lime be lima?
hmmm i think u right bout that
contrary to popular belief, lemons are not limes
not all lemons are limes but all limes are lemons
limes are suckable, lemons suck you
erwin are you ready for profiles to look like this? https://img.terano.dev/GqIgncLA
wdym?
with the bar
thats gross
new vs old
and the about me (which doesn't show bc not added)
nah, its expirements
y'know whats funny/
nope
do you fetch all users on startup?
not anymore
thats a weed strain
looks good
but thats also none of my business
isnt that misleading advertising? discord's website been showing that UI for ages, and discord never looked like that
bitcoin gold
yes
discord themes would be sick
Just allow us to have custom themes 😩
imagine if servers could make server-specific themes
One message removed from a suspended account.
cough cough mods cough cough
like custom backgrounds for channels

okay
let me 100% honest
i DID have an idea like that , but for stage channels
how cool would it be to remove message topic ratelimits and have backgrounds?
it would legit be a spotify collab
edit channel topic to current song + background when inside the stage channel with the art cover of the song playing
/hug
doesnt ts3 have a popular theme similar to that
dunno
I only have ts5
i used to code themes for some mods, back in my old obscure past
so it wouldnt be hard to do it
but i dislike using mods myself
obscure
Awwww phone was ringing
How do i make it so that my discord bot can send custom emojis and animated emojis?
custom emojis
<:emoji_name:emoji_id>
animated emojis
<a:emoji_name:emoji_id>
oh so you don't need ur bot to have nitro or anything?
no ofc not
for some reason the emoji doesn't send
it just sends its name
but it doesn't send its id
even tho i put it in the msg
and it doesn't send the angle brackets
Is the bot on the guild where that emoji is?
yes
can you show the code you use to send it?
im tryna send the guild's custom emoji
sure
await ctx.send(":diamond:")
wait
why doesn't the id show
the id was invalid probably
yes ^
when the bot sends it?
oh ok
you could also do
const emoji = <client>.emojis.cache.get("emoji id")```
alternatively
oh ok
wait how do i get the emoji id for animated emojis
if i don't have nitro
cuz doing \
before the emoji doesn't work
there are other ways around, like using a bot that show's your emoji list
maybe there's a way to find it by name in dicsord.py? ?I don't know that lib so I can't really say
common typo
oh ok thx
pythong
would there be a way to use multiple discord libraries together?
i use discord.py but is there a way to use discord.js too?
That wouldn't make much sense
what are u trying to do like a interaction between js and py?
I mean you can start two different bot codes with the same token, that works
but you can't "mix" them
you can use nodesocket which will only work in unixbased system but not so efficent
well technically you can (It's weird and not suggested and a lot of ppl will hate me)
why would you mix both anyways
both are not even meant for the same programming language
so why
it was only a question to see if it was possible
What exactly are you trying to do
dont know it was only a question
pretty sure its not
import subprocess
subprocess.run("node", "index.js")
it's weird and stupid
unless you wanna port over discord.js to python or discord.py to js
interesting
technically you could have both processes running a an api or something
i only asked because discord.js has more users and documentation
they could communicate using http requests
but my bot is already made in python
but like
rewrite it
i dont feel like switching'
in my opinion either use 1 lib or don't
using 2 libs meant for different languages at the same time is dumb
im gonna try that out akio
Be like me and code the whole bot from scratch just because you installed 650 npm modules
eh okay but im trying it anyways
i mean yeah obv
yes
also would any of you know how to take heroku and have it install a github repo
heroku's docs probably explain it.
ah fair
heroku does pip install but it cant just only do pip install for a hithub repo
github*
so it cant find my module for my pag help command
so ill have to figure that out
thank you
Anyone knows a libary,which evulates a expression without eval an returns a boolean
Like: "1==1&&2==3" would be false
whats the concern about eval?
for drag and drop in html
the element which is being dragged, looses some opacity.
Can we stop that?
eval is dangerous .I want to use User expressions
eval can get into your computer files i hear and some other dangerous stuff so its highly despised ig
but you can make it owner only so its not that bad
u can always eval in a vm
there are open eval bots even
only way to "parse javascript" without doing an eval is... well... You have 2 choices.
- You can write your own custom javascript parser that will do simple exact operations that you've pre-determined as valid, making for a very limited language
OR - You can actually do an eval, but, inside a docker machine running something like the
pistonengine which ensures it's impossible to escape the sandbox. This makes for a very valid and fully functional eval but one that takes a lot of power to run and is complex to setup.
inefficient
atm i follow 1
I've done some pretty extensive research on this, and every module except piston has very blatant security flaws letting you escape the "vm" itself. You need some docker shit for this to work
I have a giveaway command and it has a setTimeout function. I am planning to make a giveaway end command but how do i actually stop that timeout? (we can use clearTimeout but then how do i stop only that timeout whose giveaway was ended using that command and not all?)
That's why i never use eval.I parse everything
map your giveaway by an assigned id, and have that map somewhere accesible, for example in ur client
you need to keep a list of all active giveaways and their data in a database, as well as an in-memory list of running giveaways. Upon reboot, your bot would read the database and read the active giveaways, restoring the various timeouts. I'd suggest looking into node-schedule which is much more powerful than a simple timeout.
i do something similar for my reaction collectors
Giveaways bots that persist between reboots are actually a fair bit of complicated code tbh 😄
this is what i ended up doing
the timers key is just a Node.Timeout
so it'll run when it ends
ok
i have that tbh
what i wanted to know was say i have two giveaways going on, A and B, both A and B are supposed to end tomorrow, but i use giveaway end command to end A right now
The giveaway A would end but how do i end the timeout that's still working in the giveaway function? if i use clearTimeout(), wouldn't it end both A and B?
map your giveaway by an assigned id
ok
i literally explained a good way you could do it too
wait a sec i have a helper for it if you need it
yes, i guess
why do everyone go for giveaways or music bots? not kink shaming, but there are so many out there already

actually mine is a multipurpose
because they're simple/popular
thats even worse tho
giveaway is basically a one-liner
multipurpose bots dont grow anymore
and music is most plug 'n play if you don't mind the bug overflow
Usage is commented
if u doing it for fun, thats fine
but i would discourage making a multi purpose bot to get it famous
yea too much bots
its been a couple years now that multi purpose bots dont grow anymore
why typeof something !== 'undefined'?
which line?
they would need to still save that timeout variable somewhere
which is exactly what i was suggesting with my chat
why? he only needs the name?
timeout.start(callback, 1000, 'giveawayid');
like this
oh i see
well yeah, that'd work i guess
prob need to be careful though
by the time the giveaway ends, message might not be present anymore
it supports browser too
like, undefined is already falsey ain't it?
so just !module would suffice
or !window, !global, !self
no idea why maybe i was bored
module is a node.js global, there's no module in the browser
if they were to do !module they would get the errror "module is not defined"
typeof module !== "undefined" checks if module is defined
nope
run that code in your browser and then run !module
Hi
ah I see, typeof also catches not defined exceptions
Rake probably didn't write that if they don't know why they wrote that lol

That code was made to support old browsers
is there any browser that still don't support let?
¯_(ツ)_/¯
internet explorer 11
Damn was about to say it
The code Rake sent is overkill if you're only executing it in Node.js, and barely readable too
Actually wait, I think even IE11 supports it, and it's IE9 and older that doesn't or some shit
haha
although that IE partial compatibility is practically irrelevant
there are very few possible ways not having individual let instances would wreck stuff
I don't mean that, I mean that partial compatibility
as in the second screenshot
other than that, IE seems to support it
y dont they delete IE from this world??
IE to perish soon
banks
next year 2022 june
send it to mars
Still maintaining their cobol and FORTRAN code base
There are still pc with windows 98 in europe
burn them
moon or country?
Europe is a continent
also is america but we don't talk about that here
How can I check if a category exists? 😮
with name id?
Some people use Win98 by choice
some people are insane
client.channels.cache.find(x=>x.name==name&&x.category) @brave tendon
oh thanks 😄
Well regarding the shitshow Windows 10 is people still use XP and for a good reason tho
Even if getting something to run on it is horrible
some part of win 10 is still based on xp
having access to the internet is a hell of a lot better than standing your point about an os
you can still support older browsers that don't have let by compiling down
downpiling
cough cough typescript transpiler cough cough

yis
if only it was this simple
i really dont get people not using ts even in lax mode which would really not have any meaningful difference than simply using js
just some extra intellisence from whatever libs have it shipped along
230% cpu usage @quartz kindle
though its using workers now
there should be 7 threads dealing with the absurd amount of presences now
lel
why does adding a number to parseInt(mystring) return a string with the number at the end
welcome to Javascript where nothing makes sense
welcome
wot
yeah
you're probably adding a string to it not a number
m is not a string here
and this is the kata i was doing this for:
https://www.codewars.com/kata/54a91a4883a7de5d7800009c
used: and then the actual array
stringementer
hey
arnold
JS for the most part makes sense. Logic is predictable
It can be strictly typed as well which is good
why null's type is an object is beyond me tho
const checkSpooky = setInterval( () => {
const server = bot.guilds.cache.get("801048326514409502");
if(server.name !== 'Spooky Month') return;
bot.channels.cache.get("841977665672970240").send("Server name is Spooky Month :white_check_mark:");
clearInterval(checkSpooky)
}, 5000)
This is code to send a message when going from a official name to Special name
how do i send a message when going from special Name to normal name?
use a else if statement
oh its you again
i will have a decent amount of special names
could i just use else if ?
i think so
but idk how the event would work
thats why im asking in the first place lmao
Checking every second for something that might happen like 12 times a year is ridiculous especially if you have a guildUpdate event
hi
So,im getting a
Error: Cannot find module 'discord.js'
Require stack:
Error, but Discord.js is clearly installed.
You could run npm install in your project directory to reverify.
show your package.json file
and show your package.json as well as snails said
{
"name": "simple-discord-bot",
"version": "0.0.1",
"description": "A simple discord bot, mainly used as a template.",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"express": "^4.17.1",
"graceful-fs": "^4.2.4",
"quick.db": "^7.1.2",
"ms": "^2.1.3",
"moment": "^2.29.1",
"moment-duration-format": "^2.3.2",
"os": "^0.1.1",
"cpu-profiler": "^2.1.1",
"cpu-stat": "^2.0.1",
"figlet": "^1.5.0",
"util": "^0.12.3",
"g-i-s": "^2.1.6",
"twemoji-parser": "^12.1.2",
"imageapi.js": "^1.3.2",
"canvacord": "^5.1.0",
"discord-rich-presence": "^0.0.8",
"discord-rpc": "^3.2.0",
"discord.js-pagination": "^1.0.1",
"canvas": "^2.8.0",
"node-fetch": "^2.6.1",
"humanize": "^0.0.9",
"got": "^11.8.1",
"erit-ytdl": "^0.1.3",
"soundcloud-downloader": "^0.2.4",
"simple-youtube-api": "^5.2.1",
"discord-ytdl-core": "^5.0.1",
"string-progressbar": "^1.0.3",
"path": "^0.12.7",
"fs-extra": "^9.0.1",
"fs": "^0.0.2",
"opusscript": "^0.0.8",
"sequelize": "^6.6.0",
"sqlite3": "^5.0.2",
"ytdl-core": "^4.4.5",
"amethyste-api": "^1.1.4",
"randomstring": "^1.2.1",
"sourcebin_js": "^0.0.2",
"html-entities": "^2.3.2",
"snekfetch": "^4.0.4",
"@wordpress/html-entities": "^3.0.0",
"@types/html-entities": "^1.2.16",
"superagent": "^6.1.0",
"jimp": "^0.16.1",
"discord.js": "^12.5.2"
},
"engines": {
"node": "12.x"
},
"repository": "https://github.com/KeemROH-Development/Simple-Discord-Bot/",
"license": "MIT",
"keywords": [
"node",
"bot",
"discord"
],
"author": "repl.it user <replituser@example.com>"
}```
That's been a Base Package.json I use in all my projects.
I've tried npm install discord.js
I've tried completely removing the package then re-installing it.
jesus christ so many dependencies
Yup, its a multipurpose bot lol
Eh, not necessarily.
You probably don't need most of them
For example, the fs package comes with Node.js
glitch, premium.
did you add discord.js using the "add package" button?
Correct.
run enable-pnpm in the console
Running...
ls node_modules/discord.js?
Now its just stuck on: .../node_modules/register-scheme install: Done - One second, working a fix.
-_- mhm k
lmao
lmfao, Me spamming Alt+Tab waiting for it to go off that one thingy
More people should use docker for hosting. I think digitalocean will host a container for $5 a month or so.
just trying to help yo, many of those packages are literally useless
like literally literally
lmao
now go clean your deps
Haha yes. Don't start a project with a base package.json. install as you need something.
you mean footer icon?
Yes.
i belive its
Mhm. 👍
You should try running du -sh on your node_modules
O_o
yes
Ah yes lmao
may I introduce you to npm install no-one-left-behind
It's a great package
You basically will never have to do npm i again!
I recommend
of power
How can I make a lockdown command in discord.py that locks every channel for everyone?
how can i make that it will give the amount by the animal it choose, it did not work for me and i dont know what to do? https://sourceb.in/vcWvRIggsx
i hope i explained it better now^
hey!
for channel in ctx.guild.channels:
pass # set permissions and stuff
setTimeout(() => {
message.channel.send(embed2)
}, 5000);
}
{
item1 = opponent1[Math.floor(Math.random() * opponent1.length)];
item2 = opponent2[Math.floor(Math.random() * opponent2.length)];
const embed3 = new discord.MessageEmbed()
.setColor("RANDOM")
.setFooter("Pokehub Coordinates || PVP")
.setDescription(`${item1}`)
setTimeout(() => {
message.channel.send(embed3)
}, 5000);
const embed4 = new discord.MessageEmbed()
.setColor("RANDOM")
.setFooter("Pokehub Coordinates || PVP")
.setDescription(`${item2}`)
setTimeout(() => {
message.channel.send(embed4)
}, 5000);
}``` why is 1 timeout working, and thenit just spams the rest of the code
without checking for other timeouts?
timeouts are asynchronous and don't care about the scope outside of them
but maybe your issue is with the message.channel.send
What exactly are you trying to do? Analyzing your code is difficult since you haven't well-defined a hierarchy via indentation and formatting.
Are you trying to send one embed, said 5 seconds, send the next, wait 5 seconds, and send the last one?
yup!
Then you need to nest the timeouts inside one another.
Ok, just a quick question, so i know that "rainbow roles" arent allowed on discord, but for example lets say you had a role that every 10min went from dark green to light green, and then 10min later went back to dark green, repeated. Would this also count as a violation of TOs? If so, is there any way around it in which it wouldn't count as a violation, also please note this is a bot thats only ever going to be in a single server changing a single role.
There are a few issues with your source code:
- You repeatedly access the element from the index randomly generated by creating multiple conditional statement. Instead, I recommend you replace this for a switch statement and have a variable to set.
- You declared the
moneyeevariable in the local scope of the if conditional block. It won't be available outside it. - In the database, you're writing the value of
random_moneyinstead of the random money selected.
For example, you could do this instead: ```js
const animals = [
"lion",
"fox",
"moose",
"sheep",
"raccoon",
];
let index = Math.floor(Math.random() * animals.length);
let money = null;
switch (animals[index]) {
case "lion": {
money = 4000;
break;
}
case "fox": {
money = 2000;
break;
}
// ...
}
// money should be a number by now. Write it to the database and do whatever else you need with it (such as sending the amount to the user in a message)
Discord does not have a well-defined interval for the time span between API requests. The current consensus is it should be "reasonable". If you think 10 minutes is reasonable, go ahead. If you don't, set it at something higher (such as an hour or a few).
ok, thanks
hmmm?
tysm
In the setTimeout function you pass, you create another setTimeout inside it. For example:
setTimeout(() => {
console.log("Awe");
setTimeout(() => {
console.log("some");
setTimeout(() => {
console.log("sauce")
}, 1000) // 1 second (+ 2 from the previous two)
}, 1000); // 1 second (+ 1 from the previous one)
}, 1000); // 1 second
Run it in your browser to experiment
the problem is, is that each 2 embeds are started and closes using a {}
so it wouldd look like this:
setTimeout(() => {
setTimeout(() => {
setTimeout(() => {
message.channel.send(embed2)
}, 5000);
}
{
item1 = opponent1[Math.floor(Math.random() * opponent1.length)];
item2 = opponent2[Math.floor(Math.random() * opponent2.length)];
const embed3 = new discord.MessageEmbed()
.setColor("RANDOM")
.setFooter("Pokehub Coordinates || PVP")
.setDescription(`${item1}`)
message.channel.send(embed3)
}, 5000);``` see the issue occuring?
i thought it said po*nhub for a second and i got scared
in the footer
One issue crippling your program is the formatting. It's hard to visualize
I don't know what's going on outside the scope of the code you've shared, but the example I've shown you is a solution to your problem.
🙅♂️
let me give you a skeleton structure:
{
const embed1 = ...
setTimeout(() => {
message.channel.send(embed1)
}, 5000);
}
{
const embed2 = ...
setTimeout(() => {
message.channel.send(embed1)
}, 5000);
}```
Why are you forcing the two to be independent
also for future reference I recommend you read this
https://javascript.info/coding-style#indents
this triggers me more than it realistically should
no
How do I make it so like a var, let, or const is not local to like an if statement?
You can raise the scope the variable is part of.
Or you could use var to raise the scope to the function scope
You may want to research the kind of variables and what they do in JS
let name;
if (true) {
name = "value";
}
I need help fixing 2 issues. 1st, it doesn't select the correct message, it selects the message above the attended message. 2nd, if args 0 isn't a correct message, or there is a space after the message id it goes through and gives me an error.
Can... you show your code?
i have a levels system for my friends bot and i was wondering if i can make it so it would show how much xp a user needs to level up....
@client.command()
async def level(ctx, member: discord.Member = None):
if not member:
id = ctx.message.author.id
with open('users.json', 'r') as f:
users = json.load(f)
lvl = users[str(id)]['level']
xp = users[str(id)]['experience']
await ctx.reply(f'You are at level {lvl} with {xp} xp points!')
else:
id = member.id
with open('users.json', 'r') as f:
users = json.load(f)
lvl = users[str(id)]['level']
xp = users[str(id)]['experience']
await ctx.send(f'{member} is at level {lvl} with {xp} points!')
heres my level check command

