#development
1 messages · Page 424 of 1
🤦 no
;)
do you have like a variable set as token to login with
NO MY LORD
listen agin I get an error http://prntscr.com/johavd and then i make a new bot and put the exact same code in and it works, why doesnt my old bots tokens ever work?
i use bot.log("token")
so you just copied your code
ok bye
...
the only way you get that error is because you have an invalid token or something like that
regen ur token and use the new token
const { Client } = require('discord.js');
const client = new Client();
client.login('BOT_TOKEN');

l.eval const superagent = require('superagent')
superagent.get('https://discordbots.org/api/bots/365958655926992896/check')
.set('Authorization', 'BOT_TOKEN_WAS HERE')
.query({ userId: '231733082804322304' })
.end((err, response) => {
console.log(response.body);
});
anyone know how to store the number from response.body https://mrsheldon.me/images/523590.png ?
I want to do msg.channel.send(variable);
and get 1 or 0
ik
does it even matter? the thing is works
I get { voted : 1 } in the console
I want to send this "1" in the chat
can you do console.log(typeof response.body) ?
yes
JSON.parse(response.body).voted
it says object
okay
o
its parsed already
so just do msg.channel.send(response.body.voted)
i need help me this please?
guys?
anybody help me?
I'm heroku here
help meee
!!!!
https://zxbyte.plays-with.me/7288bd31.png reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
how?
and answer the questions
learn js
oof
make sure the needed dependencies are in this file and you can push
don't remember where but you need to specify that the app is a node.js one
i have nodejs here... So?
lemme see
in the settings tab
you have a thing called buildpacks
I think you can add node.js
hey look this buildpack
i can remove it?
hmmmmmmmmmm..... https://zxbyte.plays-with.me/ba837a4c.png 🤔
try to deploy again
https://zxbyte.plays-with.me/e2f6856d.png I deploy again but is nothing happens
i pushed it
not package-lock.json but the valid one
because heroku needs it so it can know what dependencies your bot needs
const discord = require('luki.js')
const superagent = require('superagent')
superagent.get('https://discordbots.org/api/bots/365958655926992896/check')
.set('Authorization', 'MY-DBL-TOKEN-WAS-HERE')
.query({ userId: msg.author.id })
.end((err, response) => {
console.log(response.body.voted);
var check = response.body.voted;
if (check == 1) {
msg.channel.send("You already upvoted today")
} else {
msg.channel.send("GO UPVOTE!!!")
}
});
@gusty topaz thanks for the help
Damn my laptop can't connect to my WiFi

