#development
1 messages · Page 890 of 1
you want to say a random job every time?
const jobs = ["Youtuber", "Doctor", "Police"];
const job = jobs[Math.floor(Math.random() * (jobs.length - 0) + 0)];
console.log(job);

🥣
might not work, haven't tested 
w h a t
lmao

I just remember the formula to make a random function
with min and max parameters

random() is enough
cbb appropriating it
you can only use random() if you make a collection of it
I'm still struggling with the TS error 
import { Client } from "discord.js";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:1101:16)
at Module._compile (internal/modules/cjs/loader.js:1149:27)
at Module._extensions..js (internal/modules/cjs/loader.js:1205:10)
at Object.nodeDevHook [as .js] (/Users/Nick/Development/Numen/node_modules/ts-node-dev/lib/hook.js:61:7)
at Module.load (internal/modules/cjs/loader.js:1034:32)
at Function.Module._load (internal/modules/cjs/loader.js:923:14)
at Module.require (internal/modules/cjs/loader.js:1074:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/Users/Nick/Development/Numen/node_modules/ts-node-dev/lib/wrap.js:80:1)
at Module._compile (internal/modules/cjs/loader.js:1185:30)
Only happens in the file passed over to the ShardingManager
const manager = new ShardingManager("src/bot/index.ts", {
token: process.env.BOT_TOKEN,
});
it doesn't matter
How many servers does my bot need to be in to have a active server count on top.gg?
@static trench 0, you just need to post your server count to dbl
check out the dbl api
An official module for interacting with the top.gg API - DiscordBotList/dblapi.js
here's the one for python
Ok ty’
my bot goes offline every 2 minutes
i get that even though its literally never happened when i was using it before
how long do i need to let it rest for
quota for unverified accounts is 550 hours per month
if you pass that quota, it will only work again next month lol
550 hours is about 21 days
hlep
you can only have 1 dyno on free account lol
you'd need to create another account
or simply verify it
Don't be lazy and properly censor your tokens please...
I doubt that is good enough to hide your token
uhh, I guarantee you can get the token from that screenshot
Why wouldn't you be able to?
ok
it's poorly censored
Also, it looked like your index.js was in node_modules.
where would you suggest me take it
Do you guys think it will be a problem to have a mongoDB database on a linux server if, I wanna make a web dashboard for my bot?
Why would it be a problem?
drop here? ****
Yeah.
Why would it be a problem?
@nimble escarp idk, never got into this stuff
i try
Depends on what you'd want to do with it. I'm hosting the web dashboard with Heroku as well
I'm running it in the same process (with express)
I'm not on hiroku
nothing...
Heroku*
@earnest phoenix that means your index.js is wrong
https://discordjs.guide/ follow this @earnest phoenix
i dont see the porblem
It looks like you didnt save the file on your screenshot
Check if the contents are actually inside
How i can mention a role in embed?
- im not eng

