#development
1 messages ยท Page 1266 of 1
I bet all mods are just gonna resign saying, ENOUGH, 1 Million BOTS testing and we approved 1%, thank you, bye.
Jk
I just got my bot Verified! ๐ฅณ
But no badge, which is a

you can thank badge hunters for that
Ah. ๐
badges should be displayed to friends only imo
File is not db
yeesh quick.db on glitch... that's gonna be fun.
For sure
Lmfao.
how can i fix this?
Wouldn't it run both
@slender thistle https://i.imgur.com/kFlrIbC.png
https://i.imgur.com/BSArmiH.png
only logged one
@earnest phoenix well first you wouldn't use glitch because you can't run your bot 24/7 on it anyway. Once you've found a better host, we'll need to see your code because just the error isn't enough.
@silent cloud what error ๐
Syntax
@umbral zealot message.js is erroring
@earnest phoenix well first you wouldn't use glitch because you can't run your bot 24/7 on it anyway. Once you've found a better host, we'll need to see your code because just the error isn't enough.
@umbral zealot True lmfao
I feel like that's d.js's weird behavior
why is noob hour always filled with people that have absolutely no idea how the hell to describe a problem.
that's why it's a noob hour :^)
true
@earnest phoenix what error does it say
wait
honestly, I feel like you missed the first part of what I said. glitch.com is not an appropriate hosting service.
Unless I'm mistaken, it's simply impossible to run quickdb on glitch anyway
Me too using quick.db
Even if so, you can't have a 24/7 bot on glitch anymore
@zenith terrace u tried
You have intsalled db?
no
no
yep they did @slender thistle
Go to package.json
+banning ping services
And install it
Okay
Glitch now straight-up bans users that keep their bot up 24/7: https://support.glitch.com/t/an-update-on-pinging-services-glitch/27311
@silent cloud what error
and they moved to hours like Heroku afaik
@slender thistle 1000 hours a month iirc
They limit the hours but more importantly, they do not let your app stay online.
aka not a full month
Glitch now straight-up bans users that keep their bot up 24/7: https://support.glitch.com/t/an-update-on-pinging-services-glitch/27311
@umbral zealot They don't need pinging services anymore
Syntaxerror: await is only valid in async function
@silent cloud so put it in an async function?
why is noob hour always filled with people that have absolutely no idea how the hell to describe a problem.
Noob hour ๐
Honestly I'll probably just fuck around with Glitch at some point
make your function async then @silent cloud
Im installed
they dont ban users, they just delete your project if they detect it trying to use a ping service
Ty
async function
@zenith terrace thats odd
that doesnt help, is there any error above that
probably
@silent cloud glitchs says module errors
i assume thats total?
@earnest phoenix have you installed discord.js
smartass gang ๐
Between 696 and 744
aka 2 hours are exhausted per month for each hour if you run 2 apps
@zenith terrace yeah
so you're telling me you coded stuffbut never actually inst
ok
I was meant to delete that message
but meh
hmmm
what does the error say
did you update discord from v11 straight to v12
update node version
^^
done updated
oh not updated :D

Yeah
wait :D
Are u trolling those who want to help u?
they're not trolling they're just the standard d.js user.
Ahahahhaha
XD
ESL, probably underage, absolutely no knowledge of javascript, using the worst possible platform. It unfortunately describes most of d.js users.
Maybe thats the reason why i stick woth discordpy
With*
actually, that gave me an idea
So i cant help d.js users 
Maybe thats the reason why i stick woth discordpy
@obtuse niche Discord.js Is better!
@obtuse niche Discord.js Is better!
Ok thanks for the info
giving errors too
@earnest phoenix Are you just copying and pasting?
honestly at this point @earnest phoenix please read this. https://discordapp.com/channels/264445053596991498/272764566411149314/757640324406313073
Is all you do is make fun of you?
You should take a course
all i want is for you to help me but here you are kidding
all i want is for you to help me but here you are kidding
@earnest phoenix We can't help someone that dose not know d.js!
or js

