#development
1 messages · Page 1423 of 1
nah
ok
Do you have a package.json file? node . won't work without one afaik
is there a self promo
nah
oh ok
so you still haven't installed it
see, you need to show the whole console
one of my edits
looks okay
No, no. I don't have the indexes of those values, i need the second last. thats all
collection.last(2).first()
Maybe it could look like this: ```js
let keys = collection.lastKey(2); // the last two keys in the collection.
let value = collection.get(keys[0]); // second to last
Unless I'm misunderstanding.
like tim's one
did you read my question? @earnest phoenix
who
oh
i ran the .bat for it
what bat file
this is how i saved it
one
let wrole = args[1]
if(isNaN(wrole)) return message.channel.send({ embed: { color: ('#ff3636'), description: ("` | You must provide a valid role id, check to make sure the one provided it valid") } });
db.set(`whilelistedil_${message.guild.id}`, wrole)
message.channel.send({ embed: { color: ('#63f736'), description: (" | You have Configured the whitelisted role, is now set to <@&" + wrole + ">") } });
what do i do ahah
ye
zip
download the installer
ok
timmm
cheers
you saved it to whilelistedil and you tried getting it from whitelistedil
aint this how u make the welcome thing?
Yes, but that's a very basic welcome announcement.
Do you have the intents enabled for guild member join events?
me?
wdym?
do you know what a variable is
uuhhh...how do i check that
back when i did it, all i did was just putting the code in
no
:/
You need to enable server member intents on the developer portal. You then need to pass it as a client option ({ ws: { intents: [...] } })
See the docs for what intents you can add: https://discord.js.org/#/docs/main/stable/class/Intents?scrollTo=s-FLAGS
Variables are primitive to JavaScript, so it's hard to explain your answer if you don't know what one is.
See this https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/Variables
You need to make your token a string ("something")
so what do i have to do to get it working as i did the node dowload and now when i do npm install i get a error
you need to learn some basic javascript
To get it working, you should spend more time learning JavaScript in the meantime. It'll be easy to solve future errors as well.
so how can i get it up working?
aka "i dont want to learn i just want you to fix it for me"
Pretty much
java is not javascript
can u send me sommat to help me then please
Martino if you want help you need to help yourself first. Here's a good resource for learning JS: https://learnjavascript.online/
let m = await gchannel.send(gembed)
m.react(":tada:")
it is saying await is only valid in async (the video i see it in work well without async)
and when i use it without await it says m is not defined
You need to make the function that line is in async.
it works well in that video
henlo
join my discord server for help: https://discord.gg/invite/AzJkFcQ
Ok then the video did that in an async function and you are not
oof
ah yes, jquery
I can't find it that where I had to put the bot token
Can someone help me with that?
Wdym where
hello, why <collection>.findOneAndUpdate({}, {}, {returnNewDocument: true}) dont return the new document?
mongodb
@earnest phoenix i think it's just new: true
hmm
i go to try
dont work
idk then
got all first 2 pages right but stuck on this like i dont get string length at all
you spelled length wrong in your function: length not lentgth
why did you @ me lol
Can I send the script in DM?
npm ERR! code 1
npm ERR! path C:\Users\NAME\Documents\DiscordBots\Ch1ll Bot\node_modules\canvas
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c "node-pre-gyp install --fallback-to-build"
npm ERR! The system cannot find the path specified.
npm ERR! node:internal/modules/cjs/loader:922
npm ERR! throw err;
npm ERR! ^
npm ERR!
npm ERR! Error: Cannot find module 'C:\Users\node-pre-gyp\bin\node-pre-gyp'
npm ERR! at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:15)
npm ERR! at Function.Module._load (node:internal/modules/cjs/loader:763:27)
npm ERR! at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
npm ERR! at node:internal/main/run_main_module:17:47 {
npm ERR! code: 'MODULE_NOT_FOUND',
npm ERR! requireStack: []
npm ERR! }
npm ERR! A complete log of this run can be found in:
-- Here it shows other stuff --
uh
for my server info command
im trying to filter out humans and boots
bottums*
so rn when i did it bots was 0
${message.guild.members.cache.filter(member => !member.user).size}
this was my thing for getting the bots
i'd rather filter out
!member.user this doesnt even filter out bots
every bot is still a user
i dont understand why you cant use the one i sent
so rn i have a cmd that gives a random amount of coins:
Math.floor(Math.random() * 1000) + 1;
how would i make it so theres a
5% chance of getting -50 coins
or like 1% chance
basically chance stuff
you get the bots
no you dont
member.user.bot wont be true for actual pepole
ok
ig
legit just try it
but of its !member.user.bot it wont send the boots smh
i put this:
{ returnOriginal: false }
and work
that's the original document, not the one you updated but ok
returnOriginal false
OH MB
xd
oh
just messing around in js
anyone can help?
const friends = ["Alex", "Joe", "Bob", "Jeff", "Im super cool"];
if friends[7] === undefined {
console.log("poop")
}
else:
console.log(friends[7]);```
unexpected indentifier
else {...}
or else console.log(...)
or even no brackets, which will rely on whitespace
you need () around it
if (friends[7]) === undefined {
^^^
SyntaxError: Unexpected token '==='```
isnt js ifs ===?
if (condition) {...}
if(friends[7] === undefined)
@reef carbon use inspect element for the css selectors
trying to learn js without yt vids lmao
Mind if I post question again
const friends = ["Alex", "Joe", "Bob", "Jeff", "Im super cool"];
var friendcount = 4;
if (friends[friendcount] === undefined) {
console.log("poop")
}
else {console.log(friends[friendcount])}```
see im a pro
😎
Yes damn
oh how do I do that?
oh ok
Wait nvm I figured it
db pushes twice yet console.log is once playerqueue: [ '543900991569789016' ] const queue1Config = await QueueConfig.findOneAndUpdate({guildId: message.guild.id}, {"$push": {"playerqueue": message.member.id}}, function(err) { if (err) throw (err); }).catch(console.error)
can some 1 help plz error
Bot dont understand what file
hello
Const bot
Give me a sec
Try this
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
bot.commands.set(command.name, command);
}```
Change folder and other
ok 1 sec
the folder command is for the commands
not to have the message or ready event
copy/paste them into your main file
no
im trying to have some commands in difrent files
like music code will be in Music.js
ban code will be in ban.js
like that
@past needle
ys
but you don't have to make new listeners then
follow the discord.js tutorial on their website, it's good
Code your advanced command handler using Discord JS! This advanced method is a better alternative to the basic command handler. Creating discord commands can be very easy! This tutorial teaches you how to code commands for your own discord bot. Next video we will start getting into our very own discord tutorials, so much sure to let me know in t...
yes, you write the code of your commands in individual files, but since it's the main.js file that is going to be read, you have to make the bot understand what do to with those commands
it's better to look at there website I think
ok
Give me it all
how do i do an if "str" is in a var?
So i don't want to cause the ratelimit problem and i have thaugh of an idea to make an array of functions to do individually, this way whenever a function executes. The problem is that i also want it to wait a little bit before doing the next question and, it might be simple but i don't get how q---------q
js
if its a string ?
if(typeof("str") === "string"){}
so like if "e" in "reee"
oh
thats typeof?
if "reeeee".includes('e')
Webhook oluşturmayı bilen Türk varsa dm gelebilir miw
whats typeof tho?
oh ok
str.toLowerCase()
you can find in google all functions to do to a string
wait hold on i'll search for you
ty
thanks
commando still the 1 or ?
,_, ?
Webhook oluşturmayı bilen Türk varsa dm gelebilir mi
npm ERR! path C:\Users\NAME\Documents\DiscordBots\Ch1ll Bot\node_modules\canvas
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c "node-pre-gyp install --fallback-to-build"
npm ERR! The system cannot find the path specified.
npm ERR! node:internal/modules/cjs/loader:922
npm ERR! throw err;
npm ERR! ^
npm ERR!
npm ERR! Error: Cannot find module 'abbrev'
npm ERR! Require stack:
npm ERR! - C:\Users\node-pre-gyp\node_modules\nopt\lib\nopt.js
npm ERR! - C:\Users\node-pre-gyp\lib\node-pre-gyp.js
npm ERR! - C:\Users\node-pre-gyp\bin\node-pre-gyp
npm ERR! at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:15)
npm ERR! at Function.Module._load (node:internal/modules/cjs/loader:763:27)
npm ERR! at Module.require (node:internal/modules/cjs/loader:991:19)
npm ERR! at require (node:internal/modules/cjs/helpers:92:18)
npm ERR! at Object.<anonymous> (C:\Users\node-pre-gyp\node_modules\nopt\lib\nopt.js:10:14)
npm ERR! at Module._compile (node:internal/modules/cjs/loader:1102:14)
npm ERR! at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
npm ERR! at Module.load (node:internal/modules/cjs/loader:967:32)
npm ERR! at Function.Module._load (node:internal/modules/cjs/loader:807:14)
npm ERR! at Module.require (node:internal/modules/cjs/loader:991:19) {
npm ERR! code: 'MODULE_NOT_FOUND',
npm ERR! requireStack: [
npm ERR! 'C:\\Users\\node-pre-gyp\\node_modules\\nopt\\lib\\nopt.js',
npm ERR! 'C:\\Users\\node-pre-gyp\\lib\\node-pre-gyp.js',
npm ERR! 'C:\\Users\\node-pre-gyp\\bin\\node-pre-gyp'
npm ERR! ]
npm ERR! }
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\NAME\AppData\Local\npm-cache\_logs\2020-12-01T17_35_07_099Z-debug.log
PS C:\Users\NAME\Documents\DiscordBots\Ch1ll Bot>``` This makes me mad.
Anyone know how to fix all this crap?
how can i check if the message author isnt the bot in js?
Like in dpy
module not found
message.author.bot
Yeah.
if message.author.id == bot id
Yes
use !==
if(condition) return; if the condition is true then it won't read the rest of the code in the scope
and there is google to understand scope (honestly i'm not 100% sure neither lol)
o uh
So i don't want to cause the ratelimit problem and i have thaugh of an idea to make an array of functions to do individually, this way whenever a function executes another starts. The problem is that i also want it to wait a little bit before doing the next question and, it might be simple but i don't get how q------q
thats not how it works tho
oh
now ik
dont copy events into your command
make an event handler, when you making command handler
yes
he found out
@-@
Can you please upload to https://hasteb.in/ instead of a .txt attachment
I WAS ABOUT TO SAY THAT
no one wants to have to download a file to help you ^_^
But how can I send it like u guys?
Like this one here
wa
```js
your code here
```
const Discord = require('discord.js');
const bot = new Discord.Client();
bot.once('ready', () => {
console.log('Ready!');
});
const groupID = 8239314,
discordServerID = "783359880466792488";
async function getUserRoles(robloxUserID) {
const targetGroupList = (await axios.get(`https://groups.roblox.com/v1/groups/${groupID}/relationships/allies?model.startRowIndex=0&model.maxRows=100`)).data.relatedGroups.map(guild => guild.id);
const aliaseGroup = (await axios.get(`https://groups.roblox.com/v2/users/${robloxUserID}/groups/roles`)).data.data.filter(group => targetGroupList.includes(group.group.id)).map(data => data.role);
const mainGroup = (await axios.get(`https://groups.roblox.com/v2/users/${robloxUserID}/groups/roles`)).data.data.filter(group => group.group.id == groupID).map(data => data.role);
return {mainGroup: mainGroup, aliaseGroup: aliaseGroup}
}
function getPrefix(rawRoleName) {
if (rawRoleName.startsWith("|")) {
let roleName = [],
endLine = false;
spiltedText = rawRoleName.split(" ");
if (3 > spiltedText.length) return null;
for (let i = 0; i < spiltedText.length; i++) {
roleName.push(spiltedText[i]);
if (spiltedText[i].replace(" ", "") === "|" && endLine) break;
if (spiltedText[i].replace(" ", "") === "|" && !endLine) endLine = true;
};
return roleName.join(" ");
} else {
switch(rawRoleName) {
case "Field Marshal": return "| FM |";
default: return rawRoleName;
}```
Sending more hold on
no wait
@-@
if it's larger than this, USE HASTEBIN
we do not want a spam of 12 different messages. Please, just paste to hastebin and send us the URL.
np
i made a really small and simple bot in js
if anyone wants it lmk, not even sure if i can
but its just th ecode
Uhh nice what did you make
What is the bot about*
alright so what's the issue with the code? question?
Umm the bot is not working :/
lang?
how is it not working?
Can I send you the invite link to the server?
Also I hired a scripter to make me this
Surely you can describe the problem with words?
.setTitle("**POLL STARTED!** " + `${message.author.tag}`, (message.author.displayAvatarURL()))
.setTimestamp()
.setColor("#1fff00");
message.channel.send(embed2);
newMessage = await message.channel.send(embed2)
message.react('🟢').then(() => message.react('⚪').then(() => message.react('🔴'))).catch(error => console.log(error))
const filter = (reaction, user) => {
return ['🟢', '⚪', '🔴'].includes(reaction.emoji.name) && user.id === message.author.id;
};
message.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === '🟢') {
message.author.send(`You reacted: **YES**!`).catch(error => console.log(error))
} if (reaction.emoji.name === '⚪') {
message.author.send(`You reacted: **CANNOT DECIDE**!`).catch(error => console.log(error))
} else {
message.reply('You reacted: **NO**!').catch(error => console.log(error))
}
}```
SyntaxError: await is only valid in async function
What did I do wrong this time? I added the *newMessage = await message.channel.send(...)*
IF you hired someone and the thign they delivered is broken, then they should fix it. not us...
But If I tell him one last thing he will block me
you did insert the bot token, right
just make your message handling function async and that should fix it. See https://js.evie.dev/promises#async-await for details.
At the end of the code
You get the client object and use the login function
And put your token as your parameter
Bye, blocked.
Marine SensorToday at 6:27 PM
Bruh it's my 2nd day easssssy tell me step by step
Clyde
BOT
Today at 6:27 PM
Your message could not be delivered because you don't share a server with the recipient or you disabled direct messages on your shared server, recipient is only accepting direct messages from friends, or you were blocked by the recipient.
Only you can see this • Dismiss message.
Marine SensorToday at 6:45 PM
um
hayperToday at 6:45 PM
Stop dming me
And ask people in development or use googlr
Marine SensorToday at 6:45 PM
Okie so do I have to script at the end of the code so I can put the token?
hayperToday at 6:45 PM
Or else i gonna block you again
Marine SensorToday at 6:45 PM
ok
So the token is not added yet is it safe to copy it and paste it in the development chat?
hayperToday at 6:46 PM
Yes
Marine SensorToday at 6:46 PM
Okie
Marine SensorToday at 8:04 PM
Umm hayper I'm not experienced like you, I didn't find what I wanted
Can you teach me?
teach
This is what he said
And I
is there a way I change the short description color?
Not me @earnest phoenix
I tried .shortdescription but it's not working
Put your bot token. @latent cave
Explain the error.
whats the error you get when running the code?
otherwise people cant help you
did you invite the bot to your server?
Is it online?
I'll try out your code
It says bot is runing
no it should give me the roles that's connected to my roblox group
Okay that's weird
as soon as it successfully logs in, the console should display Ready! and then the bot should work
when you run the bot, using node index.js for example, it's supposed to print Ready! in the console where you run it
right great, so when you do that, it should say Ready!, in that place where you ran this
No it's not saying
@rustic nova is there a way I change the short description color?
then it's not running that code.
I tried it and it doesn't work, pretty sure this prevents it from running it
if (message.guild.id != discordServerID) return;
You're supposed to have a database? @latent cave
Use inspect element
Like i told you
oh ok
Is discordServerID your server ID? @latent cave
but isn't there a .shortdescription like .longdescription?
Hold up
@rustic nova
Inspect element can tell you which are which
Now it gives me this error
Error: Cannot find module 'C:\Users\Marine sensor\Desktop\discord-roblox-bot\index.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
npm i
Huh?
quickdb isn't even defined in your code, did you give the full code or is the raw exactly that? @latent cave
Hold up I fixed it I had to say node bot.js
I said node index.js
Just wanted to see if it works now
Yea that's what @earnest phoenix gave me
Try out the command then
axios is also not defined
"Hired" as in you paid him?
Yes I paid him
That's fucked.
We're not really here to support code someone else wrote to be honest. If @earnest phoenix can't be bothered to make this work, that's not our responsibility.
He's like if you message me again I'll block you
You paid for a service, not sure how much but that's just fucked up.
At the end of the code
You get the client object and use the login function
And put your token as your parameter
Bye, blocked.
This is what he said
ok but that's not our fault or responsibility ¯_(ツ)_/¯
we can't start telling you how to run random code made by someone - member or not
We don't moderate private transactions.
That's your risk man, sorry to say. @latent cave
That's fucked
I'd refund if someone gave me an unfinished project whether it's just missing a simple line of code or whatnot. But eh 🤷♂️
See with requesting a refund through whatever method of payment was used, if you want.
isis there a way
Sounds like you got fucked on that, if they don't want to tell you how to use it.
to check each message sent for a regex in maps?
mhm
the solution is unfortunately to at least learn the basics of nodejs and how it works, and fix it yourself ¯_(ツ)_/¯
is there anyone else to make me that bot? I'll pay :/
.setTitle("**POLL STARTED!** " + `${message.author.tag}`, (message.author.displayAvatarURL()))
.setTimestamp()
.setColor("#1fff00");
message.channel.send(embed2);
newMessage = await message.channel.send(embed2)
message.react('🟢').then(() => message.react('⚪').then(() => message.react('🔴'))).catch(error => console.log(error))
const filter = (reaction, user) => {
return ['🟢', '⚪', '🔴'].includes(reaction.emoji.name) && user.id === message.author.id;
};
message.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === '🟢') {
message.author.send(`You reacted: **YES**!`).catch(error => console.log(error))
} if (reaction.emoji.name === '⚪') {
message.author.send(`You reacted: **CANNOT DECIDE**!`).catch(error => console.log(error))
} else {
message.reply('You reacted: **NO**!').catch(error => console.log(error))
}
}```
SyntaxError: await is only valid in async function
**What did I do wrong this time?**
did you check the answer I gave you before
omg help me 
check out https://custom.discord.re/ for help on that, actually.
it should cover what you need
thank you
Oh, sorry. I didn’t see your reply. I will try it soon!
??
like i have the regex already
then apply the regex for each entry in the map
with a loop
so like
how is it possible to do a unique cooldown for multiple commands without cogs file ?
python language
let mention = /<@(.*?)>/;
const userData = usersMap.get(message.author.id);
const { lastMessage, timer } = userData;
const difference = message.createdTimestamp - lastMessage.createdTimestamp;
let msgCount = userData.msgCount;
That would depend on how your current code is setup.
you can use Map.forEach()
O
regex is a one-way "Does insertregexhere match with someword?"
so like
you test the regex against the words inside ur map
usersMap.forEach(mention);
no
it takes a function
unless mention is a matching method you've declared somewhere
Docs are really useful, tbh. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach
mention is the definer for the regex
then you need a function
it'll be something like ```js
let regex = someregex;
theMap.forEach((key, value) => {
if (regex.test(value)) {
//Execute here if true
} else {
//Else execute this
}
});
note that idk how regex is tested in js
this is just a raw example
note the word raw, it'll probably not work if you just copy-paste it
not going to
Who pinged me?
yo guys it works for all the async events i tried it out on so far.. so how it works is that it takes 3 functions
first param(function) that returns true if success(that you define) is achieved
second param(function) that returns true if failure(that you define) is achieved
thir param(async function) that is a function that returns whatever async activity you're trying to do
as per every async function.. just put the .then and or the .catch after you run this function to move on
//async looper EXPERIMENTAL
async function asyncLoop(totalSuccess,totalFail,asyncFunction){
var fails=0, errors=0
var paramErrors=[
typeof totalSuccess!="function",
typeof totalFail!="function",
typeof asyncFunction!="function",
!asyncFunction.toString().split('{')[0].includes("async")
]
if(paramErrors.includes(true)){
return Error("all three parameters MUST be functions with the last one BEING ASYNC function")
}
//errors are actual errors, fails are situations which you deemed unsuitable
//in this function, a resolve is passed ONLY if it matches your demands
//however a reject is passed ONLY if it is a total fail according to you
function looper(r,j){
asyncFunction()
.then(t=>{
if(totalSuccess(t,fails,errors)){r(t)}
else if(totalFail(t,fails,errors)){j(t)}
else{fails++;looper(r,j)}
})
.catch(c=>{errors++
if(totalSuccess(t,fails,errors)){r(c)}
else if(totalFail(t,fails,errors)){j(c)}
else{fails++;looper(r,j)}
})
}
var p=new Promise(looper)
return(await p)
}
sry that it looks spammy
that seems... overengineered
btw, ain't that doing the same as the cascade lib?
ok im gonna put an example of running the function
not exactly.. close
there r 2 params which YOU define what's a totalwin or a totalloss
what i mean by this.. is that sometimes there are gonna be values/situations that don't fit either bill
and if it aint a complete fail or a complete success..
try again
so yea u were close.. but that extra detail took a bit of work
could u give an example use-case?
mhm
like, a scenario
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/container/bot.py", line 374, in play
voice_channel.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
File "/home/container/.local/lib/python3.9/site-packages/discord/voice_client.py", line 561, in play
self.encoder = opus.Encoder()
File "/home/container/.local/lib/python3.9/site-packages/discord/opus.py", line 231, in __init__
raise OpusNotLoaded()
discord.opus.OpusNotLoaded
How Do I Fix This?
give code to where it is giving errors
ok
asyncLoop(
function(t){return t.text=="xD"},
function(t,f,e){return f>e},
async function(){return fetch(sryImTooBoredToPutExampleParamshere)}
).then(console.log).catch(console.error)
that's....not what I was expecting lul
@client.command(name='play', help='This command plays songs')
async def play(ctx):
global queue
server = ctx.message.guild
voice_channel = server.voice_client
async with ctx.typing():
player = await YTDLSource.from_url(queue[0], loop=client.loop)
voice_channel.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
await ctx.send('**Now playing:** {}'.format(player.title))
del(queue[0])
no, I mean
i do plan to simplify it by making a when function
okay so for server do ctx.guild
Hello
ik, I didn't mean a code example
i did...
oh ok
okay idk how to use yt_dl soo
Do you have a Turkish official?
sory man
ok
@earnest phoenix where are you from
i am not from turk
so I began working on it when i saw a stackoverflow question and just walked right past it today
the thing is that their question was of how to loop again an axios request and his reason was that sometimes the result was undesireable and they wanted to efficiently repeat the async call until they get their desired result @lyric mountain
my bot has been denied for not having the help menu
make a help command then?
you could just make a simple function recursion
It was denied because the person reviewing it has no idea how to use it, from either the bot itself or your bot's top.gg page. Which means, probably, not one else would know how to use it.
a function that calls itself until you tell it to stop
that seems to be a lot of bloat and overhead for a loop though
what makes that better over a simple async function, i.e.
async function doThisThing() {
let fails = 0;
let success = 0;
//loop of your preference
{
try {
await doAnotherThing();
/* handle success */
}
catch { /* handle fail */}
}
}
So yes you might want to make a help command, something that explains how to use your bot.
thank you 🙂
i am turkish
yes I think we're all clear on that at this point 😄
i could but then.. there's that obvi loophole as in it is never gonna stop until it gets desired result.. but there is the advanced option i put to just stop when certain circumstances exist
what if you don't get desired result 15 times?
make a recursion limit then
if success OR (fails > 15) return
my code is a bit longer than what u had.. above the 3 lines of comments r just error handling for incorrect parameters
so it aint some malignant thing as it looks
um.. that is where you define what a success and a fail is..
lemme show u the code example again..
this
it can be boiled down to
async function doThisThing(limit) {
let fail = 0;
while(fail < limit)
{
try { await doAnotherThing(); }
catch { fail++; }
}
}
your way uses way too much processing power for a loop
because of method overhead
and what if you define fail as not a limit but as what data you get..
so handle the result
he wants to pass a callback to define what makes the call fail, it might be wrong result instead of 404 for example
if the data isn't the desired one just throw an exception
if the result is not what you expect, count up the fail
or that
I did say it's short.. this is it if im not expecting you to put in wrong stuff```js
async function asyncLoop(totalSuccess,totalFail,asyncFunction){
function looper(r,j){
asyncFunction()
.then(t=>{
if(totalSuccess(t,fails,errors)){r(t)}
else if(totalFail(t,fails,errors)){j(t)}
else{fails++;looper(r,j)}
})
.catch(c=>{errors++
if(totalSuccess(t,fails,errors)){r(c)}
else if(totalFail(t,fails,errors)){j(c)}
else{fails++;looper(r,j)}
})
}
var p=new Promise(looper)
return(await p)
}
yes but why i'm saying it's bad is because there's a fuckton of method overhead
if you're going async, go async all the way
that would only try once more
no
it'd try until you don't throw an exception
or until fail counter reaches the limit
if you want to return a result... you can
returning will break the loop and exit the function
this will try until you tell it to stop(if(totalFail())) or if you get success by whatever you define(if(totalSuccess()))
so calling a while loop and await at same time? but mine takes more processing?
also it only works for that one condition of if you're using amount of times
async function doThisThing(limit) {
let fail = 0;
let checklist = {exit: false};
while(fail < limit && !checklist.exit) {
try {
await doAnotherThing(checklist);
} catch {
fail++;
}
}
}
How do I start creating bots?
idk if JS is able to pass variable references, so this is as far as I could think
use a library is quickest good way
Where that
discord.js, discord.py
others
there's a c library for discord kek
await is blocking so it can't be at the same time, and it does use more processing because i think im saying this for the third time now, method overhead
Thx
calling .then() and .catch() does cost more than going async all the way
general rule of thumb when working with async code anywhere is "go async all the way down"
a while loop is most blocking
what
i mean let's say each time
it takes 100 ms
to get an answer
to even ++
a while loop small like that would execute hundreds of times per ms
i don't think you understand what blocking means
yea async logic.. but when u have that many async blocks running at same time.. strange things start to happen
????????????????????
Lol
??????????????????????????????????????
👀
you're making absolutely zero sense
ok bru
while(bla) {
await something()
}
the while loop will not continue and not block, while it waits for something
then my pc just lagged when i tried that.. mb
ik in theory it shudnt but prob just a coincedence then
but i wasnt just speaking off my ass with that one
you might be confusing method blocking with serial vs parallel execution
if i change these .then .catch into try{ catch{ would it be super fast then?
lets say something is an async method
while(bla) {
await something()
}
is serial execution, it executes the method, blocks, waits for it to finish, then does it again
while(bla) {
something()
}
is parallel execution, it's going to run without blocking until the while loop is broken, it won't wait for something to finish
can you install opus without root permisisons?
super fast, probably not, but from personal experience it can shave off a good 25-150ms
bruhhh
i never tested the difference of those
very interesting
where do u have ur stuff without root perms is the real question
wdym
async programming is very funky, it took me a while to figure it out
@earnest phoenix ever messed with the proxy object?
in node?
btw the second example.. would it be wrapped in something like
var x=async function(){
while(bla){
something()
}
}
right?
var
i discovered a pretty drastic optimization flaw
.setTitle("**POLL!**")
.setDescription(q)
.addFields(
{ name: 'OPTION 1: :green_circle:', value: 'Add this reaction if you want to vote: **YES**', inline: true },
{ name: 'OPTION 2: :white_circle:', value: 'Add this reaction if you want to vote: **CANNOT DECIDE**', inline: true },
{ name: 'OPTION 3: :red_circle:', value: 'Add this reaction if you want to vote: **NO**', inline: true },
)
.setFooter(`Started by: ${message.author.tag}`, (message.author.displayAvatarURL()))
.setColor("#ff1d00");
embed.setTimestamp()
const embed2 = new MessageEmbed()
.setTitle("**POLL STARTED!** " + `${message.author.tag}`, (message.author.displayAvatarURL()))
.setTimestamp()
.setColor("#1fff00");
message.channel.send(embed);
async function myFunc() {
const response = await message.channel.send(embed)
console.log(response)
}
message.react(':green_circle:').then(() => message.react(':white_circle:').then(() => message.react(':red_circle:'))).catch(error => console.log(error))
const filter = (reaction, user) => {
return [':green_circle:', ':white_circle:', ':red_circle:'].includes(reaction.emoji.name) && user.id === message.author.id;
};
message.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === ':green_circle:') {
message.author.send(`You reacted: **YES**!`).catch(error => console.log(error))
} if (reaction.emoji.name === ':white_circle:') {
message.author.send(`You reacted: **CANNOT DECIDE**!`).catch(error => console.log(error))
} else {
message.reply('You reacted: **NO**!').catch(error => console.log(error))
}
}
)}
}```
I used it, the bot started 🙂 but the old issue (the bot reacts to wrong message) still persists. The bot should react the embed, not embed2.
hi
there's no need for that function to be async, it isn't doing any async work
I...
You shouldn't have created a new function
you could have just, y'know, added async to the client.on("message", (message) => { function
async is all fun and games until:
-> This
-> message!
-> test
-> is
-> a
@earnest phoenix check this ```js
const obj = {
str: "a",
test1() {
for(let i = 0; i < 9999999; i++) {
this.str + this.str;
}
},
test2() {
let str = this.str;
for(let i = 0; i < 9999999; i++) {
str + str;
}
}
}
let a = new Proxy(obj, {
get(target, key, receiver) {
return Reflect.get(target, key, receiver);
}
})
twice as much?
test2() takes exactly the same, or even faster, test1() takes 1000x more
this ain't even doing anything at all
what in the literal fuck
exactly
im pretty sure this is a v8 bug
copy and paste this anywhere ```js
obj = {
str: "a",
test1() {
for(let i = 0; i < 9999999; i++) {
this.str + this.str;
}
},
test2() {
let str = this.str;
for(let i = 0; i < 9999999; i++) {
str + str;
}
}
}
a = new Proxy(obj, {
get(target, key, receiver) {
return Reflect.get(target, key, receiver);
}
})
b = new Proxy(obj, {
get(target, key, receiver) {
return target[key];
}
})
c = new Proxy(obj, {
get(target, key, receiver) {
return target[key].bind(target);
}
})
d = new Proxy(obj, {
get(target, key, receiver) {
return obj[key];
}
})
e = new Proxy(obj, {
get(target, key, receiver) {
return obj[key].bind(obj);
}
})
console.time(); obj.test1(); console.timeEnd()
console.time(); obj.test2(); console.timeEnd()
console.time(); a.test1(); console.timeEnd()
console.time(); a.test2(); console.timeEnd()
console.time(); b.test1(); console.timeEnd()
console.time(); b.test2(); console.timeEnd()
console.time(); c.test1(); console.timeEnd()
console.time(); c.test2(); console.timeEnd()
console.time(); d.test1(); console.timeEnd()
console.time(); d.test2(); console.timeEnd()
console.time(); e.test1(); console.timeEnd()
console.time(); e.test2(); console.timeEnd()
the difference it makes is absurd
jesus
all it needs now is a mem leak
i didnt notice a leak, but i also didnt really test for it
but im gonna post this in the v8 issues
and see what they say
ok one last question... when u mean waits for it to finish i know that the await would only return when it has a resolve or reject state.. but would the while loop keep executing?
example1.. while loop starts.. begins waiting on something.. runs again and again and again until something is returned and then re-calls something
example2.. while loop starts.. begins waiting on something.. ONLY runs again when something returns
which is it??
the results are the same in node 12, 14, 15 and browser
sry for the 4 questions but that was my final one
await will block the while loop
^
yes example 2
await is like "I don't care what you're doing next, but you won't go anywhere until I finish my stuff"
its not synchronously blocking, so it doesnt lock the code
but while and for loops do respect the await keyword
I know I'm dumb... this way: async = await message.channel.send(embed2) ?
oh my
gh actions is still having a stroke 😔
probably caused by that one guy who hosts his bot in github actions
yikesss
it's been down for over three hours and i all want is just to release a new version of an app pls
btw for some reason I can't not see a Clicker in ur pfp cry
LOL
this means
(async=()=>{
client.on("message",(message)=>{doStuffHere;})
})()
it'a rose 😭
@distant light ⏫
what the fuck
a dude was asking..
uh
thats so wrong lmao
that effectively did nothing
how would i grab the player queue? const config = await QueueConfig.aggregate( [{ $unwind : "$playerqueue" }, { "$sample": { "size": 1 } } ]); console.log(config)
that's going to do the same with or without the async function being there
the inner function is still sync, you just put everything in an async wrapper
for no reason
client.on("message", async message => {
})
ohh u mean like that... so u meant client.on("message", async
ah u said it
lol i didnt understand it the way it was said first
config[0].playerqueue
wb just the id?
that returns name and id, is there a way to get the id?
const queue1Config = await QueueConfig.findOneAndUpdate({guildId: message.guild.id}, {"$push": {"playerqueue": message.member.user.username + "|" + message.member.id}})
split it
.setTitle("**POLL!**")
.setDescription(q)
.addFields(
{ name: 'OPTION 1: :green_circle:', value: 'Add this reaction if you want to vote: **YES**', inline: true },
{ name: 'OPTION 2: :white_circle:', value: 'Add this reaction if you want to vote: **CANNOT DECIDE**', inline: true },
{ name: 'OPTION 3: :red_circle:', value: 'Add this reaction if you want to vote: **NO**', inline: true },
)
.setFooter(`Started by: ${message.author.tag}`, (message.author.displayAvatarURL()))
.setColor("#ff1d00");
embed.setTimestamp()
const embed2 = new MessageEmbed()
.setTitle("**POLL STARTED!** " + `${message.author.tag}`, (message.author.displayAvatarURL()))
.setTimestamp()
.setColor("#1fff00");
message.channel.send(embed);
client.on("", async message => {
await message.channel.send(embed2)
})
message.react(':green_circle:').then(() => message.react(':white_circle:').then(() => message.react(':red_circle:'))).catch(error => console.log(error))
const filter = (reaction, user) => {
return [':green_circle:', ':white_circle:', ':red_circle:'].includes(reaction.emoji.name) && user.id === message.author.id;
};
message.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === ':green_circle:') {
message.author.send(`You reacted: **YES**!`).catch(error => console.log(error))
} if (reaction.emoji.name === ':white_circle:') {
message.author.send(`You reacted: **CANNOT DECIDE**!`).catch(error => console.log(error))
} else {
message.reply('You reacted: **NO**!').catch(error => console.log(error))
}
}
)}
}```
I want the bot to react to embed, not to embed2. What else can I do?
what the fuck
yes
I know I'm dumb.....but I don't know how to fix it :(
[index]
Astrah is first index
the id is the second index
first index is 0
second index is 1
How do I edit the color of the bot description text?
what do you mean by copy, paste?
r u a troll?
how do u not know what copy and paste mean?
im confused no cap
making canvas?
I know the meaning. I'm just asking, if by copy pasting you mean pasting the whole code or the parts? The reaction part it pasted from the discord.js guide and the embeds part is coded by me.
so ur saying the parts which ur showing us are the parts u pasted
that is the worst code ive ever seen
so then ur answer would be yes
how do i grab the id? const config = await QueueConfig.aggregate( [{ $unwind : "$playerqueue" }, { "$sample": { "size": 1 } } ]); let player = config[0].playerqueue.split("|") console.log(player)
const embed = new MessageEmbed()
.setTitle("POLL!")
.setDescription(q)
.addFields(
{ name: 'OPTION 1: 🟢', value: 'Add this reaction if you want to vote: YES', inline: true },
{ name: 'OPTION 2: ⚪', value: 'Add this reaction if you want to vote: CANNOT DECIDE', inline: true },
{ name: 'OPTION 3: 🔴', value: 'Add this reaction if you want to vote: NO', inline: true },
)
.setFooter(Started by: ${message.author.tag}, (message.author.displayAvatarURL()))
.setColor("#ff1d00");
embed.setTimestamp()
const embed2 = new MessageEmbed()
.setTitle("POLL STARTED! " + ${message.author.tag}, (message.author.displayAvatarURL()))
.setTimestamp()
.setColor("#1fff00");
________________________________
message.channel.send(embed);
client.on("", async message => {
await message.channel.send(embed2)
})
message.react('🟢').then(() => message.react('⚪').then(() => message.react('🔴'))).catch(error => console.log(error))
const filter = (reaction, user) => {
return ['🟢', '⚪', '🔴'].includes(reaction.emoji.name) && user.id === message.author.id;
};
message.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === '🟢') {
message.author.send(`You reacted: **YES**!`).catch(error => console.log(error))
} if (reaction.emoji.name === '⚪') {
message.author.send(`You reacted: **CANNOT DECIDE**!`).catch(error => console.log(error))
} else {
message.reply('You reacted: **NO**!').catch(error => console.log(error))
}
}
)}
}
BELOW THE LINE IS THE PASTED PART.
@viscid gale and @fierce ether
How do I edit the color of the bot description text on my top.gg page?
I tried:
.bot-description {
background: #c33799 !important;
}
``` But this edits the box surrounding the description. I just want to edit the color of the text not the whole box.
where do i put index then @quartz kindle
players react
add to array
random user from array grabs user name and id
but i need the id
#development message can someone help me please
@reef carbon think that's css styling, look up css font colors or something
@earnest phoenix whats ur issue about
let player = config[0].playerqueue.split("|").index[0] @quartz kindle
that will get the name
ok its because of the size limit for the box that r!youtube is in @earnest phoenix
if that column is a bit wider it'll display better
(node:14292) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '1' of undefined
instead of like that
if i change it to 1
github actions broke even more
@quartz kindle sorry about yesterday-
remove index lol
you never used an array before?
how do you get an item from an array?
.pull
pull is to add
mb?
you need to access the index
...
my bad
@reef carbon instead of background-color use color 
just js lol
["A", "B", "C", ...];
│ │ │ └ index N
│ │ └ index 2
│ └ index 1
└ index 0
just a visual example of an array
if you need to learn how to use arrays
ain't arrays one of the lowest possible data structures?
ah, it meant the JS array object
nvm
they are high level because low level has a lot of different types of arrays
js has only one
sometimes I wonder how js is even able to be mostly non-typed
like, behind the scenes
they have a bunch of different c++ classes for each js type
and adapt to the situation
still dosent explain what i needa do
it does tho

for example even a js string behind the scenes is split into like 5 different string types
short strings, long strings, concatenated strings, etc
@fierce ether you need to "use" the index right? but you don't understand what the index is?
imagine the IF cascades behind JS
xD

this tells you everything you need lol
that reminds me of let fruit = "Ba"++"a"
xD
actions decided to work now!
it only took 4 hours
I never fully understood how actions work
CI/CD debugging is the worst
this is all from trying to make the workflow work
lmao
Hi, so I was redirected here.
I have set my tables' width in bot description on the website to 25%
They show up full size
Any ideas?
"As a project drags on, my git commit messages become less and less informative"
try vw instead of %
Can relate lol
% for some reason freaks out in some browsers/containers
although vw is relative to page width, it'll work in this case since longdesc is also relative to page width
Very insightful. I mainly do backend in python and some javascript once in a while, so my knowledge of HTML and CSS are enough to just make a basic website 😄
Appreciate the help.
So whenever such problems occur I'm at a loss
always remember:
% = relative to container dimensions
vw/vh = relative to page dimensions
And googling such specifics is always a pain
Awesome, thanks!
vmin/vmax = relative to smallest/biggest dimension
ite i gotta ask again since here is filled with the most nodejs users.. I asked my question on stack overflow https://stackoverflow.com/questions/65077170/how-to-list-all-declared-variables-in-running-nodejs-file and it seems there are no answers.. im only getting views.. the basic idea is that I want to have some list which includes all of the declared variables from a running nodejs file(obvi im trying to achieve this from inside the program but global doesn't have)
im starting to wonder if this is really unsolveable
there's probably a way to do it, but why
because a nodejs console interface
the idea hit me when i saw someone on stackoverflow asking about some thing but the answer was some method(that they wouldnt know unless they knew)
i mean.. i learned what i learned of js cuz of the nice chrome console
not comparitively nice but the interfacing really helped
if you know all the variables being declared why cant you just write those?
can you edit the color of the invite and vote buttons?
yeah
oh
what?? im trying to make something that once you activate it, you can interact with the program through the console(the program that it's running from)
I have
a.votebutton:hover {
color: #23272A !important;
background: #c33799 !important;
}
a.votebutton {
color: #ffff !important;
background: #23272A !important;
}
``` But it only changes the color of the review button @solemn latch
do you know why?
the only way to do that is to declare all variables as global
otherwise there is no way afaik
couldnt you also just use an object?
ur missing the point
at least u get the poing BUT
nvm I figured it out
if i make a file
var xD=1
require('myFutureReadLineInterface').initiate()
there is no list that has variables like xD
remove the var
nowhere
wt
they are not accessible programmatically
with my half pick ducked code.. it is accessible programatically
as in if i enter in the console xD
it will return 1
i realised.. but is that just the way they are?
according to javascript logic.. it searches from its "local" then goes up all the scopes and only returns undefined if it really isnt defined
so logically there must be a scope where the vars and consts are owo
:{
time to look to make something else bois
hmm.. u seem knowledgeable.. is there a way to "hijack" keywords?
like there's a way to edit XMLHttpRequest that pushes all requests made through it into an arr
yes
i call it "hijacking" (personal term)
well if i can hijack const, let, and var
trust.. u can
any thing that aint a const, u can
and if that const is an object.. u can play with the keys
when it comes to using browsercode.. dependencies ARE weaknesses
don't ask.. just trust xD
the const means it cant change the type
example, you can push shit into an object
but you cant reassign
ik..
var is broken
const args = Message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
const commandfile = Bot.commands.get(command) || Bot.commands.find(command_ => command_.config.aliases && command_.config.aliases.includes(command));
if (!commandfile){
return Message.reply("What? https://media4.giphy.com/media/UnTC9o2HMyUta/200.gif")
}
...
} ``` It cannot find the returns that it cannot find the file.
var is lovely
const is A$$
so this is today's new feature in my bot... i never ever expected this was a thing
ok boomer
😏
same difference
not really owo
shush filthy millenial 😄
xDDD

c++ doesnt have a function for locale aware conversion?
lol
its not locale aware conversion, its lazy grammar conversion
for a specific language
well.. not exactly hijacking.. but i guess u know what i mean tho
@solemn latch dev senpai?
hijack is when u turn the var itself into ur own
wdym
lol
like delete XMLHttpRequest from existence?
wow i actually get to teach something yayyy
i have a questioN
and use it for something else?
dms?
yeah idm rn
i mean make XMLHttpRequests something else.. the delete from existence part.. not really ur changing it
why i call it a hijack is because lots of functions use those stuff
@quartz kindle so, in spanish, young speakers might say 'papa' instead of 'papá'... the first means potato and the second means father
so if u hijack them.. u have control
so their text would translate to 'today im staying at my potatos'
and the only way anyone is going to know is via context, computers dont do context well
but we have to support this lazy typing, where they cba to put in accents
getters 'n setters for the go
so at the same time it lowercases it... it hacks in this laziness, but only for spanish
and a hella lot of getters 'n setters
because only spanish do it apparently
What do you guys leverage for databases? I posed the question in general; however, it may be more suitable for here. I'm leveraging DynamoDB; however, I'm worried that it may cripple me in the longrun as more access patterns emerge 😬
i was told by the admin of a huge server that we needed to do this to make it friendly for lazier typists
not the same format of laziness though, apparently if i did this in portugese it would break stuff
they have different 'lazy' rules
ugh why is enter doing that sryyy
i mean, if i understand correctly, you want for example "nao" to be a valid answer for "não"
so yeah portuguese people do it all the time
the people who do this grammar shortcut only omit vowels with a reverse ` accent
@quartz kindle
i was on the fence wether to implement it or not




