#development
1 messages Β· Page 735 of 1
d
before you dive into classes
make sure to capitalize class names
example iAmRetarded turns into class IAmRetarded
i am indeed retarded
yes because it was an example
capitalization is not a requirment
its just what people usually do
you can just as well do your own thing and make all classes lowercase and all variables uppercase lol
there's only some rules to names in js
Cant start with a number
Lol
I think there are some more
cant be any built in js namespaces, such as var let const for while new in of etc..
whats the fastest http lib
if (!message.member.roles.has(dj.id) || !message.member.hasPermission("MANAGE_MESSAGES"))
Is this wrong?
With out DJ?
?
I am trying to make the command avaiable for users with dj role or for users with MANAGE_MESSAGES permissions
i removed the dj role from me an it didnt work
well that's how you have it coded
if they don't have the role or permission then...
ok
but the command send the errors
|| means or and you said you don't have the role so it's functioning as expected, right?
ok wait
if (!message.member.roles.has(dj.id) || !message.member.hasPermission("MANAGE_MESSAGES"))
return [utils.timed_msg(utils.no_perm("You need the \`DJ Role\` or \`MANAGE_MESSAGES\` permission to use this command!"), 5000)];
what's the error
it says "You need the `DJ Role` or `MANAGE_MESSAGES` permission to use this command!"
ik this isn't much of a solution but why not use &&
if they don't have the DJ role and they don't have the permission to send messages then...
how do i start using the bot
well the code is functioning as intended lmao
you don't have the role so it's returning that message
because your using ||
?
talking to Director
or should i do something like
let havepermission = message.member.roles.has(dj.id) || message.member.hasPermission("MANAGE_MESSAGES")
if (!havepermission )
return [utils.timed_msg(utils.no_perm("You need the \`DJ Role\` or \`MANAGE_MESSAGES\` permission to use this command!"), 5000)];```
ok
So I don't know where to put a part of the code can someone help me?
client.level.fetch(message.author.id + message.guild.id).then(i => {
client.level.fetch(`userLevel_${message.author.id + message.guild.id}`).then(o => {
message.channel.send(`Total messages sent: ${i.value + 1}\n Level: ${o.value}`)
})
})
...
o is null
does anyone know the max file size a bot can upload?
@twin pendant
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
at least im pretty sure thats what it means
Python question
open(some_file, 'wb') used to create a file if it didn't exist but apparently it doesn't work anymore? 
Issue solved
oh thanks spider
Can some 1 tell me how 2 send a image in a message (like the one im typing now) by a command by a embed 2 another channel.? EX:
-bugreport please send this immage in the embed 2 the super secret bug report channel >>>
ive tried multiple approaches but none seem 2 work.
@oak minnow
- Get the message content + any attatchments
- store them all in variables
- Get the channel you want to send the message to
- Either make a fancy embed or just send it raw. doing smth like channel.sendMessage(rawMessage + attatchments)
Well it wont actually tag the people, but <@&roleid>
I don't think it does anyways
For the looks 
\
Itβs possible to record audio with the discord api if I remember right. Would it be against the ToS to do that? I feel like if you have a terms of service thing you would be fine but just looking for some elseβs opinion
its possible
https://discordapp.com/channels/264445053596991498/272764566411149314/648388023070752768
You'd have to have the users' consent
it should be fine when u put it in ur bots ToS right
Hello
I have an add command for a music bot
let queue = {};
And the queue is in the file add.js
But if i want to use the queue in the play.js i can't....
you can hold the queue object in play.js and pass it to add.js so it can add to it
or make it somewhere else and pass it to both scripts
you can hold the queue object in play.js and pass it to add.js so it can add to it
How?
actually what i think what i would do is create it in some main script that requires the other two
then pass it to both
Oh okay
Ty
This is a nice idea
index.js => let queue = {};
play.js and add.js => let { queue } = require("../index.js")
But when i add i have =>
if (!queue.hasOwnProperty(message.guild.id)) queue[message.guild.id] = {}, queue[message.guild.id].playing = false, queue[message.guild.id].songs = [];
TypeError: Cannot read property 'hasOwnProperty' of undefined```
don't use require to get the queue object
you have to pass it by reference either with a method or a property
you should do it to <client>.queue to get it all files
like <client>.queue = {}; on index
and <client>.queue[message.guild.id] = {}; ln play.js and add.js
fyi that just makes the queue a property of your client object
.setImage("https://top.gg/api/widget/527625435128004628.svg")```
for some reason it's not putting any image?
should i put the link in a const?
It should be .png
uh ok
thanks
Np
those of you with bigger bots, mind discussing your backup routine with me? what do you back up, how often, and how do you do it?
currently, i have all my source code in two git repositories, one on github and one on my lan, and i backup my sql database to a remote machine every night at midnight using a simple script that does mysqldump to a bzip2'd file with a datestamp in, deleting files over 30 days old.
should this be enough? to me it seems enough, as its more than most are doing i guess.
the critical thing to me is my database. without it, my bot is basically a blank slate
Same
i can restore the bot's source code as simple as git clone --recursive, but if i lost the database...
The code is on github and on my local machine
I backup db once a day keeping that backup on vps
Once a week I put a backpack on my local machine
In case the VPS would entirely die
good plan π
should i even bother with stuff like string[] instead of using List<string> in C#
lol yeah thats been my experience, but things like bots tend to attaract skiddiots with a desire to prove themselves, dont want anyone to wipe my box or anything and have no backup to roll back to
@mossy vine isnt List<String> a linked list?
i have no idea lmao
if it is, its much slower to access an arbitary element by index, but faster to iterate the list... in that case, if youre accessing aribtary elements youre best using an array
but also arrays are garbage from what ive tried
yes, List<> is a doubly linked list
so if you want fast access to arbitrary indicies, use array
they dont have nearly as many useful methods and stuff as List
but if i dont care about speed can i just settle for List
dictionary is key value which is not what i need lol
unles youre only storing like 10 elements
25 lmao
may be ok, depends on how often you access that list
i dont care much about speed, its just experimentation stuff
its also faster to insert into a list than an array
an array must be re-allocated to insert into it
an insert into a list is just the adjustment of two pointers
client.level.fetch(message.author.id + message.guild.id).then(i => {
client.level.fetch(`userLevel_${message.author.id + message.guild.id}`).then(o => {
message.channel.send(`Total messages sent: ${i.value + 1}\n Level: ${o.value}`)
})
})
o is null
@earnest phoenix console.log(o)
Please
Maybe you don't have userLevel inside whatever you're trying to access.
Can the ID of a user-to-user's DM channel change, e.g if the user 'deletes' it somehow?
I doubt there's a way to delete a DM channel
Even if you close DMs the messages still stay there
How much does it take to get accepted for the auction system?
Not a bot

Whenever the big man gets to it really
Yh
Oops wrong channel
they're probably so sick and tired of reviewing all sorts of applications that they are probably working on an AI for that at this point, hence why the queues are long
Which, to be fair, should've been done a long time ago
Hmm...
TypeError: Reduce of empty array with no initial value
static highestRolePosition({ guild, roles = [guild.id] }: Member): number {
const reducer = (a: string, c: string) => guild.roles.get(c).position > guild.roles.get(a).position ? c : a;
return guild.roles.get(roles.reduce(reducer)).position;
}```
I set a default value
what is this error ?
my 2 bots down after this error they are longing and disconnecting again and again.
both bot on different cloud
to dm an embed is it message.author.send({embed});
yes Gerb
oh thank you
you could just do message.author.send(embed);
if you were to use it that way there is an embed option in the message
And how its possible both clouds quota exceeded on same time
@low wasp
you using google cloud?
quota for what tho? what kind of passwords are you verifying?
there isnt much we can do without more information
Lol i have no more info about that
are you using a database?
Yes
which database?
@opaque eagle you didn't set an initial value...
All I see is ...(reducer)... which doesnt have an initial value
@quartz kindle @low wasp problem solved after regenerate my both bots token.
def download(FileID):
creds = None
# The file token.pickle stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the first
# time.
if os.path.exists('token.pickle'):
with open('token.pickle', 'rb') as token:
creds = pickle.load(token)
# If there are no (valid) credentials available, let the user log in.
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(
'credentials.json', SCOPES)
creds = flow.run_local_server(port=0)
# Save the credentials for the next run
with open('token.pickle', 'wb') as token:
pickle.dump(creds, token)
service = build('drive', 'v3', credentials=creds)
Request = service.files().get_media(fileId=FileID)
FileHandler = io.BytesIO()
Downloader = MediaIoBaseDownload(FileHandler, Request)
Done = False
while not Done:
Status, Done = Downloader.next_chunk()
print(f"Download {int(Status.progress() * 100)}")```
i have achived fuck all with this ^^
^-^
just if anyone wants to know the worlds most annoying api
how dare you not add spaces between function arguments π
its javascript lul
Java === JavaScript
blasphemy
Lol imagine not being python
usual .set_thumbnail(url="")
or in python
embedVar.set_thuimbnail(url="discord url link or what ever")

@strange trout on master, format is a parameter not sure otherwise
@strange trout are you on master?
help me with example?
this is the third time i'm telling you to read the error
@charred loom Map#find requires a string or a function
ur missing a string or function in line 10 with find()
youtube is bad
wha
i did
well you have to line 10
i gave you the example on how to use .find()
:facepalm: well what do i do
@charred loom https://discord.js.org/#/docs/main/stable/class/Collection?scrollTo=find π€¦
he gaved u link
no
ok
thanks
I still did not understand, if you want to give me the direct example, if not, no
Hello
yes
I m turkish
use google translate?
ok
https://discordapp.com/channels/264445053596991498/272764566411149314/648577912789925940
https://discordapp.com/channels/264445053596991498/272764566411149314/648578270920704031
https://discordapp.com/channels/264445053596991498/272764566411149314/648580542299897866
I'm starting to doubt your knowledge of the very basics of programming
plot twist he doesnt read any answers that dont include the code he needs
@charred loom no spoonfeed
you need to understand yourself like i always do when i ask for help. they just give me links and i need to figure it out myself how to use by using the links what the guy gaved
#nospoonfeed
Directory/file doesn't exist
/ = root directory
../ = previous directory
./ = current directory
it was working earlier
so how does the file not exist now
it has same file as another bot i own so i copied and pasted that to it and now the bot is working
but it was the same as it was before when it didnt work
im confused
~/ project root
but why did it work after i copied and pasted the exact same thing
Hey I have some questions about the point bot
Is it a public bot or some self-hosted one
I want to use this bot (hopefully) so members of my discord can earn points by being active and sending messages.
Once they reach 500 points they can use the points to buy they're own discord channel. Is this possible?
And it's the "points" bot
yes
Perfect. Thank you guys. If I have anymore questions I'll be sure to ask.
we can help you with bugs or errors, #nospoons
goodluck
You said good luck like it'll be a Hassel or hard to configure
well its not going to be a 1-2-3, most peeps in discord expect stuff for free, you bot usecase applies more if patreons/donators get special roles
idk about their own channel
Then it doesn't seem possible as others said.
its feasable
Unless if they get the role they can request they're own channel
but i dont know how discord user will react to paid channels, i mean will they be able to talk with anyone since they are on their own in the channel?
how would you go about this?
It's used for personal advertising and posting update content for they're game. In this case an rsps.
RuneScape Private Servers.
So they earn points, with those points they buy the role, then request they're own channel
their*
Lmao ^^^^
if its a public bot listed on the website, you have to go to their support server
if its an open source bot, you have to host it and configure it yourself
we can help with coding and setting up hosting and shit, but we dont really help setting up public bots, they have their own support severs for that
I need some help, when i press authorise it does nothing and it won't let me invite the bot to anything. i have 2 factor auth so idk
because you didnt select a server
i have no option to
zoom out because your resolution is too low
With.... What?
2 6οΈβ£ reactions
it's probably a custom emoji
can you confirm?
ChillFish π
:six: and :six~1: are not the same. :name-number: is added when an emoji has the same name to my knowledge in the picker
unless you mean something else
yes, i know they're not the same
Mobile is having a stupid issue, when I click on one with the same name as another, but dont have nitro, it still appends the number :Thonk-1:
Like that
i'm telling you that in that message they're : six : and : six :
Doubt
not : six : and : six ~ 1 : so in theory they're the same
6β£
?
does the bot's detailed description on the website not allow script?
if it's js, that's only for certified devs
oh, that makes sense
@cunning tinsel it does that for your emotes that have the same name, so you could tell which one it is
It doesn't do that for emotes from different users
As there's no reason for that
solved, i'm removing all 2k reactions and using just : six :
the 2k one use the unicode one, the one that i was trying to use was : 6 :
what is cmds
const cmds = boatboye.commands.filter(f => f.config.owner !== true)
cmds.map(c => `\`${c.help.usage}\` - ${c.help.desc}`).join("\n")```
and i have ```js
/**
-
A very cool extended Map class!!
-
@extends Map
*/
class FancyMap extends Map {
constructor() {
super()
}filter(fn, thisArg) {
if (thisArg) fn = fn.bind(thisArg);
const results = new Map();
for (const [key, val] of this) {
if (fn(val, key, this)) results.set(key, val);
}
return results;}
map(fn, thisArg) {
if (thisArg) fn = fn.bind(thisArg);
const arr = new Array(this.size);
let i = 0;
for (const [key, val] of this) arr[i++] = fn(val, key, this);
return arr;
}
}
module.exports = FancyMap;
Map doesnt have a map function
this is what happens when i copy paste
ok how do i make it do that in the
class
so that would work
i think
Works but doesn't make sense?
beautiful
it does when your brain is js
Just return this?
oh
I mean if you never use the key value
Just returning an array would be enough
That's what the filter method in a regular Map does I think anyway
well, if you're gonna extend it like that, its always better to return itself so you can chain it
and yeah, you can call classes from within themselves, the same way you can do recursive functions
I don't know why this code doesn't work for me, it orders users in a messy way, I want to order them by xp, can you help me? :c
xp.query('SELECT id, xp, level FROM xplevel ORDER BY xp DESC', (err, rows) => {
if (err) {
throw err;
}
const embed = new Discord.RichEmbed()
.setColor('#800080')
.setTitle('Tabla de primeras posiciones')
.setFooter('Ordenado por xp');
let order = 0;
for(let i = 0; i < 10; i++) {
if(i > rows.length - 1) {
break;
}
if (message.guild.members.get(rows[i].id)) {
const user = message.guild.members.get(rows[i].id).user;
if(!user.bot) {
embed.addField(`${numbers[order]} ${user.username}`, `${rows[i].xp}xp - lvl ${rows[i].level}`)
order++;
}
}
}
message.channel.send(embed);
});
then it orders alphabetically not numerically
if your database supports it, you can use ORDER BY cast() or ORDER BY convert()
try googling those functions
@quartz kindle I already changed it to type int, thanks!
π
client.channels.map(c => {if(c.type =="voice" && c.voiceConnections == true){return console.log(c.name)}})
I was asked to make a bot music for a "radio" system and the person wants it to indicate the name of the channels that were with the bot when it restarted
How can i make this?
uh
what
client.channels.map(c => {if(c.type =="voice"){return console.log(c.name)}})
This return all of voice channels but it should only give the names of the channels in which it is connected
keep track of the channels you're connected to manually
or even better, keep track of the VoiceConnection objects manually
oh that's a thing in d.js
So I'm trying to evaluate this script but it just outputs false I can't figure out what's wrong with it.
client.guilds.map(g=>g.name + ` with ` + g.members.size + ` members, owned by ` + g.owner.user.tag).join('\n \n')
are you sure the problem is there?
@earnest phoenix could be guild owner not cached, but that should throw an error
try without the guild owner to see if it works
Okay
also, to get a more accurate number of members, use g.memberCount
members.size will return only cached members
Okay, hold on
Still not working...
Try to send this in your channel
client.channels.map(c => {if(c.type =="voice" && client.VoiceConnection.connection == true){return console.log(c.name)}})```
TypeError: Cannot read property 'connection' of undefined
Still no
"TypeError: Cannot read property 'connection' of undefined"
Client#VoiceConnection doesn't exist
what are you trying to do lol
Wait i open a translator x)
also @earnest phoenix it works for me, so there might be something wrong with you eval command
@vital lark yup this is voiceConnection i think
Maybe, but you just saw it working. I'm gonna try some more evals
yeah but he could be handling it and turning it into false
and forgetting about it
lul
client.channels.map(c => {if(c.type =="voice" && c.guild.voiceConnection.connection == true){return console.log(c.name)}})```
`TypeError: Cannot read property 'connection' of null` :/
what are you trying to do wtf
^
because sometimes it detects that "type" is greater than "bank" being that it is not so?
let type = args[0];
let bank = rows[0].bank; //bd mysql
if(Number(type) > Number(bank)){
const embed = new Discord.RichEmbed()
.setAuthor(`Retiro`, message.author.avatarURL)
.setDescription(`Al parecer quieres retirar dinero que no tienes :|`)
.setColor("RED");
message.channel.send(embed);
}
console.log them both
I was asked to list the channels to which the bot was connected when broadcasting a radio
c.connection?
@quartz kindle in another command the same thing happens, in the same embed it comes out "you only have $56 and you need $30", :c
And it detects it as 56 is less than 30
The sign is not included in "bag"
console.log them both
Is it just me or when I try fetching a message by Id and edit it to a new embed message, the embed will be gone after some time?
someone is probably suppressing the embed (clicking on the little x next to it)
I thought suppressing bot embeds went to shit recently
Can someone help me with a webhook which sends a message to a channel when someone voted for my bot?
They break alot
wdym
[Discord.js]
i tried to use message.client.guilds.size to get the amount of servers where my bot is in, it gives 1 when it should give 3/4
maybe your bot is in one server
nope, the bot is in 4/5 servers
shouldnt it be guilds.length?
let me try
btw that was an uneducated guess, ive not used d.js but i have done a fair bit of js
and most arrays and lists seem to have a length property
nope, undefined
ok, worth a try lol
it's size
are you sharding your bot across 4 or 5 shards for some reason?
hmm, well, im out π
are you using the wrong token?
(i have two tokens and if i use my dev token my bot has 2 guilds, if i use live it has 280)
client.guilds is a map, so it's size and not length.
Try logging message.client.guilds to the console and see what you get
i'm using 2 bots, one for development and the other one for the stable, soon deprecated, but i implemented the DBL api in the dev one
hm, looks like i'll have to implement the dbl api in the old one
hmm. i just had a crazy idea.
its probably completely wrong.
but what if, .size was a writeable property, and somewhere you did a guilds.size = 2 rather than == 2...
nope, first time using the guilds.size
i doubt its writeable by you anyway
yep
alright i'll spend my next 50 minutes of my life trying to figure out how to fix this, brb
You can't write to it.
alright so, little update
the bot counts the servers
buuut, DBL's card stays on 1
it takes a while to update on dbl
that is, if you made an api request to update it lol
if you made an api request to update it lol
nope, i just added
const client = new Discord.Client();
const dbl = new DBL(process.env.BOTGG, { webhookPort: 5000, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});```
and the vote thing doesn't even work
yep
i just said that i just added this, nothing else, someone said that i have to manually update the counter
never worked with anything else other than discord.js
i barely know what i'm doing π
read the docs π
already reading the docs
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size);
}, 1800000);
console.log("Stats Updated on top.gg")
});```
this should be ok, right?
but now i'm thinking about something...
since i'm using glitch.org, every change i make restarts completely the bot
rent a proper vps then
i already set up a throttle, but i'm afraid that i might accidentally request too many times to upload the stats in a small amount of time
@earnest phoenix can't afford a vps at the moment
i don't have any kind of credit card/debt card
yet
Get a raspberry pi or something similar and self host it on that
i give up, i'll see what i can do
renting a vps wont magically fix his issue tho lul
if you don't have the money to rent/buy hosting then you will have to accept the crappy service that you get on free hosts
@quartz kindle i was thinking about the same thing
wait, can i request an update every 5 minutes?
well, yeah
your setInterval wont fire immediately, the first call is always after the timeout
but the dbl module has an internal interval that also sends updates
so you'd need to disable that
or drop the package and do your own request
its not hard
i'm trying to do this because the image won't update, it says that my bot is only in one server
and the image doesn't properly update
the bot-displayed image shows 3 upvotes, but when i open the original image it shows 4 upvotes
what about the server count?
server count should update right away, but your code doesnt do that
setInterval will only fire after one full interval
(i removed the setInterval)
dm me your bot page
alright
c# process effectively communicating with minecraft
this project is a mess of languages lol
c# typescript and java
now make discord plays minecraft
good idea
stream a minecraft game controlled by bot commands
ono
oh yes
or with twitch
The ratelimit is 5/5s by default
oh ok
i need help
Get straight to the question instead of saying "I need help"
oh okay
i keep getting this error
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'pollchannel' of undefined
i know why its giving this error, because the guild did not set any channels
thats why i want to return message saying please set the channel
Code:
i did run check but its not working
You could check if pollchannels contains message.guild.id
i did
Or literally a simple try-catch
Yup, I see the if statement now
Huh
?
okay
nothing
my bot can set the poll channel but if the poll channel is not set then how do i return a message saying its not set
like when you use the poll command if its not set then return message
i check if the channel was set with if statement and its not working
if (!pollchannel)
When I run this script:
const DBL = require('dblapi.js');
const dbl = new DBL(myDBLToken, { webhookPort: 5000, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
I get this error:
ReferenceError: hook is not defined
Could someone help?
did you make sure the file was saved
or are you sure the error was thrown in that codeblock
Sometimes my bot randomly shuts down with the error message.guild.joinedAt can't read the property of 'null'
are you sure the command was used in a guild
Yes. It in in my info command and usually works. It just randomly shuts down with that error.
pls
help
pls
provide a valid token 
thx
How to make the bot write to ctx.message.author ?
.send
thx
I'm kinda confused I'm trying to reward people for voting but I'm not sure how to create the webhook that DBL connects to
you need to make your own webserver in your own language and either host it alongside your bot or in the same application @vague kite
for example in java my code looks something like this
bot.start() // do shit here
webserver.start() // port, url to listen to, endpoint, etc
Okay Thanks will give that a go
I have an economy leaderboard in my bot, in my MySQL database I have the "bag" and "bank" rows, in the command you can see the first 10 with money in the bank or the first 10 with money in the bag, but how can I see those who have more money in total adding bag + bank?
xp.query('SELECT id, xp, level FROM xplevel ORDER BY xp DESC', (err, rows) => {
if (err) {
throw err;
}
const embed = new Discord.RichEmbed()
.setColor('#800080')
.setTitle('Tabla de primeras posiciones')
.setFooter('Ordenado por xp');
let order = 0;
for(let i = 0; i < 10; i++) {
if(i > rows.length - 1) {
break;
}
if (message.guild.members.get(rows[i].id)) {
const user = message.guild.members.get(rows[i].id).user;
if(!user.bot) {
embed.addField(`${numbers[order]} ${user.username}`, `${rows[i].xp}xp - lvl ${rows[i].level}`)
order++;
}
}
}
message.channel.send(embed);
});
short PSA: webhooks are basically reverse api requests, instead of you making requests to a website, the website makes requests to you instead, which is why you need to expose a port
Haven't used sql in a while but I believe you can ORDER BY x + y @distant plank
You could also add the sum as a new collumn in your query and then order by whatever you named that
@late hill I will try :)
Hey, I'm trying to make a regex that converts every ES6 import to CommonJS require()
But it messes up the code
by the time you spend writing the regex to do it for you, you could've ported it all manually
are you that lazy
Oh yeah, I would love copy pasting a bunch of const for over 300 files
That is sure a fun thing
by the time you spend writing the regex to do it for you, you could've ported it all manually
Eh, not necessarily
why are you trying to port it anyway :)
Because I made a dumb mistake and hit convert to ES6 module in VSCode
which now means my bot doesn't work
have you ever heard of a
you know
a nice little keyboard shortcut
its called ctrl + z
it makes you undo most actions
Yes, I know that exists
Problem is I did that a while ago
for all my files
and I expected it to work on node.js
...bro, if I'm asking for help, you don't need to say convert it yourself
what else do i say thats all you have to fucking do
???
search for a website then
????
what do u want
I need help with the regex I'd like to build
Then clearly, I wasn't talking to you specifically
and the time it takes you to wait for someone who does u can just do it urself
Β―_(γ)_/Β―
calm it down xD
Now, I'm just going to respond to cry
by the time you spend writing the regex to do it for you, you could've ported it all manually
Not necessarily, its a lot of work and time I'd rather be spending doing something else
Besides, it might come handy in the future
bro how hard is it to write const package = require("package")
@late hill is working, thanks
babel might be able to help
so you have literally only 2 options
try to waste time on some regex or fucking
do the thing urself
π€¦ββοΈ
I already picked the option #1
and that's what I'm asking here: for help with it
Thanks for wasting my time then
atleast i wasted it with you
Yeah
I messed up and converted my bot to ES6 without realizing that node.js didn't support it and that Babel wouldn't be able to compile it with the code working
and I can't undo it all, so I wanted to build a regex to undo it for me
calm down dudes
Add a .babelrc to your repo
no point aruging
It'd be much quicker to make the regex to convert import to require
I already done so. Let me send it to you
Paste snippet please
Alright
"presets": [
[
"env",
{
"targets": {
"node": "current"
}
}
]
],
"plugins": ["@babel/plugin-syntax-dynamic-import", "add-module-exports", "transform-remove-strict-mode"]
}```
github is too much
You could manually type it (which is probably more efficient), but I think the problem with your script is you don't really handle anything that's a keyword. You only handle anything within braces and * as. You could add a third "OR" divider and make it catch all until it's hit a space.
just paste or hastebin 
That babelrc doesn't look correct
At initial glance
Okay hold on I'm going to my computer
You made me get out of bed
Sorry Regexr
if you don't have anything helpful to say don't say it at all
Who are you talking to
@sudden geyser Hm, I'll try that. Thanks for the tip
someone who deleted their message
np, also can you send the regex
If you want to send me the regex that you're using, I'll help you correct it. But I don't think that correcting the regex is actually the correct solution here. What you should do is configure your babyl RC properly
import\s*(?:\{?\s*(.*)\s*\}|\*\s*as\s*(.*))\s*from\s*([^;]*);*
Here's the regex
But lets try to configure babel correctly
@earnest phoenix yea thats why i deleted it not supposed to be a message you think about :)
pls stop saying babyl its babel xd
I dictated it
i wasn't just talking about the message, i was talking about your messages, but i'm not going to argue
so u just said it out and spelled it so
lul ok
yea ill leave now i have no reason being here currently
Here, I'll send you my bot code too
I added another "OR" and matched everything: import\s*(?:\{?\s*(.*)\s*\}|\w+|\*\s*as\s*(.*))\s*from\s*([^;]*);*
The groups you'll be matching and such are really up to you, assuming this is all you were looking for.
I don't want it
actually do any of you have boilerplates
ok
also you should make backups
not just for this but like incase ur pc dies or something
this is my babelrc
{
"presets": [
["@babel/preset-env", { "targets": { "node": "10" } }],
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-transform-modules-commonjs",
"@babel/plugin-proposal-export-default-from",
"@babel/plugin-proposal-export-namespace-from",
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose": true }]
],
"parserOpts": {
"ecmaFeatures": {
"legacyDecorators": true
}
}
}
I recommend using "@babel/preset-env"
as well as most of those plugins
the decorator syntax is super optional
whats that
@sudden geyser At this point, I might as well fix up the babel. Thanks though
specifically
I'll check out your babel config
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-transform-modules-commonjs",
"@babel/plugin-proposal-export-default-from",
"@babel/plugin-proposal-export-namespace-from",
["@babel/plugin-proposal-class-properties", { "loose": true }]
those plugins are helpful
klasa is bae
whats wrong with commando?
i agree
What's wrong with akairo?
p e r s o n a l o p i n i o n
i dont use frameworks in general tho i make my own stuff
There's nothing wrong with them package wise; they get the job done. It's just a preference
^
making your own frameworks is a great way to innovate new and interesting wheels
my layout i guess
is based on klasa
"framework"
command
file
nah its based on komada
Klasa just has everything I need & advanced even though it's large.
I have my own framework uwu
exports.run = (boatboye, msg, args, prefix) => {
if bruh is bruh then bruh
}
exports.config = {
aliases: [],
ownerOnly: yas
}
exports.help = {
name: "e",
desc: "eeks description",
usage: "how to use!!!"
}```
β’οΈ
I use es6 classes
i dont
why
my framework is if return
Classes are great
i dont use classes much
i use neither also
vscode >>
but i did used to use neovim
vim >
you seem to misunderstand the statement
talking about vim vs emacs vs vscode vs sublime vs whatever is pointless, meaningless garbage
no i get it
it has the smackings of substance without any substance
not very pointless
can i show some bad code
knowing the advantages and disadvantages of something lets you decide more easily
Regexr it's more just preferences than calling the other bad
people who ask you to look at their github should be called github rappers
You can use variables or just placements like SELECT * FROM store WHERE storeID = ? and have the 2nd arg be an array or object by replacing ? for $variableName
@earnest phoenix hey, do any of these modules remove the .default stuff from the end or atleast make it work without .default?
you shouldve seen the code for my first bot then
@lavish shuttle when using es6, you import default by stating import Thing from 'file'
I hate doing security research, because inevitably you just end up being a QA analyst for someone elses shitty code
idk why node has everything from ES6 except imports
its under an experimental flag lul
@lavish shuttle if you want to require() a file, and that file does export default, then yes, you need to reference it by require('thing').default
but it makes more sense to use import Thing from 'file'
@sudden geyser what are you talking about?
i
need
weed
bee
are
bee
here is a good example of how bad it was
@sudden geyser yes, import can be used in that way, but it can also be used in es6 basically as a require statement
a little sample code from my actual job:
import { readDashboardActivityLogs } from '../../actions'
import { dashboardActivityLogsSelector } from '../../selectors'
import { ActivityPropType } from './shared/proptypes'
import { t } from '../../lib/i18n'
import './ActivityHistory.scss'
export const ROOT_CLASS = 'client-activity-history'
export const LOADER_CLASS = `${ROOT_CLASS}-loader`
export const NO_DATA_CLASS = `${ROOT_CLASS}-no-data`
export const ACTIVITY_HISTORY_UL_CLASS = `${ROOT_CLASS}-activity-node-ul`
I'll try it out
once you go node, you hate going back to web
i never go to web
i do, but i hate every minute of it
i also remember trying to make a profile command
@earnest phoenix So the bot still doesn't want to do anything. I don't know how to debug it either
Oh, nvm, I got an error this time
Killed
npm ERR! code ELIFECYCLE
npm ERR! errno 137
npm ERR! yamamura-discord-bot@0.0.1 server:prod: `node ./dist/yamamura.js`
npm ERR! Exit status 137
npm ERR!
npm ERR! Failed at the yamamura-discord-bot@0.0.1 server:prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/pi/.npm/_logs/2019-11-26T20_34_45_191Z-debug.log
ERROR: "server:prod" exited with 137.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! yamamura-discord-bot@0.0.1 prod: `NODE_ENV=production npm-run-all clean build server:prod`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the yamamura-discord-bot@0.0.1 prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/pi/.npm/_logs/2019-11-26T20_34_45_590Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! yamamura-discord-bot@0.0.1 start: `npm run prod`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the yamamura-discord-bot@0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/pi/.npm/_logs/2019-11-26T20_34_46_378Z-debug.log```
just a simple "Killed"
I also get this:
< Debugger listening on (Insert Debugging link here)
< For help, see: https://nodejs.org/en/docs/inspector
< Debugger attached.
Break on start in file:///home/pi/yamamura-discord-bot/dist/yamamura.js:1
> 1 (function (exports, require, module, __filename, __dirname) { require("cache-require-paths");
2
3 require("./utils/extraFunctions.js");```
Oh whoops, I forgot to git pull
yep, nothing is happening
The bot doesn't even go online
........
I wrote my code in ES6
and I'm trying to use Babel
to allow NodeJS to run in it
Yes everything
Babel big succ
ok then
TS but that's just me
what
is babel bad
anyone know how to set up a connections authorization for a bot?
I'm like 2/3 of the way there but can't figure out the purpose of the redirect URL and how my bot is supposed to get the code out of it
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
uh you mean oauth?
yeah
ok
the redirect uri is where your user gets redirected after they authorize your app
the authorization process adds a ?code= url parameter to your redirect uri
so when your user gets redirected to your website
you can extract that code
exchange it for an access token and boom
yes that's what I was referring to
I don't have a website for my bot, so would I have to create one in order to get the oauth code?
yes
why is having a website a necessity to extracting the code?
because that's how oauth2 works
sorry, I'm not entirely familiar with how oauth works
thanks for the help
is there a way I can pull it from the api if I just use https://discordapp.com/oauth2/authorized
just trying to find the easiest way
you can't utilise oauth2 features if you don't have a website
(inviting a bot into a server is the only exception)
my bot is in a bunch of servers so could you elaborate on that exception?
the link where users invite your bot to a server
is a part of oauth2
it's the only case where you don't need a website to complete an action (because it doesn't need a redirect uri)
ah okay so that's just the oauth2 authorization for server invites
so I can't use that for getting an individual users connections
nope
alright thanks for your help
I'm not very familiar with hosting a website, but the only need I have for it is to fetch the access codes
So I need to figure out something very simple
but when someone visits I can somehow check the URL they are using and extract the code from that?
I don't have a website for my bot, so I'd need to set something up in order to get the auth codes when users authorize the bot to see their "connections"
seems a little more complicated than it needs tobe
you need a website
^
there's no other way to go around it
also oath2 has alot of stuff you need to set up with it
yeah I understand that, now I'm trying to think of the easiest way to get a website set up since my only purpose for it is to get the code
why do you need the codes anyway
a simple api server would be enough
^
like from what i can tell you dont need to get permission from the user to access there profile and personal info etc...
or grant yourself access to other files
they want to get user connections
if your hosting it yourself
user connections are accessible through a user token and through oauth only
yeah
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
but why do you need connections?
to get the users steam account so I can have my bot integrated with their steam
wouldnt it be easier just to have a opt-in feature
e.g GameStats takes your steam profile ID
and then you just need to make your account profile public
but it works just as well
someone can fake being someone else by doing that
yeah that would be easier but it also allows someone to put another person's ID in
seems a bit overkill if you ask me
yeah that's making me consider if it's worth it
gona look into setting up a simple API server first like cry suggested
cuz another thing to also make note of if you do it via connections if people use a diffrent engine, program to play the game / account then it wont work
so in some cases allowing the user to add their own accounts makes more sense
@lavish shuttle don't know what to tell you
what if I used oauth2 and made the users DM the bot with the code so I don't have to fetch it from a website
kinda seems like you don't know what you're doing with es6 tbh
or maybe you have too many variables changing too quickly in your env
problem still stands that it will only work for steam games
which rules out OW, fortnite etc...
this bot is specific to CSGO
and if they have those accounts connected to their profile then I'd be able to see those too
Could you check the bot code for me? Its on GitLab
what if I used oauth2 and made the users DM the bot with the code so I don't have to fetch it from a website
big security issue
you'd still need a website so it redirects the user to that website with the code
is that so I can exchange the code immediately and invalidate it
pretty much, the code is there acting as a protection layer
you need to exchange it for an access token
and exchanging requires you to match the client secret
but couldn't I just have the bot take the code and use it with the client secret to do the exchange
Not saying that's a good idea though
yeah
that process is so quick and automatic on most websites using oauth that the user doesn't even get to see the code
they do that by making the link redirect?
yeah
i'm doing that on a website i'm working on
basically as soon as the user hits the redirect uri the webserver attempts to grab the code from the url and just redirects the user back to the homepage
cool
yeah I'm thinking I'll just set up a simple rest api server with flask
and the bot can interface with that easily
would that be good to do what I want?
don't work with python so i don't know what you would use, but yeah a simple rest server is good
yeah my bot is currently in python but I guess the server wouldn't have to be since it's a separate entity
thanks for your help @earnest phoenix and @modest maple much appreciated
@earnest phoenix here's my bot's GitLab page in case you want to see what's going on
@paper flame you can use Django for python websites just btw
Altho defo better using js etc...
yeah, I'm a CE major so my exposure is C/C++ Python, so I'd have to learn JS
Or get someone else to do it
Coding a simple website isn't a massive issue
But you'll still need a domain
All I can say is oath2 can be a massive pain in some ways
whats wrong with js for apis?
imma just do the github update later and send it to my stackoverflow answer later
whats wrong with js for apis?
for restful json apis it's not the best among its competitors
https://www.techempower.com/benchmarks/#section=data-r18&hw=ph&test=json