What's your node.js version @earnest phoenix
No
here
Just learn javascript first before developing a bot @earnest phoenix nobosy is here to spoonfeed
People that have no clue of what they are doing making stupid questions before the even look YT or Google
@slender thistle
Everyday journy
yeah I'm sure trying to re-import every single core node js feature as their npm module that's gonna work fine ๐
fs, util, http....
Lol
idk man
half of that seems weird to me considering I'm not a JS dev
???
It isnt even glitch
its u
Could you suggest me a coding program to make bot I know the glitch is too bad
@earnest phoenix node.js is not a package. node.js is the entire engine that runs your code. how to update it depends on where your code is hosted. for glitch.com you need to change its version in the "engines" field in your package.json
npm i nodejs@20.0.0
VScode
@earnest phoenix let's be clear: your current problem is not glitch, it's that you are trying to develop a bot with absolutely no knowledge of javascript. You need to learn JS before making a bot. Refer to my previous statement: https://discordapp.com/channels/264445053596991498/272764566411149314/757640324406313073
discord.js is a package not node.js, node.js is the main part of the whole system
so you run npm install discord.js
then you can follow the rest of the steps
Because at this point you've awoken all the trolls and people that step in halfway into the help process with information that's completely irrelevant.
getting help from us right now isn't going to be possible, Astrax. You need to take the time to learn the language.
ye @umbral zealot is true
so you CAN run it 24/7
@opal plank no
explain
well i found a way to run my bot 24/7 it never shuts down unless i run a command to do it
Only static projects will stay online while not using those hours
well i found a way to run my bot 24/7 it never shuts down unless i run a command to do it
And the editor also eats up the hours
Projects that have a package.json will NOT stay online
@honest perch so standalone nodejs apps stay up?
if you only have 1 app with a total of 1000 hours, you can get it, no?
don't use package.json 
I use package.json.js 
I don't get why people use glitch. I have an obsession to own the hardware I host from
If it cant be hosted on their s3 buckets then it won't stay online
Lmao
old android = free 
laptop is too weak to run
Raspis are great tbh
too weak?
I'm running a whole npm registry and proxy on mine
etc
do you think most underage kids (users of glitch probably) have a decent pc, or an old android..?
no I meant decent in the way it can stay online properly
But they dont know how to set it up
that too
Glitch does everything for you
a good amount are on school chrome books too now
Except
...stay online properly
apparently
I had a laptop
i ratio have it
still*
itโs dead
it still works
itโs just a pain to keep on
at least in my area thatโs the kind of laptop kids get
Ive run a bot from: A gaming Desktop, an android smartphone, an old Dell poweredge Desktop, and an old Gateway laptop with a broken screen
As long as it runs javascript really lol
you can run it on anything
I bet a smart fridge runs js 
your overestimating the average age/smartness thing of people using glitch though
probably
I explained to a complete beginner last night how to do an android deployment
but I gave up when they asked how to do JS. I'll help with the niche part for android/linux setup but can't teach someone to code

ESL, probably underage, absolutely no knowledge of javascript, using the worst possible platform. It unfortunately describes most of d.js users.
@umbral zealot https://discordapp.com/channels/264445053596991498/385837258768515083/758661765751111700
"avarage" is right ๐
Oh yeah well im pretty experienced at js and use vs code ๐ where's my cookie
is my cookie ๐
You probably deserve it
Is there a script for eval that I can make my bot have a mobile status?
F
you'd have to hack the library to do that
or make your own library to login into discord for you

Or make the API call
My beta branch is doing it
El chapo bot
thats just nickname
its @earnest phoenix , but the beta branch

10 mil in 15h
noice
Strawberry
.setDescription(${member.user} Welcome to Our Server + db.get(`welmessage`));
This doesnt work
@opal plank >:
Homie said quickdb
css library
definetly not
Yes
missing a
'
@faint prism where
not knowing basic javascript syntax
that's the problem
learn about how template literals work
Hey I m new to JS
๐
And need a name
@honest perch mislee