Better use === for comparisons in JavaScript @upper ember
Unless you specifically don't want it
does your bot have a data storing of some sort? a json or db?
is it for credentials or legit storing data from discord?
Yes
Which one are you replying with "Yes" to?
nice, you can forget about it then if you will be using heroku
I never use heroku anymore
choose a priority: either you want to host on heroku or have your bot to store data you wanted
oh?
What.
then what is that above in screenshots? 🤔
Horuke.
heroku doesn’t support persistent database btw
or more specifically, heroku has github-like data or something
i watched tutorials video so much
if you’re using js use https://glitch.com
it’s shit but better than heroku
moving from shit, and recommending shit
still better than shitty heroku and so what it’s a okay for a simple bot
do people not hear about skysilk? they are in open beta which gives you 100% discount, plus they will have a free plan after closing beta soon
¯_(ツ)_/¯
glitch is ok for starting bots
but when your bot grows it won't be that good of a choice
And it'll be time to move to a proper VPS
Keeps saying the ping is 0ms, just wanna check that this is working right. Discord.py async
# ping command
@bot.command(pass_context=True)
async def ping(ctx):
"""Ping the bot."""
before = time.monotonic()
ping = (time.monotonic() - before) * 10
embed = discord.Embed(title=f"Pong! `{int(ping)}ms`", color=0x176cd5)
embed.set_author(name=ctx.message.author, icon_url=ctx.message.author.avatar_url)
await bot.say(embed=embed)```
Probablt because you are basically doing before - before in ping var?
bc you should calculate the ping value after awaiting
you should do datetime.datetime.now() - ctx.message.created_at
This has the flaw that discord time and bot time need to be synchronized
Does anyone know how to use Node.js to download an image from a URL?
I would use classic http request module
snekfetch or superagent
request (npm install request) does the job too ^^
@gilded thunder you could try setting a time (before) then execute typing then set the after time and do a time delta
t1 = time.perf_counter()
await ctx.channel.trigger_typing()
t2 = time.perf_counter()
don't forget to import time
docs on pref_counter() https://docs.python.org/3/library/time.html#time.perf_counter
Hi
I'm trying to have the bot status have the server count plus another message
I set a variable to get the number of guilds
And I added the command to set the status and game
console.log('I am not dead.....yet');
client.user.setStatus('online', numguilds + " servers | ;help");
});```
It is not working, no errors in console
help
please
@earnest phoenix I think setStatus was deleted. Try setPresence instead
Hmm
How did you do the setPresence?
I just replaced setStatus with set Presence
https://discord.js.org/#/docs/main/stable/class/ClientUser?scrollTo=setActivity
https://discord.js.org/#/docs/main/stable/class/ClientUser?scrollTo=setPresence
Discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
ok
Or that
what is that white bit called at the bottom of my website
i have tried to get rid of it.. but it doesn't work
which website?
mine
@slate basin source
ty
@earnest phoenix yep
Did you try the margins?
Like margin: 0px;
On the body
Or html
on of them
Post code to hastebin though
no one likes margin anyway...
ahhh
get SSL
weew
thanks man
lol
i have seen it on three*
it does
In my opinion
idk why im rewriting pibot
on my web?
ye
ye gud
thank you 😄
gj
quite
imma invite it 😄
still trying to find ways to advertise it
Seems cool
47 guilds ;-;
I have a dev group that can help if you like
they have like 1k
users for their bots
any help will be fantastic ❤
channel*
yea
ok
you still got the idea
if (msg.channel.nsfw === true) {
msg.channel.send("true");
} else {
msg.channel.send("false");
}
it doesn't work
do == if this doesn't work
That statement should work
I've done smth similar and it worked for me
The random.cat api hates me
9|FauxBot | at _response.transport.request.then (/home/reconal/FauxBot/node_modules/snekfetch/src/index.js:182:21)
9|FauxBot | at <anonymous>
9|FauxBot | at process._tickDomainCallback (internal/process/next_tick.js:228:7)
9|FauxBot | request: undefined,
9|FauxBot | body: <Buffer 3c 21 44 4f 43 54 59 50 45 20 48 54 4d 4c 20 50 55 42 4c 49 43 20 22 2d 2f 2f 49 45 54 46 2f 2f 44 54 44 20 48 54 4d 4c 20 32 2e 30 2f 2f 45 4e 22 3e ... >,
9|FauxBot | raw: <Buffer 3c 21 44 4f 43 54 59 50 45 20 48 54 4d 4c 20 50 55 42 4c 49 43 20 22 2d 2f 2f 49 45 54 46 2f 2f 44 54 44 20 48 54 4d 4c 20 32 2e 30 2f 2f 45 4e 22 3e ... >,
9|FauxBot | ok: false,
9|FauxBot | headers:
9|FauxBot | { 'content-type': 'text/html; charset=iso-8859-1',
9|FauxBot | date: 'Wed, 30 May 2018 15:56:59 GMT',
9|FauxBot | server: 'Apache',
9|FauxBot | 'content-length': '213',
9|FauxBot | connection: 'Close' },
9|FauxBot | statusCode: 403,
9|FauxBot | statusText: 'Forbidden' }
``` x.x
I swear lol
That's the same thing
Lol
ik
It will only trigger true if the channel is marked as nsfw
I've used it before and it was working
ye
Even though, when I start the dev version of my bot up, it posts images fine, while the live version errors out
Should i use comic sans as my vscode font 
Have you tried comic sans
nope
It's basically the most hated font of all time
lol
?
guys
newbie question here
you know when you say
await bot.say("")
you can use that for urls too
but it also posts the url
ya how do we get the image without like printing the url as a message
Embed
ik you can save it, but if you save it you have to upload it
making it
slower
correct me if im mistaken
Use an embed
Np
anybody use node-canvas?
could I post a question that is semi related to discord bots? (its about downloading an image from discord that I will use later in a bot)
How can I make an instant volume on java Player?
wdym?
^
That the volume is taken over immediately after change
how do I add custom fonts to node-canvas?
i did that already. You don't have to google it for me. nothings been working for me so far.

show code
When my laptop reconnects to the WiFi XD
async def run_cmd(cmd: str) -> str:
"""Runs a subprocess and returns the output."""
process = await asyncio.create_subprocess_shell(
cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
results = await process.communicate()
return "".join(x.decode("utf-8") for x in results)
@commands.command(aliases=["shell"])
@commands.check(checks.is_owner)
async def debug(self, ctx, *, command: str):
oof = await run_cmd(f'{command}')
await ctx.send(f'{oof}')
@commands.command(hidden=True, aliases=["pull"])
@commands.check(checks.is_owner)
async def update(self, ctx):
"""gets latest commits and applies them from git"""
await ctx.trigger_typing()
await run_cmd('git init')
await run_cmd('git remote add cookie https://github.com/Skullbite/CookieBot')
pull = await run_cmd('git pull cookie master --no-commit --no-edit --ff-only')
await run_cmd('git fetch --all')
ack = await run_cmd('git reset --hard cookie/master')
pull = pull.replace('https://github.com/Skullbite/Cookiebot', '🍪')
info = discord.Embed(description=f":cookie::fast_forward: `py\n{pull}`", color=0xa40bdb)
msg = await ctx.send(embed=info)
trying to make a pull command
asyncio and subprocess are imported
your error doesn't specify the line of error
Traceback (most recent call last):
File "C:\Program Files\Python36\lib\site-packages\discord\ext\commands\core.py", line 62, in wrapped
ret = yield from coro(*args, **kwargs)
File "C:\Users\drago\Documents\GitHub\CookieBot(test2)\owner.py", line 100, in update
await run_cmd('git init')
File "C:\Users\drago\Documents\GitHub\CookieBot(test2)\owner.py", line 19, in run_cmd
cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
File "C:\Program Files\Python36\lib\asyncio\subprocess.py", line 210, in create_subprocess_shell
stderr=stderr, **kwds)
File "C:\Program Files\Python36\lib\asyncio\base_events.py", line 1162, in subprocess_shell
protocol, cmd, True, stdin, stdout, stderr, bufsize, **kwargs)
File "C:\Program Files\Python36\lib\asyncio\coroutines.py", line 212, in coro
res = func(*args, **kw)
File "C:\Program Files\Python36\lib\asyncio\base_events.py", line 341, in _make_subprocess_transport
raise NotImplementedError
NotImplementedError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Program Files\Python36\lib\site-packages\discord\ext\commands\bot.py", line 886, in invoke
yield from ctx.command.invoke(ctx)
File "C:\Program Files\Python36\lib\site-packages\discord\ext\commands\core.py", line 514, in invoke
yield from injected(*ctx.args, **ctx.kwargs)
File "C:\Program Files\Python36\lib\site-packages\discord\ext\commands\core.py", line 71, in wrapped
raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NotImplementedError:```
thats the traceback i get
any ideas?
tried googling error
did this is what the python site said
This exception is derived from RuntimeError. In user defined base classes, abstract methods should raise this exception when they require derived classes to override the method, or while the class is being developed to indicate that the real implementation still needs to be added.
Raised when an error is detected that doesn’t fall in any of the other categories. The associated value is a string indicating what precisely went wrong.```
idk that file is provided by discord.py i dont look at the source files
Oh right. I figured that was your main bot but didn't look at the file path.
Don't know much about python, my bad
its fine lol this error just been bothering me for weeks
You know anything about discord.js?
no
Damn ok lol
Is there a way to ask questions in the awaitMessages function and get multiple responses?
So lets say
The bot says: "Hey! Can you provide me with your name."
user inputs name
Bot: "What about your age"
user inputs age
Bot: "What about your country"
user inputs country
Bot sends the data to me in dms
https://paste.ofcode.org/44LvNPayzUE6e3P43Fc5NT
Obviously this isn't the right way to do it because it doesn't work
What's this error? http://prntscr.com/joqnrr
Whats it missing access too?
the channel?
must be permissions
not a bot error
It's a permissions issue.
Hi, short Question, I have an Embed which can Users React to, I would like the User Id's of all Users that reacted, how could I do that correctly?
reactions.get('🎊').users
I get Collections for every User
But tbh I don't know how to go on, I'm pretty new to Javascript
Okay so. It should work the same as an array unless I am being dumb af.
reactions.get('EMOJI').users[0]
possibly
I try that, one moment
There's also collection maps but idk how those work.
Could I send you the Collection via DM? I don't want to spam this Channel with it
Because I get an "undefined"
Sure
Why is the bot replying to commands in DMs?
because you're not checking channel type
whats the best way to render custom fonts
is it if (message.channel.typedm.message.author.sendMessage('Commands can not be used in Dms')) ?
message.channel.type !== "dm"
you are using d.js no?
discord.js yes
message.channel.type !== "dm" message.author.sendMessage('Commands can not be used in DMs') ? @earnest phoenix
if statement
hi
#general unless it’s dev related
I was just about to put my bot back on the list
if an if statement
also
sendMessage is deprecated don't use it
use .send instead
I use sendMessages...
for every commands etc
if (message.channel.type !== "dm" (message.author.send('Commands can not be used in DMs')))?
also, I use DBM for my bot, just because i can
the code DBM generates doesn't filter bot messages
if statements are really fundamental
My bot actually has no prefix
L
what
also, what library does DBM bots go through?
ok
iirc
!= 'dm'?
yes
use the identity operator instead (!==)
What do you guys look for in an IDE?
- intellisense?
- design/looks?
- customizability?
personally my #1 is intellisense (auto complete/suggestion)
idc about looks as long as it has a dark theme and a not stupid syntax scheme
same
I care most about code completion mostly
ye
The JetBrains editor is easily the best in that category
yep
you code in c#?
yes
C# is my main language but I've been putting it aside lately
it's just depressing that it isn't natively cross-platform
in my opinion C# is better X2 compared to java
but the flaw of cross platform 😭
c# is java++
but then the mono project limits cutting edge stuff and alot of stuff
ikr
c# has everything that java has and much more
no but the funny thing is that C# is designed to be a clone of Java, but still can get things right like async/await
async/await, structs
Java doesn't have real async lul
what about javascript lmao
typed languages are always better in large professional projects
ye 😭
is slots with no profit/actual gambling bad?
oh and also if you wanna make rythm 2.0 use kotlin
better than java in every way
objectively
no arguments
no
show me an example
i dont know what kotlin looks like
fun main(args: ArrayOf<String>): Unit {}
the unit bit is optional but I used it to make a point
btw can you just do mono myapp.exe to run apps in linux?
im gonna suck at kotlin if i tried to make a bot with it
tbh
just trying to get ping with jda is complicated a bit 
what part?
what are properties methods
so like everything is methods
getContextRaw() < content
it kinda feels good
oh no
in my opinion
why properties methods
java doesn't have properties like that
no it does
"like that"
but in pure OO all properties of a class are private, and you have dedicated methods to get/set them
true
hence, "getters and setters"
i mean, you can abuse static
that's bad practice
^
btw
I didnt know u just needed to use mono <app>.exe to run c# apps in linux
lol
idk maybe java was designed with the intent of being the shining beacon of pure OO
and everyone said "ok cool" and went off and did their own thing
the real reason that java is so popular is because
of it's compatibility
its because of coffee machines
with alot of stuff

ew an m-sku
cause ur thermal throttling
or windows is doing some priority fuckery with it
241 processes tf
its kinda different you know what I mean
@worn sparrow increase the priority of your bot's runtime
self-hosted?
right click process, there should be a "priority" drop-down in the rightclick menu
i dont have a credit card so i can use my AWS stuff
can or cant
lemme just plug my sketchy hosting
cant*
owo what is this
peep my pizza rolls
@trim plinth neofetch
ok
did you know that you're paying more for a gaming laptop compared to an actual desktop with the same capabilities
that OpenVZ plan looks nice 🤔 @shy verge
i have no neofetch 
openVZ bad
its cheap boyo
KVM good
i mean OpenVZ is cheap
oh
how to neofetch
how to make bot?
wot
what linux distro are you running
Ubuntu
lol
16.04?
ok
upgrade to 18
no
time to beg the parents
lol
hey mom its 20% off, I know how you loooove discounts,
cuz this isnt really bot development chat
@knotty steeple
$ sudo add-apt-repository ppa:dawidd0811/neofetch
$ sudo apt update
$ sudo apt install neofetch


Screenfetch ey? - https://i.imgur.com/JWDlutK.png
so for some reason this server and this server only my bot can't grab the owner throwing an error
and no idea as to why
anyone else have the same issue
rip
Cant find owner 
where does one use bot cmds in this server
oh
plus #265156361791209475
it'd help if I unstacked them lol
well rip
bot is muted for some reason
¯_(ツ)_/¯
whats your bot?
@manic zealot
Mute | Case #5972
Bot
Finbot#2066 (@Finbot)
Moderator
EGGSY#3388
Reason
Responds to other bots.
05/15/2018
oh
well thats not my fault
Kinda is
fix it then
You didn't add the check
oh
then ping the mod to tell them its fixed
I thought it meant like
it shouldn't respond to other bots
I left it open intentionally but I mean.. I guess I can make a hardcode for this server
eh idk if I care enough tbh
this server will just be broke for my bot
¯_(ツ)_/¯
._.
what
well its up to you
ye idrc tbh. I might make a config cmd once I set up a database that someone could make one of the options no reply to bots
but like eh
just tryna see why I can't get server owner
well why would you want it to respond to other bots in the first place
basically you can't in this server
because its funny to use my f!fight command and make a bot fight someone else using a say command
plus other reasons
I don't really see much reason to why not to allow my bot to reply to another bot
but I guess thats just me
endless loops?
causes spam and loops are hell
^
well duh, but like anyone can make a selfbot and do the same thing if they wanna
?
I still gotta make a rate limiting thing rather than just api-end
However self-bots aren't allowed so we could report those people to discord
selfbots are against ToS
...
I mean, sometimes it does
Quite honestly, i know i'll never use a bot that responds to other bots >.>
although i make my own bots so i know i'll probably never actually use another bot 🤷
same tbh
plus, most people don't use bots to make a bot reply, and most, if not all my commands are basically spam-proof through a loop
I dont know of any that will loop
orheally
I mean
It probably wouldn't be hard for me to make a bot that causes an endless loop
yus
bots that overlap each other will cause an infinite loop
humans can just not use that command anymore
Like you do !say !say !say !say !say !say !say !say !say !help
if bots respond to each other they will start spamming help messages
and it makes other things complicated
especially in servers where there are many bots
Like if your bot has logs or stuff they log other bots deleting their own messages as well
Well idk
One thing for sure is that you don't want it to respond to a random bot
hence why I made my say command owner only :D
I was very aware on recursive loops with other bots hence why I implemented things the way they are
anyways
for the say command
I have mine locked to owner only
since I don't plan on getting my bot deleted and all lol
deleted for what?
prob api abuse
it'll probably just get muted
I meant via discord, not a server
I know, but excessive sets off red flags, resulting in deleted bots
they understand a few hiccups, so I'm not worried
the only way my bot would get hard limited is via logging deleted messages in one server, but even then its fairly normal for a 110k server
tldr; yes I know what I'm doing with my bot
code: https://hastebin.com/oliqabixeh.js
error: https://hastebin.com/kimivitabe.js
help
pls
ok
I dont think many people would even suggest to use heroku
@violet wyvern your params need a edit
exports.run(client, clientUser, message, args, guild)
Like what
And for your error
Your message param did not contain a proper message cause it does not have the channel on it
Hence the error what it pretty much exactly says
how do you do a top 10 leaderboard that works? i have this one:
if (command === 'leaderboard'||command === 'lb'||command === 'top') {
const data = await r.table('players').run();
let pos = '', dat = '', coi = '', lim = 0;
data.forEach(player => {
if (lim !== 10) {
pos += `${data.indexOf(player) === 0 ? ':first_place:' : '🔸'} #${data.indexOf(player) + 1}\n`
dat += `**${client.users.get(player.id).username}**#${client.users.get(player.id).discriminator}\n\n`
coi += `${player.coins.toString()} coins\n\n`
lim++
}
})
const embed = new Discord.RichEmbed()
.setColor('#FAA61B')
.setAuthor(`Global Coins Leaderboard`, client.user.displayAvatarURL)
.addField(`Position`, pos, true)
.addField(`User`, dat, true)
.addField(`Coins`, coi, true)
msg.channel.send({ embed: embed });
}
but it doesn't order ;-; just displays the top 10
yeah..?
you have to run through the whole array once, to sort it, then you can get only the 10 first users
xD
how long until the bots get verified usually?
1 hour - 1 week