you need the & sign
@opaque seal aight
@white fable - User
[#12321312312311312](/guild/264445053596991498/channel/12321312312311312/) - Channel
<@&12321312312311312> - Role
The same problem as before.
You moved it back to node_modules
Wait is your index.js in node_modules?
I'd suggest learning node.js properly before making a bot.
im new js
node_modules is only for modules installed with npm or yarn
You shouldn't really touch node_modules
learn basic js, then learn basic node.js, then make a bot, then verify the bot
its soo hard
setup is not like that
bot.on('messageReactionAdd', async (reaction, user) => {
if((reaction.message.guild !== null) || user.bot)
return; //ignore reactions unless its in a dm and not made by bot
if (reaction.message.partial) {
try {
await reaction.message.fetch();
} catch (e) {
console.log('Something went wrong when fetching the message: ', e);
return;
}
}
}
still getting "reaction.message.fetch is not a function"
How do i find it?
with Partials enabled on client
I'm still crying over my typescript bot 
ID?
its soo hard
@earnest phoenix if you aren't willing to learn, you won't be able to program in js correctly.
@maiden mauve message.channel.messages.fetch(message.id)
How do I find my dbl token?
if(command === "myinvites") {
let userinvites = await message.guild.fetchInvites(message.author.id)
if(!userinvites) userinvites = 0
let invitesembed = new Discord.RichEmbed()
.setDescription(`The user ${message.author} has ${userinvites} invites.`)
.setColor(config.Green)
message.channel.send(invitesembed)
}```
How do i fetch invites of a user properly?
The user @earnest phoenix has [object Map] invites.
I found it
found it too
@earnest phoenix did you actually save the file?
but its saying 0 invites every time
oof
if(command === "myinvites") {
let userinvites = await message.guild.fetchInvites().then(invites => {
invites.find(invite => invite.inviter.id === message.author.id)
})
if(!userinvites) userinvites = 0
let invitesembed = new Discord.RichEmbed()
.setDescription(`The user ${message.author} has ${userinvites} invites.`)
.setColor(config.Green)
message.channel.send(invitesembed)
}```
this means the file is not saved
^
@earnest phoenix i'm not sure but i think richembed was removed in favor of MessageEmbed
^
im v11
ohh
lmao
if(command === "myinvites") {
let userinvites = await message.guild.fetchInvites().then(invites => {
invites.find(invite => invite.inviter.id === message.author.id)
})
if(!userinvites) userinvites = 0
let invitesembed = new Discord.RichEmbed()
.setDescription(`The user ${message.author} has ${userinvites} invites.`)
.setColor(config.Green)
message.channel.send(invitesembed)
}```
@earnest phoenix
sorry xd
how can i fetch the users invites properly?
Hello! I'm trying to run my JDA bot on a Google Compute Engine VM, and I can't seem to find out how. I uploaded the executable JAR file to the VM, but it says it doesn't have access to the jar when I try to run it.
It's a SpringBoot app
I dont wanna keep posting the same thing, so here is a link 
Need typescript (discord.js + sharding) help.
https://canary.discordapp.com/channels/264445053596991498/272764566411149314/703253398325035049
if(command === "myinvites") {
let userinvites = await message.guild.fetchInvites().then(invites => {
invites.find(invite => invite.inviter.id === message.author.id)
})
if(!userinvites) userinvites = 0
let invitesembed = new Discord.RichEmbed()
.setDescription(`The user ${message.author} has ${userinvites} invites.`)
.setColor(config.Green)
message.channel.send(invitesembed)
}```
its saying 0 invites (sry for posting again but people are messaging)
even tho i have more invites btw
save,
ok
saved
no
delete index.js from node_modules
all ?
close the file in your editor (dont save)
open the file again in your editor, from your bot folder, not from node_modules
like starting from scratch
oh
ok
but
im deleted index.js
oh
new files!
Tim, we're going deeper into problems. Sorry to pester you but what does this mean?
reaction.message.partial undefined

its still wrong lol
i told you to close the file in your editor
this
needs to be
your bot folder name
VISUALBOT
outside node_modules
wich?
index.js
i try ?
yes
@maiden mauve can you show the full error?
@quartz kindle would using djs 11.5 be a suspect?
v11 doesnt support partials
translate trash
:^)
thanks
sigh can't figure out the problem
if(command === "myinvites") {
let userinvites = await message.guild.fetchInvites().then(invites => {
invites.find(invite => invite.inviter.id === message.author.id)
})
if(!userinvites) userinvites = 0
let invitesembed = new Discord.RichEmbed()
.setDescription(`The user ${message.author} has ${userinvites} invites.`)
.setColor(config.Green)
message.channel.send(invitesembed)
}
saying 0 invites even tho i have 40
console log invites
no
I've been asked to verify my bot because of the new privileged intents. I'm not sure what things are considered as privileged, is there a list of that?
He's using await
why are you using await and .then again
no idea
well I am done
like
to fetch them

@mystic hemlock are you looking for this?
Yeah
let userinvites = await message.guild.fetchInvites(message.author.id)```
will this be it ?
that's the only two
yes
oh
Learn about Promises.
Promises are either handled through .then/.catch or async/await (try/catch)
What exactly does GUILD_PRESENCES mean?
The user @earnest phoenix has [object Map] invites.
if(command === "myinvites") {
let userinvites = await message.guild.fetchInvites(message.author.id)
if(!userinvites) userinvites = 0
let invitesembed = new Discord.RichEmbed()
.setDescription(`The user ${message.author} has ${userinvites} invites.`)
.setColor(config.Green)
message.channel.send(invitesembed)
}```
i don't know actually
Now you can do .find on the userinvites variable
fetchInvites doesn't have any parameter
is it like message.guild.fetchInvites().find(message.author.id)
but you have to return a promise first
it returns a collection
in then
.then returns a promise itself
you can do that if it's a chain of promises
thats why you can do .then(...).catch(...)
so await
only if you're not using { }
can we see the invites structure?
let userinvites = await message.guild.fetchInvites()``` currently it
The docs have a good example imo.
// Fetch invite creator by their id
guild.fetchInvites()
.then(invites => console.log(invites.find(invite => invite.inviter.id === '84484653687267328')))
.catch(console.error);
because you put await
let userinvites = message.guild.fetchInvites().then(invites => invites.find(invite => invite.inviter.id === message.author.id))```
this was my first try
let val = await promise().then(x => true) // val is true
let val2= await promise() // val2 is whatever promise returns
let val3= await throwError().then(x => 3).catch(e => 2) // val3 is 2
just wanter to put that out
Yeah but he needs to return a promise in .then to await the value if he uses {}
i get that
wait so am i right with this code?
let userinvites = message.guild.fetchInvites().then(invites => invites.find(invite => invite.inviter.id === message.author.id))```
like
let val = await promise().then(x=> {})
add return
wdym
like where
let userinvites = (await message.guild.fetchInvites()).find(invite=>invite.inviter.id===message.author.id);
something like this should work
well?
thats probably you concatenating the object into a string
which i think returns the url
wait
shouldn't it be .filter instead of .find?
I used .find only because he used it in his example.
im looking for it to return the number of people joined from the users invite
depends
let userinvites = await message.guild.fetchInvites().then(invites => invites.find(invite => invite.inviter.id === message.author.id))``` current code
no its find
The find() method returns the value of the first element in the provided array that satisfies the provided testing function.
then in the embed do js userinvites.uses
Well, it'd depend on his usage.
how do i use the filter then

change find to filter lol
after that you can map the filter
returns undefined
userinvites will then be an array (sorry, Map)
huh?
and how do i get it to show number instead of undefined?
userInvites will return an array, then you can reduce it
i don't know the structure of the invites so yeah
let userinvites = await message.guild.fetchInvites().then(invites => invites.filter(invite => invite.inviter.id === message.author.id))```
current btw
i meant what fetchInvites return
ik
Returns: Promise<Collection<string, Invite>>
userinvites.reduce((prev, val) => val.uses + prev, 0)

userinvites.reduce((prev, val) => val.uses + prev, 0)
what is perv and val
it iterated through the array and adds every invite's uses
prev is just the total number at the time
prev = sum of the previous val.uses
val = the current object
yes
initial value
arr.reduce(callback( accumulator, currentValue[, index[, array]] )[, initialValue])
ending value ?
initial (starting) value
oh
before it begins adding up
if no invites then = 0 ?
yup
oh
initialValue Optional
A value to use as the first argument to the first call of the callback. If no initialValue is supplied, the first element in the array will be used as the initial accumulator value and skipped as currentValue. Calling reduce() on an empty array without an initialValue will throw a TypeError.
@quartz kindle console.log(currentEmbed.embeds[0].footer.text);
DJS 12 made all the difference! 😄 😄 Thanks for your time
thank you so much!
What's the issue?
import { Client } from "discord.js";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:1101:16)
at Module._compile (internal/modules/cjs/loader.js:1149:27)
at Module._extensions..js (internal/modules/cjs/loader.js:1205:10)
at Object.nodeDevHook [as .js] (/Users/Nick/Development/Numen/node_modules/ts-node-dev/lib/hook.js:61:7)
at Module.load (internal/modules/cjs/loader.js:1034:32)
at Function.Module._load (internal/modules/cjs/loader.js:923:14)
at Module.require (internal/modules/cjs/loader.js:1074:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/Users/Nick/Development/Numen/node_modules/ts-node-dev/lib/wrap.js:80:1)
at Module._compile (internal/modules/cjs/loader.js:1185:30)
const manager = new ShardingManager("src/bot/index.ts", {
token: process.env.BOT_TOKEN,
});
Well, I am using ES6 modules.
just try it
I know it'll work :c
have you tried import { Client } from "discord.js/esm"?
/esm?
was added on v12.2
Oh, it's an esmodule
One second!
Uhh, still the same problem. Guess I'll have to do with const/require.
Well I kinda got it answered
in the end
didn't get it answered

Was told to use tsc --watch instead of ts-node
Somehow fixed it myself 
@earnest phoenix just read https://discordbots.org/api/docs#jslib
it explains everything very good
omm
so the manager will be doing node shard.ts for you basically
oky
and node doesnt understand ts files
Yeah, I fixed it like this
{
"dev": "nodemon -e ts --exec \"yarn build\"",
"build": "tsc && node -r dotenv/config dist/index.js",
}
or use node.ts :)
ı need help
@restive furnace 
-ask2ask
Don't ask to ask.
Just ask your question, it wastes time if you say "i need help" or "can someone help me?" instead of just saying what the problem is. Save your time and other people's time and just ask the question.
Please read https://dontasktoask.com/ for an explanation on why this is an issue.
webhook help
well tell us the issue
simple

now I wonder how I can get the bot developer role
you don't
Develop a bot
@earnest phoenix don't you have this Turkish link
No
:C
Because dbl is based on English
more like the internet
:C ı use translate
well good luck then
basic english knowledge is recommended for coding 
or just using the internet 
yeah
english is a universally taught language you can't complain about having to speak it 🤷♂️
@earnest phoenix you dont have role
he does
yes and?
you just don't know
exactly
role doesn't mean anything

still miss gaby tho
ive been thinking of making a jackbox bot, people are bored during quarantine and getting money is a bit harder right now, so id really love to boost people's moods by bringing them a paid game to discord for free
in discord.net?
probably not
disqord/dsp
discord.net is prone to breaking due to the lib not catching on with recent api changes
Tried DSharpPlus?
he said
discord.net always disconnects sometimes, it sucks
how do I set intents in my client options?
Always sometimes?
In which library Hamburger
discord.js
{
ws: {
intents: [...]
}
}
you don't?
uh
how does that work
intents are enabled on your app page
because I need them for bot verification
I think only a few are (those regarding privacy)
oh i forgot you have to pass them through the gateway
bot.on('ready', () => {
console.log("Ready to Protect.")
bot.user.setActivity(`s!help | ${bot.guilds.cache.size} guilds`, { type: 'LISTENING' });
setInterval(() => {
bot.user.setActivity(`s!help | ${bot.guilds.cache.size} guilds`, { type: 'LISTENING' });
}, 1800000)
});
bot.on("guildCreate", guild => {
guild.owner.send("**thank you for adding bot**").then().catch(console.error);
});
bot.on('guildMemberAdd', member =>{
const channel = member.guild.channels.cache.find(channel => channel.name === "safety-logs");
if(!channel) return;
channel.send(`**${member} has joined the server.**`).then().catch(console.error);
});
bot.on('message', msg => {
if (msg.content === 'test') {
msg.reply(`test`).then().catch(console.error);
}
});
thats my code
and ppl said it will stop working
don't do event subscriptions in ready because ready can fire multiple times
or have a bool check
.then().catch(console.error) :D?
if ready had occured
so do I need intents or not
or use .once
Well intents.. afaik they are used to receive updates about certain things, so it depends what your bot does
yes
will my code stop working though
guildMemberAdd is part of the members intent
not right now but in the future probably
like once discord verification
oh
also is server members intent to do with if owner adds bot then bot dms owner saying thank you for adding bot and also welcome messages?
and how many guilds the bot is in on its status?
If you don't have it you won't receive the GUILD_MEMBER_ADD, GUILD_MEMBER_UPDATE and GUILD_MEMBER_REMOVE events
but my code is fine?
If you have the guild member intent disabled: If a member changes their nickname (and not only nickname, roles, permissions and other things as well) and they are cached the bot won't update the cached member with the new nickname, you won't know when a guild member leaves a guild or when someone joins a guild
So welcome messages won't work
But you won't receive the guildMemberAdd event.
Meaning you wouldn't be able to detect when someone has joins.
for just that person?
if you enable intents using new Client({ws:{intents:INTENTSHERE}})
and dont enable GUILD MEMEBRS priviledge
this code block will never run
it works though
because you're not using intents
so that means my bot doesnt have intents?
Is there a way to make the bots status go back and forth from streaming and playing?
@true tundra Yeah, you can change it anytime, however there is rate-limiting.
yes, your bot doesnt have intents, unless you enable them using what i said above
that box doesnt matter if you dont use intents
in the application I wrote I use server member intents for welcome message and to dm owner when the owner invites the bot
on the bots code?
yes
nope
so then intents are disabled
@nimble escarp I want the bot status to change from streaming to playing by it self without me switching the status...
what do you mean you use "server member intents"?
where is that even?
Yeah, you can do that. @true tundra
How do you do it
@quartz kindle I wasn't meant to tick it?
oh you mean the verification process
yea
you need that yes, for the future
Well, the same way you'd change the bot's activity to streaming/playing.
Just add timers or anything else you want.
but you are not using it now
i have a command to see my invites
how can i get the invites but for only people that are still in the server?
if(command === "myinvites") {
let userinvites = await message.guild.fetchInvites().then(invites => invites.filter(invite => invite.inviter.id === message.author.id))
let legitinvites = userinvites.reduce((prev, val) => val.uses + prev, 0)
let invitesembed = new Discord.RichEmbed()
.setDescription(`The user ${message.author} has ${legitinvites} invites.`)
.setColor(config.Green)
message.channel.send(invitesembed)
}```
check the inviter id
intents are disabled by default, but will be mandatory in the future, so there will come a time that your bot will stop working if you dont use intents, and when that time comes, you will need the server member intents to be able to welcome users if your bot is in more than 100 guilds
@nimble escarp I dont know how to put timers
for now you dont need it, unless you use intents, but in the future you might need it
so its fine what I wrote?
He probably wants to count the number of uses (based on if the person who used it is still in the server) @pale vessel
yes its fine what your wrote
i want to get the invite amount BUT to people that are still in the server
not people who left
@true tundra setInterval 
@earnest phoenix thats not possible
there is no list of users who used the invite, so you cant know which ones left and which ones are still in the server
In theory it could be done, but it'd be nowhere close to an elegant solution.
so how is invitemanager working?
they count it in a different way
can i get help with doing it the same way ?
@earnest phoenix https://github.com/AnIdiotsGuide/discordjs-bot-guide/blob/master/coding-guides/tracking-used-invites.md
when a user joins -> fetch the invites, see which invite was increased by 1 -> assign that invite to the user
and you need to track all of this in a database
i have no idea on how to do it or what you mean
then you will have a hard time trying to accomplish it
you can start by reading the link posted above by our asian friend
lmao
you need to ask a mod to do it
Is there a channel for that? Don't want to ping mods.
@quartz kindle look at dms please
just ping one moderator, not the whole staff
There was no need to delete the mention, also 👀
how do you make a discord.js economy system
To something easily pingable.
I'd change it to "ovxrfl0w" myself if I could.
how can i get the invite that the user joined from ?
the link posted says how
I already sent a link for that.
lmao
well, not exactly what I'd choose but sure lmfao
What invite
I'll send it in DMs
how do you make a discord.js economy system in 2020
user.money = 0
@split hazel could you change my nickname to "ovxrfl0w" instead? 
you need virtual money
You're basically asking "how to build a house".
There are many approaches.
Depends on what you want exactly.
use a database, store the amount of money each user has
how are we supposed to tell what things are going to increase money, and what its going to be used
k
and then you would have to make a money-sink so there wont be much money flowing trough
client.on("guildMemberAdd", async (member) => {
let userinvitelink = member.fetchInvites()
let userinvited =
})```
i have this code
i need to somehow get the user who sent the link by the member who joined
go over that link again
ok so i saw this online for economy
const db = require('quick.db')
const ms = require('parse-ms')
const Discord = require('discord.js')
exports.run = async (client, message, args, config) => {
let timeout = 86400000 // 24 hours in milliseconds, change if you'd like.
let amount = 500
// random amount: Math.floor(Math.random() * 1000) + 1;
let daily = await db.fetch(`daily_${message.author.id}`);
if (daily !== null && timeout - (Date.now() - daily) > 0) {
let time = ms(timeout - (Date.now() - daily));
message.channel.send(`You already collected ur daily reward, you can come back and collect it in **${time.hours}h ${time.minutes}m ${time.seconds}s**!`)
} else {
let embed = new Discord.RichEmbed()
.setAuthor(`Daily`, message.author.displayAvatarURL)
.setColor("GREEN")
.setDescription(`**Daily Reward**`)
.addField(`Collected`, amount)
message.channel.send(embed)
db.add(`money_${message.author.id}`, amount)
db.set(`daily_${message.author.id}`, Date.now())
}
}
But this has rich embeds
and when i changed it to message embed
it didn't work
const client = new Discord.Client();
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`);
console.log("Streamstatus by DayZoonHD");
client.user
.setActivity(``, {
type: "STREAMING",
url: ""
})
.then(presence =>
console.log(
`Your Status has been set to ${
presence.game ? presence.game.none : "none"
}`
)
)
.catch(console.error);
});
client.login("");```
i dont get that link
@earnest phoenix you need to fetch all guild invites BEFORE the user joins, then when a user joins, you need to fetch invites AGAIN, and check which invite was changed
client.on("guildMemberAdd", async (member) => {
let userinvitelink = member.fetchInvites()
let userinvited =
})```
i have this code
i need to somehow get the user who sent the link by the member who joined
@earnest phoenix
the link does explain it
i created a db called invites and i want to add 1 to the user that invited
so i just need the user who invited
to get him from the user who joined
and i dont get it with that link
I need help making a timer so the bot switches status from streaming to playing
@earnest phoenix the answer is still the same
You need to have the number of uses for all invites before the event happens, then when a user joins you have to find which invite's uses increased by one.
i dont get anything with that link
you need to have the number of uses from before, and compare them with the number of uses from after
but whyyy
because thats how discord works
Because there's no other way.
You can't associate the invited user with the user who created the link unless you do it similar to how it was done on the link I sent.
sigh
You need to associate the invite link with the invited user when he joins (which is what we're telling you to do).
blame discord
i will
discord doesnt tell you where a member comes from, which invite they used to join

They don't.
You can only check who created the invite and how many uses the invite has (how many people used it to join).
i wanna do it but i dont understand anything from that link
i wanna add 1 every time someone joins from his link (using quickdb)
It's described pretty well.
can u send it again ?
Then you can check https://discord.js.org/#/docs/main/stable/class/Invite to see which properties are available.
ok so i have that part
but how do i get it into quick db
oh actually wait i think i might do it
Can someone help me with this:
const client = new Discord.Client();
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`);
console.log("Streamstatus by DayZoonHD");
client.user
.setActivity(``, {
type: "STREAMING",
url: ""
})
.then(presence =>
console.log(
`Your Status has been set to ${
presence.game ? presence.game.none : "none"
}`
)
)
.catch(console.error);
});
client.login("");```
const invitedb = new db.table("invitedb")
client.on('guildMemberAdd', member => {
member.guild.fetchInvites().then(guildInvites => {
const ei = invites[member.guild.id];
invites[member.guild.id] = guildInvites;
const invite = guildInvites.find(i => ei.get(i.code).uses < i.uses);
const inviter = client.users.get(invite.inviter.id);
invitedb.add(`${member.guild.id}.${inviter.id}`, 1)
})})```
@quartz kindle
i got this so far
lmao
what is wrong with the code?
how could i place gradients at the edges of a website 
wym edges
graphics design is my passion
wait i can just do it with a box-shadow cant i
yes
definitely
aight thanks
set the position of a div element to aboslute, width and height to 100% and box-shadow
(surprised noone tryitands.ee-d me)
absolute*
instead of a div element i could just do body cant i?

it's not suggested to make the body absolute but whatever floats your boat
oh
yeah you could place box shadow on the body
im dum
okay thanks
If some funky business happens in my code and ends up storing the result of an equation as NaN, is that stored as a string or some other type?
Hmmm
Alright thanks
Another stupid question, but does let behave the same with arrays or objects as it does with strings or numbers?
yes
Ah nice thank you
const dbl = new DBL(yourDBLTokenHere, { 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!`);
});```hello yourDBLTokenHere in part (') we will put
yo
so i have every command in a file
like
commands/music/play.js
right
but when i add a new command like meme.js in file like commands/other/meme.js
when i start the bot
and go to test it i type b!meme and the bot keep telling me Unknown command
why?
any help please
const randomPuppy = require("random-puppy");
module.exports = {
name: "meme",
category: "other",
description: "Sends an epic meme",
run: async (client, message, args) => {
// In this array,
// you can put the subreddits you want to grab memes from
const subReddits = ["dankmeme", "meme", "me_irl"];
// Grab a random property from the array
const random = subReddits[Math.floor(Math.random() * subReddits.length)];
// Get a random image from the subreddit page
const img = await randomPuppy(random);
const embed = new RichEmbed()
.setColor("RANDOM")
.setImage(img)
.setTitle(`From /r/${random}`)
.setURL(`https://reddit.com/r/${random}`);
message.channel.send(embed);
}
}```
no
const {embedR0, embedR1, embedR2, embedR3, embedR4} = require('./commands/menus.js');
Am I doing this a cave man way assuming these could greatly expand? (Didn't want to flood index with datablocks)
then who did the command loader?
@maiden mauve why not just require menus.js?
and use menus.embedR0?
menus or m
hmm
that's probably the more long term solution
was a bit rusty on the syntax
and if you're writing R0 in your embed footer, you can also do menus[embeds[0].footer.text]
or require("menus.js")["embed"+embeds[0].footer.text]
or something like that
I did this
const currentEmbed = await reaction.message.fetch();
if(!currentEmbed || !currentEmbed.embeds[0].footer)
return console.log("invalid reaction");
const currentPage = currentEmbed.embeds[0].footer.text;
switch(currentPage) {
case "R0":
if(reaction.emoji.name === '▶️')
await reaction.message.edit(embedR1);
else if(reaction.emoji.name === '◀️')
await reaction.message.edit(embedR2);
break;
grrr spacing
it's working nicely just gotta organize it and maybe double check the validation against problem users
help me pls
i would have a question about how can i get the maximum value from the lvl queue CODE ```php
<?php
session_start();
require_once 'connect.php';
$sql = mysqli_query($con, "SELECT max(lvl) FROM globalxp");
$ertek = mysqli_fetch_array($sql);
?>
<h1><?php echo $ertek['accountid']; ?></h1>```
staring at the repeated conditionals in switch case is getting my brain spinning
but I'll shelf that for another code cleanup
@earnest phoenix
@earnest phoenix that adds nothing to chat. This is for development stuff only.
yo
so i have every command in a file
like
commands/music/play.js
right
but when i add a new command like meme.js in file like commands/other/meme.js
when i start the bot
and go to test i type b!meme and the bot keep telling me Unknown command
why?
im using CommandoClient btw
make your own command handler and don't use commando
^ Agreed, making your own isn't hard either.
was gonna say if your using a thing refer to it's help files
I haven't had any issues using a textbook basic command handler
hello how can I get guild channel list like this? on a web dashboard
there are a ton of ways to go about it
it depends on how your infrastructure is set up
do you depend on a websocket to exchange data or is it just requests to your backend API
api
just started making a dashboard for discord bot
any text tutorials or video anything will help me a lot
they won't
expose an endpoint in your api that returns data for the said guild
then on your frontend hit the endpoint and process the data
ok thanks
client.on('guildMemberAdd', member => {
member.guild.fetchInvites().then(guildInvites => {
const ei = invites[member.guild.id];
invites[member.guild.id] = guildInvites;
const invite = guildInvites.find(i => ei.get(i.code).uses < i.uses);
const inviter = client.users.get(invite.inviter.id);
invitesdb.add(`${member.guild.id}.${inviter.id}`, 1)
})})```
```js
const invite = guildInvites.find(i => ei.get(i.code).uses < i.uses); this is the error```
(node:16129) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'get' of undefined
the invite you got from your invites array is undefined
yeah
but
how do i fix it, thats the question
you tell me
i don't know how you structured your code
i can send it
Anyone know how I can prevent some variables from being accessed from eval without changing the value of them?
don't wanna sound toxic, but are we making your bot for you? 
const wait = require('util').promisify(setTimeout);
client.on('ready', () => {
wait(1000);
client.guilds.forEach(g => {
g.fetchInvites().then(guildInvites => {
invites[g.id] = guildInvites;
});
});
});```
Anyone know how I can prevent some variables from being accessed from eval without changing the value of them?
simply don't give eval access to people who you do not trust
const invites = {};```
it's extremely hard to make a (properly) sandboxed eval
@earnest phoenix you realize that wait is a promise and will do nothing if you're calling it in a non await/async method?
oh
it's extremely hard to make a sandboxed eval
@earnest phoenix even multimilion dollar companies struggle with it lmfao
im new to it
why would multimillion dollar companies use eval lol
There are real uses for eval lmao.
i got it from a website and just coded it a bit with someones help lmao
idk what to do
its undefined
stop copypasting code without knowing what it, or you, does
you should maybe review some djs documentation and some basic javascript and then try making a bot