easy to say, rolls off your tongue, and feeds your ego
oh you already said mislee it is
whats the best way to implement git connection within a nodejs bot, on a linux ubuntu 16.04 machine
${sampiyon[hah.freeChampionIds].slice(0,20).join('\n')}
TypeError: Cannot read property 'slice' of undefined
So how else can I change the values of hah.freeChampionIds?
How can i make the field one above
like replace
hm i see that uh
Yeah, sampiyon[hah.freeChampionIds] the object at that index doesn't exist in that array if it's undefined
first off to use ${} youve gotta use `` notation
custom what
@faint prism How can I replace hah.freeChampionIds values?
${sampiyon[hah.freeChampionIds].slice(0,20).join('\n')}TypeError: Cannot read property 'slice' of undefined
@earnest phoenix it may also be the situation such that that hah.freeChampionIds is also an array
what is freeChampionIds
ill need to know that to be able to help
{"freeChampionIds":[3,14,23,25,38,44,45,48,54,58,79,104,110,119,238],"freeChampionIdsForNewPlayers":[18,81,92,141,37,238,19,45,25,64],"maxNewPlayerLevel":10}
Replace them?
yeah
As if it would write Test if the value is 3
alright so obviously you need to also have an index there at
[hah.freeChampionIds]
^ here
now what index, you'll define that yourself
try putting just [0] at the end, it will work
but thats just gonna give you the first id
I want to draw all the strings
then use a for loop
If I write things like [0] [15] it will give an error if there is no 15th value.
I'll try to use loop
for (let i = 0; i < hah.freeChampionIds.length; i++)
// some code that uses that "i"
i'm trying now okay.
back to my question if anyone can help:
I will use push
myArr = [3, 5, 3, 5, 3]
for (i = 0; i < myArr.length, i++) {
if (myArr[i] === 3) { myArr[i] = 5; }
}
Would set everything to 5 in this instance
whats the best way to implement git stuff on a nodejs bot on ubuntu16.04
what "git stuff"
git pull mainly
probably using child_process
Yeah child_process allows you to use exec iirc
"interacting" with it though is going to be much harder.
obviously yes
You'd have to redirect std out and std in
you would be fairly limited to commands that don't require input
local websockets!
const aktiviteler = [];
for (var i = 0; i < hah.freeChampionIds.length; i++) {
switch (hah.freeChampionIds[i]) {
case `${hah.freeChampionIds[i]}`:
aktiviteler.push(`${hah.freeChampionIds[i]}`);
break;
}
}
embedx.addField('ลampiyonlar', aktiviteler.length ? aktiviteler.join("\n") : "Yok.")
I've tried but it doesn't work.
uh
uh
:d
whats that use of switch case
you're using indexes wrong lol
why is that use of switch case
const aktiviteler = [];
for (var i = 0; i < hah.freeChampionIds.length; i++) {
aktiviteler.push(`${hah.freeChampionIds[i]}`);
}
}
embedx.addField('ลampiyonlar', aktiviteler.length ? aktiviteler.join("\n") : "Yok.")
Just gonna delete that for you lmao
thanks
ok
.setImage("attachment://hello.png")
.setThumbnail(member.user.avatarURL())
.addField("Welcome", `<@${member.user.id}>`)
.setDescription(db.get(welmessage) );```
Or you're just printing the string
hm wait lemme send u full code
the field
done
Tbh idk how to do JS string interpolation, so you can just do '<@' + someVariableHere + '>' instead
oh wait someone sent this previously
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
which is using ` and not '
Oh well. Go which ever route
just ask
you need to tell us what you need help with 
you'll only need to wait, luca will dm you regarding your bot approval, if that's what you mean
๐
hey everyone
def createFolder(directory):
try:
if not os.path.exists(directory):
os.makedirs(directory)
except OSError:
print ('Error: Creating directory. ' + directory)
# Example
createFolder('.\\'+ str(guild.id) +'\\')
my code is not working for some reason
im tryna make my bot such that when the bot joins the guild it makes a new directory with the guild id as the name of the directory
pls help me
is that a file like json database 
its python?
Auger have any clue?
It's a File based database :goodgod:
Auger have any clue?
@modest smelt Not a python dev, sorry
ok
Are you doing this to store data?
How do I create folders with python on repl.it?
This is my code currently:
import discord
from discord.ext import commands
import os
client= commands.Bot(command_prefix=['bob,', 'b,'], case_insensitive=True)
@client.event
async def on_ready():
print(f'Logged in as {client.user}')
@client.event
async def on_guild_join(guild):
idofguild= str(guild.id)
number= guild.id
path = '/'
path += idofguild
os.makedirs(path)
I need help, it's not creating a folder.
Hey Augger I Tried what u said ๐ but now it came as
Hey Augger I Tried what u said ๐ but now it came as
@next flax send code again
.setImage("attachment://hello.png") .setThumbnail(member.user.avatarURL()) .addField("Welcome", '<@${member.user.id}>') .setDescription(db.get(welmessage) );```
It looks the same as the first time
Still not using template literals
still not reading https://js.evie.dev/simple-data-types/template-literals right
Still not using template literals
@umbral zealot I may have mislead him on that accidentally
invoke_without_command=True
be patient
what is this tag?
oh sry
u can do like
/folder/file.py
and upload ur files
and delete that file.py
once your files are uploaded
Dude you don't even know JS, it's probably not a good idea to try to help people with their python problems.
async def on_guild_join(guild):
idofguild= str(guild.id)
number= guild.id # get rid of this
path = '/' # this means root directory, which is NOT what you want probably
path += idofguild
os.makedirs(path)
@earnest phoenix
Dude you don't even know JS, it's probably not a good idea to try to help people with their python problems.
@umbral zealot that isnt py problem
bro
thats just a basic faq
They're wanting to create a file dynamically, you're talking about uploads, clearly you misunderstood what the problem even was. smh.
atleast i tried to help
Oh thanks
[discord.py] Anyone know of a way to see if the bot has finished playing music? I am currently using
voice.play(FFmpegPCMAudio(executable='./ffmpeg/bin/ffmpeg.exe', source='song.wav'),
after=lambda e: nextQueue(Queue[0]) if len(Queue) > 0 else print("Finished Queue"))
And this would normally work, but I need to await the function and I can't do that through lambda. So, is there any other way to see if the audio has ended?
{ name: 'Account Age', value: message.member.user.createdTimestamp, inline: true },```
why is it showing seconds?
try createdAt
im dumb
@earnest phoenix whats the problem
TypeError [INVALID_TYPE]: Supplied roles is not a Role, Snowflake or Array or Collection of Roles or Snowflakes.
what line
if (!message.guild.roles.cache.find(c => c.name === 'Muted')) {
message.guild.roles.create({
name: 'Muted',
color: '#ff0000',
permissions: {
SEND_MESSAGES: false,
ADD_REACTIONS: false
}
})
};```
i think this is problem
hm
probably. this is a promise, if you don't await it, it may resolve after the rest of the code
Guide to understand promises: https://js.evie.dev/promises
ยฏ_(ใ)_/ยฏ
thx
{ name: 'Highest Role', value: message.member.guildMember.roles.highest, inline: true },```
im back my second part of the code isnt working
pretty sure member.guildMember isn't a thing
if that's discord.js, it's literally mesage.member.roles.highest
yea message.member is guildMember
ah ok
theres no guildMember property of guildMember
Hey I have another question.
Like there is a member:discord.Member is there a channel: discord.Channel?
This is in discord.py
also, if not, how would i get the id of a mentioned channel
Help!
Accident sry
-atmods @earnest phoenix
@earnest phoenix
Please do not mention (ping) more than one or two moderators for help, unless there is an emergency.
Here are some examples of emergencies:
- Raids / Multiple members mass spamming.
- Severe disruption of Discord's ToS (NSFW content, etc)
- Anything that requires more than 2 moderators to handle.
...
Deleting it afterwards doesn't help at all
I am sorry, it was an accident
yeah sure
imagine pinging mods
Uhoh
@earnest phoenix channel.id
thanks
[discord.js] can someone answer this question i dont want to use the setInterval function for this since that ruins it one restarted
https://stackoverflow.com/questions/64048103/how-can-i-make-my-discord-js-bot-send-messages-at-specific-times
@earnest phoenix how the hell does one "accidentally" ping a whole role
i meant to ping user
but accidentally clicked one down
@remote kernel you have to use setinterval sadly
or learn js and programming in general to know other methods that were not gonna spoonfeed u
or base it around specific times of the day
@remote kernel the problem is not setInterval
the problem is that you want your program to remember something the next time it starts
that can only be done by saving data somewhere outside the program, for example a config file or a database
If you want to persist across program restarts, you need to store data in the secondary storage instead of memory
So an approach could be: When the setInterval function is called, update persistent storage with the current time
And when the script is run next, check if that time + interval has elapsed, if so, do the setInterval's function
How are you getting the message content
substring
you're probably just posting the entire msg content
you need to cut off the prefix
queueMessageText += ' ' + message.content.slice(prefix.length).replace(/^tweet/, '').trim()
like this?
nope
That's not what you want...?
oh the "new tweet"
yeah then what you had works fine then
@placid iron gg on getting darling verified, also how did u get the rounded rectangle?
thanks, and stack overflow XD
i looked it up
1 sec
@placid iron this one?
i checked it out
didnt understand it
wanna see if it works
How would you go about making it so you can do @botname command and it uses the mention as an alternative prefix? I've been wanting to for a while but I have no idea where to start...ping me with ideas
hey
also how can i make a on mention event?
this doesn't work for some reason?
queueMessageText += ' ' + message.content.slice(prefix.length).replace(/^tweet/, '').trim()
i mean yeah you could do that ๐ try it and see
@fast trench
cant you just split it at the first space then join all the remaining words
Why don't more people use chrome dev tools or something when testing JS?
he is using js
i am using js
I mean it works @eternal osprey what you were doing
https://stackoverflow.com/questions/62239816/how-do-i-make-the-bot-respond-when-someone-mentions-it-discord-py
@drifting wedge do you have a js version lol
Hello
all good
queueMessageText += ' ' + message.content.slice(prefix.length).replace(/^tweet/, '').trim()
@eternal osprey so that definitely works, you shouldn't be getting what you posted in the screenshot
Is Glitch Banned
how can i run code when the bot is mention
Is Glitch Banned
@polar carbon no
tho make it private
how can i run code when the bot is mention
@drifting wedge on msg event check if it had a mention of your bot
Mentions is a msg property
Or check the content for your bot id
hmmm
Can we help me? I want to make a boat
lient.on('message', message=> {
const args = message.content.trim().split();
queueMessageText= ('A new tweet has been posted by you: ' + args)
queueMessageText += ' ' + message.content.slice(prefix.length).replace(/^tweet/, '').trim()
if (message.content === (prefix + 'tweet') || message.author.bot) return;
T.post('statuses/update', { status: args }, function(err, data, response) {
console.log(data)
message.channel.send(queueMessageText)
}```
Can we help me? I want to make a boat
@polar carbon check the #502193464054644737 it'll tell you how
no, he wants to make a boat
I like boats
Oh sorry lol
A new tweet has been posted by you: !tweet test tweet test
this is what i get back
A new tweet has been posted by you: !tweet test tweet test
@eternal osprey did you save and restart bot?
yeah
I like boats
first of all, .split() does nothing, just makes it into an array, but doesnt actually split anything, idk what you're trying to do with it
and idk what your T.post does
return message.channel.send(nowinners)
})```
why does this not return the error message
it is just the twitter api
@stable eagle it will send the message if the reaction fails, because of an error or permission issues
but uh, it also sends the message i dont want to be sent due to the error
yes, because its async
its executed in a different context, by the time the catch runs, the outside code is already long gone
if you want to stop your code to wait for it, you have to use await
it worked
but it still posts !tweet tto
too*
to twitter
in discord !tweet doesn't show
however in twitter it posts like this
What should I add to my Karen Bot? I am trying to think of some commands
What should I add to my Karen Bot? I am trying to think of some commands
@tall sentinel a help command
I already have one
karen!call-the-manager
That's all you need 
I have something similar to that as well, when you do k!manager the bot yells at you for your manager
And you can send her to other members and make her ask for their manager
You can also shoot people but that's not the point-
Is the manager the admin? l0l
That'd be kinda a funny bot to basically be an atmods tbh
can someone walk me through making regex work with mentioning my bot so it's used as a prefix also?
can someone walk me through making regex work with mentioning my bot so it's used as a prefix also?
@fast trench https://regexr.com/
like I said...can someone walk me through it and help me learn? I am terrible at learning from websites
Is the manager the admin? l0l
@faint prism
Hmm..I could make them the manager
how do i remove a role from a user by just the roles id
Repurposing your bot to be an atmods would be pretty nice imo
https://www.nodexr.net/ this is pretty cool too if you like working with nodes and more of a visual thing
A node-based Regular Expression (Regex) generator and editor for .NET
oh sweet dotnet
yup
oh wow
open source too
that's pretty sick
I'm bookmarking that
lol
lol
Wait, I might make a command that allows you to add a manager role to someone 
I'm so doing that
why not make a command that you can add any role to given user?
yeh, gib mi admun roll
const args = message.content.trim().split();
queueMessageText= ('**A new tweet has been posted by you: **')
queueMessageText += ' ' + message.content.slice(prefix.length).replace(/^tweet/, '').trim()
if (message.content.startsWith === (prefix + 'tweet') || message.author.bot) return;
if (message.channel.id == '734123034243367002'){
T.post('statuses/update', { status: args }, function(err, data, response) {
console.log(data)
message.channel.send(queueMessageText)
}
why does it sstill post twitter messages
eventhough i am not using my prefix !tweet
Hey! I am saving Message ID (channel ID too).
And I need to get this message after server reboot.
How can I do this?
Like fetch a message by ID?
I know, bot has no access to messages, written before his reboot
Like fetch a message by ID?
@sudden geyser hm, I think so
What library are you using
DiscordJS
I am trying
bot.channels.cashe.get(chID).messages.cache.get(msgID)
but it returns undefinded
One message removed from a suspended account.
Use <TextChannel>.channels.fetch
One message removed from a suspended account.
If chID was undefined it would throw an error instead
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
nvm?
Sorry, my English skills are so bad :p
If
chIDwas undefined it would throw an error instead
@sudden geyser no, chID not undefended. But message is
Use
<TextChannel>.channels.fetch
@sudden geyser maybe TextChannel.messages?
If you want to fetch a message by ID, you should use <TextChannel>.channels.fetch(...)
So it gonna looks like
bot.channels.cache.get(chID).messages.fetch(msgID)
```?
OK, one moment
why does it sstill post twitter messages
@eternal ospreyT.post('statuses/update', { status: args }
isargsthe same as msg.content
because if so, that explains why
t.post
sends the message to twitter
const args = message.content.trim().split();
this is my args defined
Well don't you want it to not include the prefix ..?
Why are you sending it the message.content That's still includes the prefix?
Wouldn't that mean that's the cause of your issue?
i just want the bot to only work on commands !tweet
should work
@sudden geyser yes, it work. BUT. It return Promise, so code looks like
bot.channels.cache.get(data.channel).messages.fetch(data.id).then(message=>{});
now it literally works on every message i send
auger
that was my older question ๐
Then check if msg starts with a prefix
You need to resolve the promise then.
if msg.content.startsWith(prefix) { doCommand(); }
You need to resolve the promise then.
@sudden geyser
- how can I resolve it
- nothing matter. It still work how I need
Resolve it either with await or .then(() => {...}). Read https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Promises for info on how to use promises if you want to know how it works.
Looks good, but I feel there's a missing sense of location.
You keep flexing your grafana dashboard
Keep that up and I'll make one too
Resolve it either with
awaitor.then(() => {...}). Read https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Promises for info on how to use promises if you want to know how it works.
@sudden geyser ah, yes. OK thank you so much
btw you can always use ๏ฝ๏ฝ
๏ฝ๏ฝ
๏ฝ for prefix stuff to be professionally unprofessional
is there any other free without paid items hosting
startsWith()
indexOf()
substring(1) === ''
So many freaking methods
and you decide to use regex


and you can easily have multiple prefixes and all that stuff
i mean, i just prefer it
can i just like have my own preference
mapped?
yes
elaborate
where can i find my DBL token
you should have your prefixes mapped, the way you search for prefixes in a string is unrelated to prefixes
mapped in what way
Map()
yes, and where
or indexed some other form
and why
Probably in an array
well thats what i use, an array
map is likely better for indexing
likely is
What's your goal wulfey?
goal? wdym goal
What do you want to achieve
im not a like professional developer wannabe or something
yet
really just wanna have some cool 2d minecraft action going on, to be able to show it to my few friends
const Discord = require("discord.js");
const bot = new Discord.Client({
partials: ["MESSAGE", "CHANNEL", "REACTION"]
});
const botconfig = require("./botconfig.json");
const fs = require("fs");
bot.commands = new Discord.Collection();
fs.readdir("./commands/", (err, files) => {
if (err) console.log(err);
let jsfile = files.filter(f => f.split(".").pop() === "js");
if (jsfile.length <= 0) {
console.log("Couldn't find commands.");
return;
}
jsfile.forEach((f, i) => {
let props = require(`./commands/${f}`);
console.log(`${f} loaded.`);
bot.commands.set(props.help.name, props);
});
});
bot.on("ready", async () => {
console.log(`${bot.user.username} is online!`);
bot.user.setActivity("your empire | ?help", { type: "WATCHING" });
});
bot.on("message", async message => {
if (!message.content.startsWith(botconfig.prefix) || message.author.bot)
return;
if (message.channel.type === "dm") return;
let prefix = botconfig.prefix;
let messageArray = message.content.split(" ");
let cmd = messageArray[0];
let args = messageArray.slice(1);
let commandfile = bot.commands.get(cmd.slice(prefix.length));
if (commandfile) commandfile.run(bot, message, args);
});
bot.login('');
Why is it wrong?
Aren't you the one who wrote it and ran into an issue?
Tell us what's wrong with it.
is there any other free without paid items hosting
I think Heroku is having maintenance
getavps.net and probably readthepins.io
@orchid vortex
regex is the least performant

indexOf() seems the best one
actually substring is a bit better
I'd rather use .startsWith(...) tbh
Just to convey meaning & convenience rather than the 1 ms difference.
btw you can always use ๏ฝ๏ฝ ๏ฝ๏ฝ ๏ฝ for prefix stuff to be professionally unprofessional
https://ptb.discordapp.com/channels/264445053596991498/272764566411149314/758720916225654810
it was more about this @sudden geyser
like, from all the options you decide to regex prefixes, custom ones at that
its the worst option for custom prefixes

I prefer to not use regex unless when forced to
lmaoo
regex can cause quite a big impact depending on what you use it for
Yup
neither sites exist
@white vapor readthepins works for me
I sure as hell don't want to sleep regexes everywhere
Ah yes, parsers entirely in regex
werks
readthepins.io sends me to centurylink web helper
Requested to go on a break
nah it works
oh
is there a way to disable web helper
But I love you too โค๏ธ
readthepins.io it works for me too jeremy. Have you tried turning your internet on and off?
is there a login url for it cuz just searching it redirects me
is there a login url for it cuz just searching it redirects me
@white vapor https://discordapp.com/channels/264445053596991498/272764566411149314/758728615302135819
is readthepins not suitable

LOL
bruh theres a limit of how innocent you can be
im literally just gonna get help somewhere else
aw come on
It's in the pins man
the pinned messages in this channel

i like heroku its just having maintenance thats why
custom cursors
if your cursor doesnt have flames and leaves sparkles all over the screen like in 2008 you aint doing custom cursors right auger
bet
it was all miniclip
regex was just the easiest for me to use if i wanted **can you like** to be a prefix
i mean i need to get creative here if i wanna use indexof for that stuff
xD
imagine this
ngl I'm afraid to google "free cursor icons"
imagine being a good fucking developer
let reg = /prefix/
thats what i need
how you gonna add custom prefixes there?
easy
oh i finally got the joke haha so funny thank you shivaco for actually helping
i mean i need to get creative here if i wanna use indexof for that stuff
@orchid vortex use substring
yooooo
i mean, this works just fine
having 11 event listeners on message with a single command each also works

'but it works' isnt a valid excuse for a good dev
don't give them ideas
having a 71 long chain of if's is also a valid option for command handling
ยฏ_(ใ)_/ยฏ
the whole point of being a dev is improving your code
its a valid option, but not a good option
just realized i spent 20 minutes on that joke
rather than just taking a tip of how to improve the code
you just throwing 'but it works'
alright - now i beg you to shut the fuck up because i want to forcibly end this conversation, thanks

thanks
guys what is the command for if someone mention any IDs its will respond so I wont get any errors
huh?
Like when a guy tried to mention someone to kick with the ID I got an error
theres no command for mentions
message has a property mentions in it that you can access, its a map
Strip away <@ and <@! from the left
or Collection<> i never know wtf d.js has with maps and their collections
strip > from the right
this is good case for regex
you got an ID out of a mention
How fucking hard is it to use subtring instead of regex
but how
type n.tag regex in #265156322012561408 @autumn aspen
ok
indexOf() returns the index of it
fucking keyboard
substring(index start, index end)
so you'd be replacing the first and last index with indexOf()
I meant a string with more than one char as param for indexOf
@slender thistle if indexof returns -1 means it doesnt exist
thats actually smart, havent thought of using indexof like that
I am familiar with everything you both said
But
I meant a string with more than one char as param for indexOf
@slender thistle
indexOf() is a string, its length can be anything shiv
This isn't clear to me
indexOf('string')
No shit, how does it behave is what I'm asking
oh
But what would it return? It can't return 1 index
compiler wise im not sure
if (message.mentions.users.first().id === '@') return msg.channel.send("");```
I have never made a function in a separate file before and i was wondering how i would call my client in it discord.js
like this?
thats the issue
with regex you'd have a better time
cuz you can do .test() first
for indexOf() you'd have to do 2 checks for -1
erwin is right
which is when it wasnt found
is it
I mean
if (message.mentions.users.first().id === '@') return msg.channel.send("");```
lmao
Are you literally comparing the id with @ or is it just a placeholder for an id?
this
He is comparing
but what instead if u like type any ID I got an error and I want to stop that
Wh a t i s t h e e r r o r
wait
is it possible to shard on multiple nodes ๐ค
yes
im assuming wait what how
TypeError: Cannot read property 'id' of undefined
at Client.<anonymous> (C:\Users\admin\reportbot\index.js:100:43)
at Client.emit (events.js:315:20)
at MessageCreateAction.handle (C:\Users\admin\reportbot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\admin\reportbot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\admin\reportbot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\admin\reportbot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\admin\reportbot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\admin\reportbot\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\admin\reportbot\node_modules\ws\lib\websocket.js:797:20)
error
I got
Hastebin
@shy turret
<object>.id the object is undefined
are free trials ok for temporary issues
here look ยดยดยดjs
@faint prism ikr
oops
if(cmd === 'kick'){
if(!args[0]) return msg.channel.send('Please mention someone to kick.\n\n:warning: `You cant use IDs until its updated!`');
if(!msg.member.hasPermission('KICK_MEMBERS')) return msg.channel.send(":x: **You don't have permission to kick members!** :x:");
if (message.mentions.users.first() === message.author) return msg.channel.send(":x: **You can't kick yourself!** :x:");
if (message.mentions.users.first().id === '731927983274721301') return msg.channel.send(":x: **You can't kick me!** :x:");
let toKick = msg.mentions.members.first();
let reason = args.slice(1).join(" ");
what's line 100 ๐ค
Hm how am I suppost to put em in order'
if (message.mentions.users.first().id === '731927983274721301') return msg.channel.send(":x: **You can't kick me!** :x:");
let toKick = msg.mentions.members.first();```
if (message.mentions.users.first().id === '731927983274721301')
hardcoding your bot id
if (message.mentions.users.first().id === '731927983274721301') return msg.channel.send(":x: **You can't kick me!** :x:"); is my geuss
um
are free trials ok for temporary issues
are free trials ok for temporary issues
@white vapor what does that even mean
let str = '@untold widget';
if(/<@โ!?(\d+)>/.test(str)/*returns true or false if a match is found*/) {
//if true
let id = str.match(/<@โ!?(\d+)>/)[1]
}
// using indexOf
let str = '@untold widget';
if(indexOf('<@') !== -1 && indexOf('>') !== -1) {
//indexOf('string') returns the index of the param. if it isnt found, it returns -1
let mention = str.substr(indexOf('<@', indexOf('>'))) /* and hope its all numbers in between*/
//extra check
if(isNaN(parseInt(mention))) { /*the mention isnt composed of numbers, false positive*/}
}
``` @slender thistle
heroku is having network problems or something
hope that helps a bit
You couldn't write a proper fucking message without JS comments for a mobile user, could you?

@autumn aspen try .cache?
here then lmao
I'm kidding
hey guys if there a way to load only the mobile version of a website when using fetch?
ly
Yw
@autumn aspen try
.cache?
@shy turret where
with the regex you already have a +d there checking for ONLY digits
hey guys if there a way to load only the mobile version of a website when using fetch?
@rancid sand Try sending a mobile User-Agent in the request header