s
?
do it in the onready event
it seems the bot hasn't loaded yet
wait there is not such thing as bot
in the code
oh
is like clientUser undefined?
weird if it's a command
Help
my profile dont show on heroku
This is mine one :l
https://image.prntscr.com/image/OCsLZd6MTkS3mhZxDCS-ZQ.png
How do I get rid of this I for got accidently deleted it. .replace(/\s/g,'')
${tempVars("link")[1].replace(/\s/g,'')}, but cant remember what i did exactly
python?
javascript
lmao
seriously having a huge brain fart
tbh you could just html parse it
thats what that ishttp://prntscr.com/jp2y2m
but that is appearing in my bot
i did something with .replace but i cant remember for the life of me
if you're talking about the & it's a & encoded for URL
true
my bot is only showing that 8k people are using it when its in server over 20k
have you tried rebooting your bot?
yep
I don't know then
${bot.guilds.array().length}
wrong one
${bot.users.array().length}
should be right?
you could remove array and length and then just do size
true
<Client>.users return all the cached users. If you want to see the most accurate as possible (It is never going to be 100% accurate if your bot is in any large server [> 200]), you can fetch all the members guild by guild and then check the users property of the Client again.
what would be a good license for a open source discord bot?
@earnest phoenix
@spring ember no i was saying it wasn't sorting them
@halcyon torrent how do i do that?
do what?
ik
about leaderboards
ok
so.. i got a way to sort my leaderboard but it puts the ones with the lowest (1, 2, 17..) at the top. could i just reverse the array?
how do i make it sort big numbers? -.-
its only sorting based on the first numbers
5,4,2
google?
didn't help
ah
If the numbers are an array you can try array.sort()
... thats what i'm already using xD
but its sorting based on the first number only
data.forEach(player => { arr.push({ id: player.id, coins: player.coins }) });
let sortedArr = arr.sort((a, b) => a - b);
sortedArr.forEach(o => msg.channel.send(`${sortedArr.indexOf(o) + 1} ${o.id}, ${o.coins}`, { code: 'js' }))
thats the code i'm using
there is array.reverse()
do i use it as well?
also that's not what sort should return
arr.sort((a, b) => a > b ? 1 : (a < b ? -1 : 0))
woah thats weird looking, but it'll sort all the coins right?
try it
okay
i'll try it in a sec but quick question, when i type node advbot.js it starts 2 versions of my bot
so the commands run twice etc
wait fixed that, it was nodemon still running xD
also that new code does the same thing
it sorts on the first coin number i think
or maybe its sorting on the user id
my goal is to have users with the most coins (in that case 402) as #1 etc
leaderboard
oh
yeah
so what happens is that you push {id, coins} object to the array
when the sort fn is called
a and b are comparing elements
and they're whatever is stored in the array
in that case is the obj you pushed
so you can't just compare a > b because a and b are actually the {id, coins} objects pushed earlier
got it?
oh yeah i think i do
so instead you want to compare the coins
a.coins > b.coins etc. complete the sort fn I sent you like that
(a, b) is correct because those will be the parameters passed in the fn
(parameter) => fn code
those are called arrow functions
its the same as writing function(a, b) {
return a.coins > b.coins ... rest of the code etc.
}
oh
so those should be (a, b) in fact it could be called anything as its just the parameters sorted will pass to the fn
oh that worked 😄 then i call reverse on it?
you could call reverse on it, or you could just revert the sorter result
if you swapped the 1 with the -1, the order would swap too
test it out and think about it
okay
reverse works so i'm okay with it
but i'll play around with it
thanks lots ❤
How to show the person's name this way? (JavaScript)
Username#0000
what lib
.tag on the user
in discord.js it's user.tag
in eris you would have to do ```js
${user.username}#${user.discriminator}
thx
@trim plinth ?
?
I use
`${message.author.username}#${message.author.discriminator}`
For get the Username#0000, more i need the username + discriminator of user mentioned, how i make this?
its right in front of you tho
`${message.mentions.users.first().username}#${message.mentions.users.first().discriminator}`
``` or ```js
message.mentions.users.first().tag
`${message.mentions.users.first().username}#${message.mentions.users.first().discriminator}`