This way you won't learn in the end 
ik how to make a bot, but for this specific thing, someone in this server legit told me to read it
I TOLD HIM I DONT UNDERSTAND
but still
download the emoji and put it in your server
ok ctrl shift i time
right click is enough
i do
if you don't understand instructions it's more than likely a sign that you do not actually know how to code in the language you're working with. anyone can pick up a programming language and claim to "know how to do x" because they've repetitively done x, however when you give them something they have to figure out on their own, they struggle with it a lot simply because they don't know what they're doing and didn't get themselves experienced with the language - this is called a help vampire
It's like an actual language, you can only work well with it if you can speak it
let alone understand it being spoken
if you don't understand instructions it's more than likely a sign that you do not actually know how to code in the language you're working with. anyone can pick up a programming language and claim to "know how to do x" because they've repetitively done x, however when you give them something they have to figure out on their own, they struggle with it a lot simply because they don't know what they're doing and didn't get themselves experienced with the language - this is called a help vampire
@earnest phoenixI was searching for that expression.
actually, if you know how to code in just one single language, you can pretty much transfer that knowledge to any other language
how do i change the font colour in pillow ?
not the same as trying to learn french when you know dutch
Programming vampires bite code, bit by bit. 
what the
True
you dont speak of cpp, thats illegal 
....
its probably easier to learn python when you know c++, but not backwards
@regal jacinth what pillow?
Also, someone cleared my nickname 
;-;
probably being the keyword
hmmm
Pillow, that's Python
it's a module to edit in a pic
@nimble escarp back to square one
using python
how to make an infinite loop that will repeat and write a command
god damn it 
you're looking for loops @earnest phoenix
soo does any body know how?
XD
while(true == 1)
I make spam ping bot
while(false == 0)
while true == false
thats illegal
where to insert
while(true!=false)
your objective is really useless
#define true false
while(true == false)
I make spam ping bot
@earnest phoenix that is api abuse
SOME ONE PLS ANSSWER MEEEEEE ;=;
@turbid bough
hi
TF
please kill it
how do i change the font colour in pillow ?
wdym pillow
hmm
I am having problems with my embed links not opening when you click it for one of my commands, It contains a link you can copy it but it doesn't do anything when you click it...
oh ty
--JS--
args.slice(1).join(" ");``` I want to make sure that this means that this takes the content of the first argument, right?
it shows up as a link
It's a guild invite I don't want to get banned for ads
it wont let me send it here
oh
You're not allowed to
do you have the protocol in the url
https://
As a whitename
yes
are you already in the guild
i wanna try to do some stuff outside my bot, so i got visual studio code
when i try to console.log somthing it will error
i never really used it before so im confused on why
it works for me
did you install somthing so it works or ?
i was talking to cedar
@heavy anchor i'm already in the guild and it just transfers me to it when i click on it, are you doing anything else?
just tested something
it doesn't do anything once the invite doesn't exist anymore
which means that the invite had been deleted
maybe u need to escape the link because discord is dum dum?
windows script host
vsc
cant console log
so await ReplyAsync(embed: new EmbedBuilder().WithDescription("[invite](https"+"://discord.gg/ku9Wdy").Build())
no
that doesn't matter
the problem is explained
just try it
no.
alr
i'm already in the guild and it just transfers me to it when i click on it
it doesn't do anything once the invite doesn't exist anymore
which means that the invite had been deleted
also that code isn't escaping anything it's just combining two strings lol
It shows the link when i have my mouse on it It Just does not open when I click on it
so 2 possibilities
- im dumb
- the problem is dumb
are you sure the invite exists
i think its 1
yes
@heavy anchor try calling it directly, if that doesnt work either the link is not existant
so open the invite link directly from your browser
^
or just like
send it in chat and see what the embed returns
right
not here tho
@earnest phoenix thanks for help
gg
cedar,
elp meee
I have and it works fine in the browser
@earnest phoenix what exactly
um
could you try to translate that
i try to console log
and this error pops up
oh god
arabic?
hebrew
wait
did you call it from the windows javascript host
not node.js
um
i used run ?
b ruh

on terminal
bro IM NEW TO VSC
so you opened it directly
idk
D:
so you didnt do node yourfile.js
no
when i did now it erroed
errored
console.log doesnt exist in windows javascript
Error: Cannot find module 'C:\Users\איתי\somthing.js'
lmao
o wait
where did you save your thing
your file
on desktop
omfg
cd Desktop
node somthing.js
BRO
worked
lmao
running the file in the correct directory works

yeah well i used a website and this is just for testing stuff so yeah
thanks
@nimble escarp ma dood if you want to send emojis go to #memes-and-media
@earnest phoenix it works fine in the browser, Maybe it's something with my code?
I'm reacting to the situation.
i doubt, if the url displays fine on hover then there's nothing more to it
it's maybe some setting in your client
give me a minute to try something
Hyperlinks work fine in my other embeds just not this one.
try doing discordapp.com/invite/code instead of discord.gg/code
yeah
bruh whitename filter
my message got removed
again
yay
exports.run = (client, message, args, ops) => {
search(args.join(' '), function(err, res) {
if (err) {
if (message.deletable) message.delete(5000)
return message.channel.send('Sorry, something went wrong')
.then(m => message.delete(5000));
}
let videos = res.videos.slice(0, 10);
let resp = '';
for (var i in videos) {
resp += `**[${parseInt(i)+1}]:** ${videos[i].title}\n`;
}
resp += `\n Choose a number between: **1-${videos.length}**`;
const Embed = new Discord.RichEmbed()
.setAuthor('Wyszukiwanie', miniatura, zaproszenie)
.setColor("BLUE")
.setDescription(resp)
.setTimestamp()
const filter = m => !isNaN(m.content) && m.content < videos.length+1 && m.content > 0;
const collector = message.channel.createMessageCollector(filter);
collector.videos = videos;
message.channel.send(Embed)
collector.once('collect', function(m){
let commandFile = require('./play.js');
commandFile.run(client, message, [this.videos[parseInt(m.content)-1].url], ops)
});
});
}
Does anyone know how to add a script here, which after writing "cancel" stops the whole script?
add a if statement to the collect event that checks if the content is cancel
and if it is return;
ok thanks
so for example if(m.content.toLowerCase()=="cancel") return;
Yes
Thank you so much
If my bot is offline when a cron job is due to run, will it wait until the next occurrence or will it do the stuff on startup?
@earnest phoenix did you just say 'console.log doesn't exist in windows js'????!!??
i mean
as far as i experimented it doesnt
node.js it does, yeah
but windows side js dont think it exists
but like, doesn't it?
js isn't even made to be run outside of a browser
there's node which is a runtime
idk what you're using to run js outside the browser or node/deno
node
then why are you saying console.log doesn't exist
because it is that way
to translate what it said there: "Console" isnt defined
maybe u get me wrong here but i said that windows script host does not have console.log
it doesn't say it doesn't have console.log, is says it doesn't have the console object, and I don't see why anyone would use WSH
Hey so I'm trying to get my Mute command to work.
and its not unmuting at time.
woudl this be correct.
setTimeout(function() {
tomute.removeRole(muterole.id);
message.channel.send(`<@${tomute.id}> has been unmuted!`);
}, ms(mutetime));
}
discord.js
Yes, but if your program restarts, any unmutes due to be will not happen