local vars pls
also guys, how do i add 🥈 and 🥉 place here? my code is kinda weird when adding 🥇 so idk how to set it up ;-;
pos += `${sortedArr.indexOf(o) === 0 ? ':first_place:' : '🔸'} #${sortedArr.indexOf(o) + 1}\n`
thats how i do it rn ^ and it works but it only does 🥇 or 🔸
const emojis = ["first", "second", "third"]
pos += emojis[index of o]
ohhh ok, and then do || diamond thing if it doesn't match?
ugh
what library?
discord.js?.... if thats what you asking xD
no joke it's messy af
hei
@gilded plank botinfo @ornate zealot

he is
<@!ID> ^
you didnt need to ping tbh
Discord is bad with mentions
can somebody show me how to require a questions.json file (but also catch the error message)
const questions = require('./questions.js');
that'll require it
wdym catch the error message though?
because it doesn't collect the questions.json file, the output comes up as "undefined" (if I do a ${questions[i]}
whats in questions.json?
example:
"B1q1":"A simple quiz question"
}```
That's an obj, not an array.
I have the array later on in my code
just do ${questions.B1q1}
B1questions = ["questions.B1q1, questions.B1q2, questions.B1q3]
that's my array
and then I select a random one using an index
but it comes up as "undefined"
i think i see
don't add questions. to the things in the array
just set them as B1q1 etc
ok, but they need to be variables with questions inside them
hm
array of object also works
{
"question thing": {
"question": "banana",
"answer": "also banana"
}
}
something like that maybe
in questions.json
so that would make an array?
whatt?
so I wouldn't need to do the whole:
B1questions = ["questions.B1q1, questions.B1q2, questions.B1q3]?
Could you paster your code on hastebin, please?
but make it into this
B1questions = ["B1q1", "B1q2", ...]
then do ${questions[i]} or whatever
guessing that i is one of the things out of the array
"B1questions": {
"B1q1": "banana",
"B1q2": "also banana"
}
}``` this would make the B1questions array or what
@earnest phoenix stop commenting if your not helping thx
@earnest phoenix no don't do it now i see what you mean
do the array thing at the top and just do them separately in the json
random math stuff
I've tried using just 1 and it still didn't work
that's not the problem
it still says "undefined"
questions.json
{
"B1q1": "thing1",
"B1q2": "thing2"
}
your main file/code:
const questions = require('./questions.json');
const array = ["B1q1", "B1q2"];
const i = array[Math.floor(Math.random() * Math.floor(2))];
const questionChosen = questions[i];
console.log(questionChosen);
// => will return 'thing1' or 'thing2'
idk if that'll work fully since its off my head and i haven't done much like this in a while but try it
don't I need to do a
const array = [questions.B1q1, questions.B1q1]
to get them from the questions.json file
-.-
thats why you have a separate file
so you don't need that
i gave you the code you need anyways so just try it
wait so why isn't it collecting it from the questions.json file because it's a separate file
just curious tho xd
ok
// get the questions from questions.json:
const questions = require('./questions.json');
// question names, set in questions.json
const array = ["B1q1", "B1q2"];
// randomly get a name of a question from the array above
// set 2 higher or lower based on how many questions are in the questions.json file
const i = array[Math.floor(Math.random() * Math.floor(2))];
// gets the second string/question content from a question in questions.json
const questionChosen = questions[i];
// console logs the chosen question
console.log(questionChosen);
// => will return 'thing1' or 'thing2'
thats an explanation if it helps
oh so if we require the questions.json then it already knows about the variables?
ok
then get the content and (say as above) console log it
Guys in MAX function in SQL, How to get more results than one?
For example this one will only get one result:
SELECT MAX(column_name) FROM table_name WHERE condition; ```
How to get more?
wdym
Mysql?
This MySQL tutorial explains how to use the MySQL ORDER BY clause with syntax and examples. The MySQL ORDER BY clause is used to sort the records in your result set.
The code I've sent will only return one value
Just add ORDER BY DESC at the back
SELECT column_name FROM table_name WHERE condition ORDER BY DESC```
SELECT MAX(column_name) FROM table_name WHERE condition ORDER BY DESC LIMIT 10;```
SELECT column_name FROM table_name WHERE condition ORDER BY column_name DESC
LIMIT 10```
yeah
What does it do?





