#development
1 messages · Page 889 of 1
Are you good in python?
No
My server is their but on third position on tag
Then the error it's probably from your code
How can i get discordjs if im on chromebook
I need help where to visit??
get discord.js using something like glitch
idk how to work glitch
@true tundra learn a language first.đ
bruh
Why did u tell me to use glitch then
Im on chromebook though
Then use mee6 and it's customizable
yeah
omg
Wrong channel and uh check their website? This is the wrong server to ask in
whyd my bot get muted?
You can check for a reason by searching in: mod-log <your bot ID>
how do i make it so my bot doesnt respond to other bots like how do i make it so my bot only repsponds to users (discord.js)
User.bot
That's not it
so like
if(!User.bot)
Just if the message author is a bot, return
eg if (message.author.bot) return
idk what was wrong what i said lol
and i set return to nothing
so it cant be if (message.author.bot) return message.channel.send("Your a bot")
No, because then you're responding to a bot
No its literally return;
okay thank you
@turbid bough They were looking for message.author.bot which returns a boolean to then return on it
you dont want to recieve a message, check if its a bot, send a message back that it is a bot. then the other bot starts doing the same and it does a forever loop
i thought he already knew that message had a user variable :/
i am unable to change prefix of my bot in this server using quick.db
im trying to do it using eva;
eval
.eval const db = require('quick.db')
let guildID = "264445053596991498"
let a = "1s"
db.set(`prefix_${guildID}`, a)```
did you try that eval command in this server
no
or another server
cant as bot is muted
k
trying to do that by getting the guild id of this server
can you show the error
how do i convert an integer color to a hex code
bruh
i thought the ` would need to escape
as in discord its prefix and not `prefix`
but i dont have to escape `
learn js
` is a template literal
another sort of " or ' but allows template literals in them
It is possible, but its not for beginners at all
@modest maple im not begginer
then do it
@client.command()
async def f(ctx):
image1 = Image.open('Yato_2.png')
font = ImageFont.truetype("Nowharehouse.ttf", 20)
draw = ImageDraw.Draw(image1)
draw.text(xy=(50, 50),text="hehe",fill=(255,69,0),font=font)
await ctx.channel.send(file=discord.File(image1))```
```discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: expected str, bytes or os.PathLike object, not PngImageFile```
ok this cmd does write on the picture but I can't make the bot send it , this error is what I get when I use the cmmd
if I put image1.show() instead of the await line , it will show me the pic with the font
it turns out that it makes the pic into jpg , soo how do I change it into png again ?
let prefixes = JSON.parse(fs.readFileSync("./prefix.json", "utf8"));
let botconfig = require("./botconfig.json")
let PREFIX = botconfig.prefix
if(!prefixes[message.guild.id]){
prefixes[message.guild.id] = {
prefixes: botconfig.prefix
}
}
let prefix = prefixes[message.guild.id].prefixes
if(message.content.startsWith(PREFIX + 'prefix')){
if(!message.member.hasPermission("MANAGE_SERVER")) return message.reply("You need a higher permission")
if(!args[0] || args[0 == "help"]) return message.reply("Useage: ^prefix <desired prefix here>")
prefixes[message.guild.id] = {
prefixes: args[0]
}
fs.writeFile("./prefix.json", JSON.stringify(prefixes), (err) => {
if (err) console.log(err);
}).then(message.channel.send({
embed: {
color: dblue,
title: "Prefixes",
fields: [
{
name: "Prefix set",
value: `Set to ${args[0]}`
}
]
}```
i dont understand why my command doesnt change the prefix
in the prefix.json it says what i set it too
sorry
under the let
if(message.content.startsWith(PREFIX + 'prefix')){
else if {
(!message.member.hasPermission("MANAGE_SERVER")) return message.reply("You need a higher permission")
}
else if {
(!args[0] || args[0 == "help"]) return message.reply("Useage: ^prefix <desired prefix here>")
}```
like that
this is python ?
oh sorry then
do i not need the else ifs
How bots get this badge?
@keen fern you need to participate in the discord Developer Verification program if your bot is in 75 guilds or more
đ
btw how I got that nickname?
@modest maple im not begginer
Trust me after seeing your previous posts you are not ready for ot
@keen fern probably had ads in your status or something, and mods maybe nicked you because you were showing on the top of the user list due to your name starting with A
He has an ad in his status to yeah
oh that wasn't showing when i wrote that message 
Is there a way to make the bots status go back and forth from streaming and playing?
Oh
js has a think like setinterval, atm im just seeing its just for websites
or is it not a good idea to use it at all
I mean you can use setinterval for more than just websites
you can do checks like if something exists or not
or change something over time
like switch back and forth
its not useless
and not really bad
ok, just making sure it was like safe to use
I mean depending what bit system you use if you set the interval too high it will be set to 1ms
ahaha nah, i dont think it will be that no
thats only a problem on 32 bit
to be honest
also you can clear intervals
to make intervals stop after a certain condition
or over time
however you want
like make it add a number and once it reaches 100 make it stop the interval
just an example but there are many use cases
how would it go if it is going to run forever?
obviously yeah
meh you're fine
Also I got some work to do so cya
o/
Hello, i am looking for a developer who works in discord.js. I am trying make my bot change the name of a voice channel at a set time of day. For example every day at 3pm the voice channel name changes to group meeting. It is going to be a bot on my private friend server and i will not be sharing your hard earned work with anyone.
ooh, so thats what you meant, lol i thought you wanted a clock on the channel
Are you able to help now? Sorry if i didnt explain well before
You can do it
all i can say that you would use setinterval with a small timer like 1 minute or so, add if statments from date.now and change channel name from id
Okay thank you
Yes you can do it with setInterval()
hmm okay ill see what i can do
if i made testchannel a var and did testchannel.setName("meeting") would that work?
nvm, setName should work too
that will work
message.channel.setName("testing") .catch(console.error) ...
if you set an id property in a schema, will mongoose's _id id getter override it?
@woven sundial With const chan = client.channels.get("CHANNEL ID") client is not defined
that works
its okay
everything worked out
lol
Now i need the bot to detect when its 9:15 am and change the channel name
check if Date.now() is equal to 9:15 am
Does anyone know how I could put the amount of servers my bot is in, in the status? Because when I start it grabs the correct amount but then when it is added to another server it doesnât update until I restart the bot
I have it in the status as like bot.guilds.cache or something
Updating the status on guild Join or Leave could be rather spammy if it's a big boat
Guild join, or member join?
@torn nebula how do i check if the date is equal to 9:15
Does anyone know the answer to my problem? The bot Iâm trying to do it on is @safe harness. It is stuck on 68 until I restart the bot
What does your code look like SaltySpamz?
Lemme get it one sec
@coarse spade bot.on('ready', () =>{ console.log('BOT SUCCESSFULLY STARTED'); bot.user.setActivity(bot.guilds.cache.size + ' servers for cc!help', {type: 'WATCHING'}).catch(console.error) })
one sec
So i made a bet command but it prevents my node process from starting the bot up...
Is there any issues in this?
https://pastebin.com/MLLA4yXU
@sacred mountain bot.on("ready", () => { console.log("This bot is online!"); bot.user.setActivity(bot.guilds.size + ' servers for cc!help', {type: 'WATCHING'}); })
try this
what is undefined
The bot.guilds.size
@sacred mountain =>
bot.guilds.cache.size
I am currently using that
Hmm... What version of discord.js are you using?
12
Hmm wait lemme see...
What doesn't update?
The status
string breaks code @earnest phoenix
@sacred mountain you mean like the activity get updated every time it joins a new guild?
Yh
@torn nebula in which line?
Hmm... I don't see an issue on that
that's fixed img
client.user.setStatus("dnd");```
Why doesn't this code work? (It always set online status)
đ€Š
client.user.setActivity
@torn nebula wait is this any different with what you showed?
No > client.user.setActivity
@coarse spade
programming on a mobile lol?
.setPresence
@turbid bough yes... Big brain
@coarse spade This is for setting the bot activity
@balmy knoll setStatus is correct...
The setStatus function is just completely drunk
So how can i set the dnd status on the bot?
@balmy knoll idk... Just set it with what you did and you have to wait a long time
version?
@balmy knoll wair
no
Hey
@earnest phoenix I wait, but nothing change
@balmy knoll hmm... Then that's discord.js's problem
@torn nebula so as said... Did you spot any difference between what i showed in that screenshot or the code you showed lol?
How can i make the bot detect when its a certain time like 9:15am
the bot isn't aware of that, your app is
if(Date.now().getMinutes() >= 15 && Date.now().getHours() >= 9)
``` is one way
something similar to that
Please help me
@still plover this is not a server for a specific bot support
breaks from here yes there is difference
will this work @turbid bough if(Date.now().getMinutes() >= 15 && Date.now().getHours() >= 9) message.channel.send("hello")
that will send a message everytime you try to check yes and both of them are over those values
@earnest phoenix what is about this server please dercribe in some sentences
@torn nebula That isn't an issue, as he's using backticks for the string
@torn nebula still the same problem...
What happens when you start the bot?
@still plover it's about the bots you've built and support on their development for them
Thaun how do i set it to always check for it
use setInterval
Ohh i see you are build tha bot right
@hasty sparrow i mean that... The node just doesn't start up the bot after my bet command was written
how?
Does the bot start if you comment out the command?
https://pastebin.com/MLLA4yXU @hasty sparrow
Bet command
You can give me a bot
var myVar;
function myFunction() {
myVar = setInterval(alertFunc, 3000);
}
function alertFunc() {
alert("Hello!");
}```
@hasty sparrow i mean the bot just doesn't start up completely after i wrote that command
mm,
Answer bot i need but i cant find
Have you verified that it's the command itself causing the issue (commented it out and run the bot)?
@hasty sparrow when i delete the bet command from the code... The node starts up the bot but when i write that code back in or paste it back it's just this:
Also do yourself a favour and don't use a JSON file as database
Ik i'll switch to a db
These are just the test phases if the commands would work then i would switch to a db
This is one issue in your code
if (`${randomoutcomes} === "Win"`){```
The quotations are the issue?
yes
Hmm k lemme remove them real quick
the `
at <anonymous>
at runMicrotasksCallback (internal/process/next_tick.js:122:5)
at _combinedTickCallback (internal/process/next_tick.js:132:7)
at process._tickCallback (internal/process/next_tick.js:181:9)
(node:1464) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 23)```
220. satırda nasıl bi hata var ?
@earnest phoenix Line 19 you have a semicolon after setDescription
Oh do i?
@late hill also... That quotations that i removed still didn't resolve the issue
var myVar;
function myFunction() {
const chan = bot.channels.get("684266247302414377")
if(Date.now().getMinutes() >= 15 && Date.now().getHours() >= 9)
chan.setName("Meeting")
myVar = setInterval(alertFunc, 3000);
}
function alertFunc() {
alert("Hello!");
}
``` is this correct?
Try it out
Try it and SEE
the reason it didn't run was likely because of the issue dukeofsussex mentioned
the issue i mentioned is why it wouldn't work properly if it did get to run
Clear đŠ„
I inspected both the issues but no luck @late hill
If i want to set it to a pm time do i have to do 24 hour time
Comment out all of the bet command code, run the bot and if it works, uncomment it code block by code block and rerun it to find the issue
If i want to set it to a pm time do i have to do 24 hour time
If i want to set it to a pm time do i have to do 24 hour time
Also i think my node spots an error that doesn't start up (After i updated my phone to android 10 it never showed the errors in start up... It just didn't start up the bot)
No need to spam the same question
If i want to set it to a pm time do i have to do 24 hour time
No
you can check it's am or pm
please tell me how sai chinna
Why he send me an error has channel :
const channelID = '659082642116968448';
const channelID2 = '659085499872444416';
client.on('guildMemberAdd', member =>{
let embed = new Discord.RichEmbed()
.setDescription(':tada: **' + member.user.username + '** a rejoint ' + member.guild.name)
.addField('Nous sommes désormais ' + member.guild.memberCount, "** **")
.setFooter('Bienvenue ' + member.user.username)
member.guild.channels.get('471566867518193664').send(embed)
member.addRole('MEMBRE')
});
client.on('guildMemberRemove', member =>{
let embed = new Discord.RichEmbed()
.setDescription(':cry: **' + member.user.username + '** a quitté ' + member.guild.name)
.addField('Nous sommes désormais ' + member.guild.memberCount, "** **")
.setFooter('Bye ' + member.user.username);
member.guild.channels.get('471566867518193664').send(embed)
});
client.on('guildMemberAdd', function (member) {
updateStatusOnline(member.guild);
updateStatus(member.guild);
});
client.on('guildMemberRemove', function (member) {
updateStatusOnline(member.guild);
updateStatus(member.guild);
});
client.on('presenceUpdate', function (member) {
updateStatusOnline(member.guild);
updateStatus(member.guild);
});
function updateStatusOnline(guild){
let online = guild.members.filter(m => m.presence.status != 'offline').size-1;
let formatString = 'En ligne : '+online;
let channel = guild.channels.get(channelID);
if(channel.name !== formatString){ <-- Here
channel.setName(formatString);
}
}
function updateStatus(guild){
let max = guild.memberCount-1;
let formatString = 'Membres : '+max;
let channel = guild.channels.get(channelID2);
if(channel.name !== formatString){ <-- And here
channel.setName(formatString);
}
}
u want the bug report ?
What is the error?
use any npm package to check time JOHN611
/home/debian/Bot/index.js:51
if(channel.name !== formatString){
^
TypeError: Cannot read property 'name' of undefined
at updateStatusOnline (/home/debian/Bot/index.js:51:13)
at Client.<anonymous> (/home/debian/Bot/index.js:43:2)
at Client.emit (events.js:189:13)
at PresenceUpdateHandler.handle (/home/debian/Bot/node_modules/discord.js/src/client/websocket/packets/handlers/PresenceUpdate.js:48:16)
at WebSocketPacketManager.handle (/home/debian/Bot/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:105:65)
at WebSocketConnection.onPacket (/home/debian/Bot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (/home/debian/Bot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)
at WebSocket.onMessage (/home/debian/Bot/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:189:13)
at Receiver.receiverOnMessage (/home/debian/Bot/node_modules/ws/lib/websocket.js:789:20)
@hasty sparrow also to show you...
I cut and paste the code somewhere else out of my code file and the bot starts up...
Welp... I think it's investigation time to resolve some codes...
Channel wasn't found
check the Id again
if that doesnt work
check it by name
if that also doesnt work
debug
@earnest phoenix Really should use a proper editor for your code, would make your life so much easier đ
Yea... Thx for the advice btw... And yea... Let's go to the start of investigation...
@lament yoke
hey
no
no
id is wrong
channel is definied
log channel thing
id is wrong
@torn nebula
No it's for member count, and id is valid
log channel check ur getting object data
new error if (typeof value === 'undefined') throw new Error('Value must be specified.');
^
Error: Value must be specified.
at Map.find (/home/debian/Bot/node_modules/discord.js/src/util/Collection.js:499:45)
at updateStatusOnline (/home/debian/Bot/index.js:49:33)
at Client.<anonymous> (/home/debian/Bot/index.js:42:2)
at Client.emit (events.js:189:13)
at PresenceUpdateHandler.handle (/home/debian/Bot/node_modules/discord.js/src/client/websocket/packets/handlers/PresenceUpdate.js:48:16)
at WebSocketPacketManager.handle (/home/debian/Bot/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:105:65)
at WebSocketConnection.onPacket (/home/debian/Bot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (/home/debian/Bot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)
at WebSocket.onMessage (/home/debian/Bot/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:189:13)
i have change let by const
Does anyone know how I can make my bots status update? It shows how many guilds it is in but is there a way to update that when it joins a new server because at the moment i have to restart the bot for the status to update. Is there maybe a way to make a function where the status refreshes when bot.guilds.cache.size changes?
make a var
What do u mean
guildAdd event
Iâm not sure how I would write it out
21 error errno 1
22 error create-discord-bot@2.0.0 start: `node ./src/index.js`
22 error Exit status 1
23 error Failed at the create-discord-bot@2.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]```
any solution
no you can't update status on guild join
ready event fires when bot starts up
make a var for exemple "Servers" and use guildAdd or guildDelet
and use the var on the ready
so how would i do it with this:
console.log('BOT SUCCESSFULLY STARTED');
bot.user.setActivity(bot.guilds.cache.size + ' servers for cc!help', {type: 'WATCHING'}).catch(console.error)
})```
u can setinterval it updates after sometime
How would I do that
so how would i do it with this:
@sacred mountain
use the var
lol
@torn nebula you can lol...
you can change clients presence on guildAdd, and guildDelete event.
this could work ```js
client.on("guildCreate", () => client.user.setActivity(something));
yes
wdym
Donât u need to apply for an intent to use guildCreate?
in that case you can just use setInterval
K
What would be the best way to setup a premium system for by bot using patreon?
premium status in db using user ids
let servers = bot.guilds.size;
bot.on('guildCreate', function(guild) {
servers++;
}
bot.on('guildDelete', function(guild) {
servers--;
}
bot.on('ready', () =>{
console.log('BOT SUCCESSFULLY STARTED');
bot.user.setActivity(servers+ ' servers for cc!help', {type: 'WATCHING'}).catch(console.error)
})
Use that
I want it to be so they can only use it on one guild tho.
no @lament yoke
it works
no var
No var and it doesn't make sense
why ?
also, you can just remove guild from the event since you're not going to use it
bruh dont use var, use let and const instead.
@earnest phoenix so what i'd do is.... i'd have it so theres a scheduled task or cron job on your server
every day, hour, whatever you want, it wakes up
mhm
looks for new subscribers to your service via patreons api
and in your user records you have two flags
i need help
"has_donated" and "credits"
ok
so has_donated is flipped from false to true if they donate, and you skip over any that already have it set to true
with me so far?
when i downloaded vs code it made a auto folder and i cant find it
and then, when they donate, credits also has one added
Ok
Or use a webhook so you don't have to constantly poll the servers for updates
I get that part
then they can use that credit to apply to a server, you subtract from that credits value but preserve the has_donated = true
So if user_donated = true give 1 credit basically
atheonsphantom
Yup
otherwise each time your script runs on cron, youll keep giving them more and more credit đ
which would be funny for all of a few minutes đ
Could I also do it so I set Tier 1 to give role1 tier2 to give role2
yeah the tiers are provided by the api calls
and then have it to let say give 1 credit to users with role1
and 2 credits to users with role2
what is API...
only thing is you should probably store a mapping of user ids that have donated in the past
that way if they arent on your server when they donate, or they leave and come back, their roles can be auto assigned if and when they join your guild at a later date
Is there anyway to test this with patreon without me subscribing to my own bot? xD
đŠ
what's api
you could make a patreon tier for testing with a minimum donation of a cent
what's api
Yeah could do
application programming interface @elder moss a way for two systems to talk to each other
I was also thinking of another system.
is command prompt and node.js command promt diffrent?
if the internet was a plug and a plug socket, an api would be the electricians hand book that says what voltage and amperage đ
lol xD
is command prompt and node.js command promt diffrent?
Let say I make a big db of a bunch of 'premium' keys.
and hand them out?
sure that works
BUT
be very careful about generation of the keys, they must be cryptographically random
e.g. dont just use Math.rand()
Yeah 16 digit etc and totally random.
I was thinking that then I can just have a site made that a user will be able to purchase 1 key
use /dev/random or something for them
and then just do -redeem [key]
Alright
also you need to protect those keys like they were users financial details
even though theyre not
they have monetary value and will be a target of hackers
so encryption, every layer of security you can on those keys, keep as few on hand as you can get away with
i wrote a site once for a photography course where they'd give out keys like this on gift cards
it was fun, but a pain in the ass to ensure security
lol yeah
but how hard would it be be / long it take to make this key system that I am talking about?
not long, depends how quick you code
it would take me a couple of days with distractions i think?
Alright thanks for the info.
no problem đ
1 thing
So the user now has 1 token on their user ID
then can do -redeem premium
And the guild they did it in now has premium
not neccessarily
How would I go around making it expire in 30 days?
ah
oh ok
set an expiry date on either the key when you generate it in the table
so it has to be used within 30 days of generation
or set a timestamp in your guild details when its redeemed
i'd go with a timestamp in the guild data
a timestamp in the guild, for sure
I meant like patreon or key system đ
but you may also want an expiry on the keys anyway, depending.... to stop people hoarding them, also your keys table might want a 'revoked' flag
Yeah just in case
so if someone hacks you, or hacks a user, and steals a key, you can revoke that key, and it will still be in the db so you can log attempts to use it
Alright
a good example of how to do all this is steam's backend for game developers, unfortunately i cant show you that
im bound by NDA to not share it đ
but i can tell you how it works, for sure
as its pretty generic
Alright which system you think is better tho for my first premium system?
Patreon or this key system
hmm i'd go with the key system
another reason to go with the key system is, you dont have to use patreon to take the donation
patreon take a large percentage of small amounts
so if youre asking for say $3 donation for a tier you wont see most of it
Damn
if you used paypal or something instead, youd get a bigger slice of the pie
or even stripe, if you can wing it
I would use paypal but now I would probably need to get a site made.
this is why i didnt get around to doing my own donation system properly
because i was going to use patreon and someone here pointed out to me that i wouldnt see much of if any of the money lol
and i could be bothered to carry on creating it considering nobody wants to donate, they all want freebies
Yeah I have it the other way around xD
People want the premium
Since it is a giveaway bot so most people that use it have money to spend on premium
ah đ good idea then
i had a couple of people who said if there was premium for my bot they'd pay for it
so i set up a patreon, without specific attachment to the bot, and promised them something special in return manually if they did become patrons, neither did
all talk đ
hmm, probably an #memes-and-media lol... <mad hatter> CHAAAANGE PLACES!!! </mad hatter> đ€Ł
when im writing the package name in node.js command prompt it keeps failing
@earnest phoenix what kind of help do you need?
so if I launch one shard, my bot works just fine ,but if I launch an other this happens https://i.lumap.me/fvarpsiw.png
and apparently nothing happens
the bot still works
you are trying to do something that hinders the sharding manager to spawn more shards
idk what
and apparently bot activity isnt set for one of the shard
but is for the other
@earnest phoenix do you fixed it?
@earnest phoenix you can not do '${bot.user.username}' because ' and " don't allow template literals so you need to do inside ``
"This text has " + variable + " cookies"
`This text has ${variable}`
this is how you use variables in strings with either " and ' or `
Forgot the + in your first example
does anyone know why when i host mine on heroku it works but then it goes down an hour later
make that a few minutes
Is there a way for a bot to send a message if it doesnât have the required perms? Iâve been looking online but canât find an answer
Yes
How
get the member object of the bot
get the permissions
then check if it includes send messages
ok
This user has no bots
wdym by "glitched"
no like
models.guilds.findOne({guild: message.guild.id},
(err ,guild)=>{
if(err) console.log(err)
if(!guild) {
var newguild = new models.guilds(mconfig.Settings.guilds(message.guild.id))
newguild.save();
}
})
});```
then zoom out
bruh
and then i accidentally click remove page rather them minimise
that's a you problem
@storm bluff you dont get a message in guildCreate 
i know
why aren't you using a proper IDE
idk
@mossy vine guild and message not work
i know how to follow a yt tutorial
was that sublime or what
now*
or notepad
if i put guild not and message not work @mossy vine
then you should also know that yt tutorials are garbage
i dont really care
guildCreate doesnt provide a message object
I have a problem. I tried to make a function where the bots status updates whenever it joined a new guild but it doesnât seem to work... the code is below:
console.log('BOT SUCCESSFULLY STARTED');
bot.user.setActivity(bot.guilds.cache.size + ' servers for cc!help', {type: 'WATCHING'}).catch(console.error)
})
bot.on("guildCreate", () => {
bot.user.setActivity(bot.guilds.cache.size + ' servers for cc!help', {type: 'WATCHING'}).catch(console.error)
})```
it provides a guild object
yt tutorials arent that bad
no
yea they are
yes they are
no
find me a up to date tutorial right now
oh yea u fucking cant? thats what i thought
ok calm down
are you srsly gonna argue about shitty tutorials with people who know what theyre talking about 
why are you being so mean?#
why repost the same twice
Is someone able to help me
im dming a moderator
lmao
lmfao
hi whats ur problem
I have a problem. I tried to make a function where the bots status updates whenever it joined a new guild but it doesnât seem to work... the code is below:
console.log('BOT SUCCESSFULLY STARTED');
bot.user.setActivity(bot.guilds.cache.size + ' servers for cc!help', {type: 'WATCHING'}).catch(console.error)
})
bot.on("guildCreate", () => {
bot.user.setActivity(bot.guilds.cache.size + ' servers for cc!help', {type: 'WATCHING'}).catch(console.error)
})```
this can't get any worse
this is the 2020 equivalent of calling 911 on someone shit talking on xbox live
@sacred mountain any errors?

@marble juniper dont think so
k
lemme check again
except we shouldnt be talking shit but directing them to better resources
@mossy vine
cool
advice: don't copy paste code from random discord.js guides try to understand it
mega advice: read the text above the shiny colorful code blocks
@knotty steeple yes mongoose
advice: dont copy paste
advice: use brain
but i can still use yt tutorials
i only started coding yesterday
and im just trying to learn the basics
this will be one hell of a ride
trust me
I mean you can use yt tutorials if you want but I dont encourage you to watch them
sololearn only teaches syntax, not logic
i do javascript
even codecadamy works https://www.codecademy.com
thats like the only 2 sites i know
just learn js before making a bot with js
ok
i self teach myself most languages
same

Hi. Is there a way to send a message if the bot doesnât have the right perms (also like if it doesnât hav perms to send messages, send a dm saying that)
I canât find any info on it online
the docsâąïž
- why delete that and repost it
- to send a dm do
message.author.send()
But like how do I check it it has right perms
you guys have it easy while we have to fetch the dm channel
flazepe what lib do u use
ok
guess
idk eris
Hi, how can i detect when a person joins a voice channel.
pls not eris
why not?
read the docs
read the doctors

Hi
DJS 12
yes
upgrade to 0.12.0
haha yes
Degrade to 11.5.1
np
^ very useful
^
Yep.
@knotty steeple u filter it
ok ill just assume there isnt gonna be any more files
cuz i somehow cant find the function in crystal docs lmao
Canât find what Iâm looking for on the docs.... how do I check if the bot has a certain permission?
in which library
hes js if i rememebr
Oh hi Yh I am
read the docs correctly smh
I did
I searched that
yes
I know .haspermissions
but
Itâs just how do u do it for a bot
I only know how to do it for a member
for client user, it's guild#me, for a bot, just do the same
a bot is a member too ya know
if(guild.me.hasPermission("SEND_MESSAGES")?
@sacred mountain
if (message.guild.me.hasPermission())
Or
if (message.guild.member(<client>.user).hasPermission())
try. it. and. see
Jesus
don't ask us
why doesnt my bot turn on again if i use heroku
it went offline once now it doesnt let me turn it on longer then 5 minutes
tldr; don't use heroku?
i cant use the paid ones
check your logs, there should be a reason for crashing after 5 mins
an error or something
if(args[0] === "reset") return connection.dispatcher.setVolume(100/100).then(message.channel.send(reset))
(node:11353) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'then' of undefined
um
i dont get whats wrong with then
What do u want to do?
set the volume to 100/100 and then send a message
hlep
congrats u managed to show everything but the actual error
đ€Šââïž
@quartz kindle therei snt
my token is correct
why
there is only "Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect..."
hyro, what are you trying to do, and whats the error
ïŸ 
oh ok
lol
if(args[0] === "reset") return connection.dispatcher.setVolume(100/100).then(message.channel.send(reset))
(node:11353) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'then' of undefined
@earnest phoenix
nvm thats not the reason
fs.readdir("./events/", (err, files) => {
if (err) console.log(err);
files.forEach(file => {
let eventFunc = require(`./events/${file}`);
let eventName = file.split(".")[0];
client.on(eventName, (...args) => eventFunc.run(client, ...args));
});
});``` Is this how you do an event handler? d.js v12
the token was out of date but it wont go online for longer than 10 seconds
Try it and see
okay- can someone explain to me why whenever my bot turns on it decides to change its token..
if you set an id property in a schema, will mongoose's _id id getter override it?
does anyone know how to finish a whole script in discord js?
return;
now if you set an id property in a schema, will mongoose's _id id getter override it?
ok thanks
i need a lot of help-
my bots token is changing every damn second
can someone explain why .then wont work for me?
if(args[0] === "reset") return connection.dispatcher.setVolume(100/100).then(message.channel.send(reset))
(node:11353) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'then' of undefined
@earnest phoenix
What conetxt
@earnest phoenix set Volume returns undefined
It does smth, but it doesn't return smth
confused af
@earnest phoenix it is this
connection.dispatcher.setVolumeLogarithmic(100 / 100);
Just remove the .then
but i want it to send a message after tho
@earnest phoenix that's normal, you should be able to use old ones until you regenerate it
Use what I said
what is Logarithmic
.setVolume isn't just it on it's own
?
Remove the .then,keep message.channel.send
@earnest phoenix tokens are made of two components, a timestamp and the actual code. when you view your token in the discord developers website, the token will be generated with the timestamp of the current date, so every time you reload the page, the token will look different because the timestamp is different, but the actual code component doesnt change unless you regenerate the token. the code part of the token is whats actually important, it doesnt matter if the timestamp part of it changes, it works the same
Okie
Both works
likely because you have something wrong in your code
and there should be an error telling you that
theres no errors
and it was working just fine and i havent updated it
how can i stop the connection?
The set Volume function does his job, but u can't .then it beacause it returns undefined
oh ok
And u can't .then something not defined
how can i stop connection?
becuase when i play a song, it will say its playing the old song and the new one
so i want to stop the current connection playing
its staying on for longer
and then play the new one
Connection.dispatcher.end()
@earnest phoenix you need to figure out where the errors go to, there is always an error somewhere, otherwise you're blindfolded
It will trigger the "end" or "finish" event depending on your djs version
it works now
it didnt work like i wanted it to
when i play a song, it will say now playing and song name
but when i play another song, it will say now playing oldsongname and then now playing newsongname
Show your play command code
if(command === "play") {
let nosong = new Discord.RichEmbed()
.setDescription("Please specify a song name.")
.setColor(config.Red)
let vc1 = new Discord.RichEmbed()
.setDescription("You are not in a voice channel.")
.setColor(config.Red)
let noresults = new Discord.RichEmbed()
.setDescription("No results found.")
.setColor(config.Red)
if(!args.join(" ")) return message.channel.send(nosong)
if(!message.member.voiceChannel) return message.channel.send(vc1)
await message.member.voiceChannel.join()
const search = require("yt-search")
const ops = require("ops")
const ytdl = require("ytdl-core")
search(args.join(' '), function(err, res) {
if(err) return message.channel.send("ERROR")
let videos = res.videos.slice(0, 10)
let resp = ''
for (var i in videos) {
resp += `**[${parseInt(i)+1}]:** \`${videos[i].title}\`\n`
}
if(res.videos.length == 0) return message.channel.send(noresults)
resp += `\nChoose a number between \`1-${videos.length}\``
message.channel.send(resp)
const filter = m => !isNaN(m.content) && m.content < videos.length+1 && m.content > 0
const collector = message.channel.createMessageCollector(filter)
collector.videos = videos
collector.on("collect", async function(m) {
let video = videos[m.content-1];
let connection = await message.member.voiceChannel.join();
connection.playStream(ytdl(video.url))
let nowplaying = new Discord.RichEmbed()
.setDescription(`Now playing ${video.title}`)
.setColor(config.Green)
message.channel.send(nowplaying)
})
})}```
im new to it so i first used a tutorial lmao
You don't handle what happens if a song ends
so like
connection.on("end")?
Connection.play... .on('end', () => {
\here you take the song list and remove the first element and retrigger the play function
})
i can use connection.dispatcher tho
it will still not work
it will send that it stopped playing and disconnect
then the same thing
oldsong is playing, then newsong is playing
if a song is currently playing and i try to play another one, it will send that the old one is playing, and then the new one
what's your end event code?
connection.dispatcher.on("end", () => {
message.channel.send(stoppedplaying).then(message.guild.me.voiceChannel.leave())
})```
ik its wrong but i have no idea how to fix it so it stops the last song and then play the new one
do you even have a queue
have you checked your log?
maybe something's wrong with the code if it's not outputting anything
// A pretty useful method to create a delay without blocking the whole script.
const wait = require("util").promisify(setTimeout);
client.on("ready", () => {
// "ready" isn't really ready. We need to wait a spell.
wait(1000);
// Load all invites for all guilds and save them to the cache.
client.guilds.cache.forEach(g => {
g.fetchInvites().then(guildInvites => {
invites[g.id] = guildInvites;
});
});
});```
why??
Bot need Create Instant Invite permission
^
also whatever ur trying to do is against tos without the consent of the owner
if ur trying to make invites for all guilds
thats what im getting from ur code
Trying to get the invitation link of all servers. I guess.
You can add this permission in the bot invitation link. But server owners do not have to open this permission. Therefore, it will be useful to use the try catch structure separately.
It would not be good for the bot to collapse only because of someone's did not allow permission.
@quartz hill have administrator
Not all server owners can grant admin authority.
oh
You can edit the permissions while taking the bot to the server.
Especially in bots with admin privileges, server owners revoke this permission.
or just
dont randomly make invites?
because u have the perm doesnt mean u can abuse it or just use it completely any way you want
Use try catch. Try to give all necessary permissions except admin permission.
If a server owner already allows it, I think it's okay to use it.
Of course, do not abuse anyway.
Would anyone be able to help with sharding in discord.js with typescript?
Currently when I create a new ShardingManager and point it to a .ts file it throws an error saying SyntaxError: Cannot use import statement outside a module.
"Cannot use import statement outside a module"
I would like to ask, how do I fix the msg.guild.roles.fetch(role => role.name === "Blessing of Cuteness"); which returns me some discord API error mssing permission.
where did you get that from?
roles.fetch fetches a role from the API using a role ID
or all roles if left empty
it doesnt take a function as a parameter
in any case you would never need to use that because roles are all cached by default
@mortal flare I think you're looking for .some or .filter maybe
or find
^
yeah
in any case, better explain what you're trying to accomplish than asking how to fix X, just to make sure X isnt the wrong thing to do regardless
.find(thestuffheputinthe.fetch)
MessageReaction object has like 1,000,000 undefined objects inside of it
change my mind
đ
wat
oh that
It's just difficult to find the objects that have the powerful methods
I've done that before, ur using awaitReactions right?
Nah, I gave up on that method since I wanted it to be long term
I'm doing it off client messageReactionAdd
my menu uses ReactionAdd as well
mine doesnt
but the problem I'm at is
the variables reaction and user correlate to a "MessageReaction" object
that only removes my bots reaction, not the human
you need to fetch the message
awaitReactions is easier than using that event tbh
oh, like redefine the message and use the better functions?
you're trying to make it work long term right? ie: never expire
yeah
well, it's just a help menu its not the end of the world if it expires
Hey If i Submitted my bot should be to many users used ?
so you need to fetch the message first
I'm just getting rid of spam and trying to split up the info given
@mint cypress yes, it should be a public bot that anyone can use
Ok Thx And How Many ?
@maiden mauve my reaction menu works like this:
on reactionAdd
if reaction = one of reactions that the menu supports
-> fetch message
-> -> if message author = my bot
-> -> -> message.edit
@restive furnace but you can use import statements outside of modules 
@mint cypress how many what?
Thanks Tim thats the pseudo I'm going for
fetching the message has been a task
to verify its the correct menu
I'm basically doing "import" on L1.
the message itself seems to be an object of the reaction but it's not
if you enable partials, you will get a partial message
so you need to fetch the message by its id
Ah, will that have significant impact to the rest of bot though?
When I read that stuff it said all or nothing
its an api request, so it will impact your rate limits, but shouldnt be a problem
Gotcha ty
thats why you should make all possible checks before you fetch it
yeah I've just been inching through the problem for fun
ie: if the reaction is one of the possible reactions your menu uses, to avoid fetching irrelevant messages
to help with this task, my menu uses custom emojis only
theoretically, a user could be a dork and try to load menus off reacting to random things
yeah
I validate that it's a DM and one of the two arrow emojis
but i need to further validate which embed is currently loaded
im guessing ill get that from message
yes, you can get it from the message after fetching it
i put an index in the embed footer to track it
oh thats a little smarter than the title
in any case, better explain what you're trying to accomplish than asking how to fix X, just to make sure X isnt the wrong thing to do regardless
@quartz kindle okay what i was trying to achieve is i am trying to look for a specific role by name and assign it to someone
@mortal flare then yes, the correct thing is guild.roles.find(role => role.name === "yourname") in v11 or guild.roles.cache.find(role => role.name === "yourname") in v12
@maiden mauve also, you dont need to remove the user reaction every time they react
you can simply listen to reactionRemove events as well
its a little more efficient that way
I was approaching the "keep emojis in order" issue
but if I left Page 1 go back to Page 6
so you basically double down on both events
i assign the same function to both events
so adding or removing does the same thing
if((reaction.emoji.name === ':arrow_forward:') && reaction.count > 1) {
await reaction.message.edit(embedP1);
the inverse would be count < 2 I suppose
oh yeah I guess it doesnt matter
I tried using the bot boolean for that
but again I didn't have the right object
the message is always owned by the bot
@mortal flare then yes, the correct thing is
guild.roles.find(role => role.name === "yourname")in v11 orguild.roles.cache.find(role => role.name === "yourname")in v12
@quartz kindle .find function is undefined, I am, using v 12.2
but the reaction itself has an identity user right?
yes, the user who reacted is in the user parameter, not in the reaction
âïž
@mortal flare show code
thanks for holding down the fort, Tim always helpful without feeding XD
:3
` let {cache} = msg.guild.roles;
let newRole = cache.find(role => role.name === "Blessing of Cuteness");
if(!newRole)
return msg.channel.send(`cannot find role: ${newRole} in this server\n please make sure that the role exist in the server`);
else{
if(msg.member.roles.cache.has(newRole.id)){
msg.channel.send(`@${person.user.tag} has already been blessed with ${newRole.name}\ndon't be greedy.`);
} else {
let time = args[2];
if(!time){
msg.channel.send("please specify time in the argument");
}
person.roles.add(newRole.id);
msg.channel.send(`@${person.user.tag} has been blessed with ${newRole.name} for ${ms(ms(time))} (or until this bot dies).`);
setTimeout(function(){
person.roles.remove(newRole.id);
msg.channel.send(`@${person.user.tag}'s blessing has expired.`);
}, ms(time));
}
}
`
how i do randomtext?
Why is my bot down ?? in #logs -> @earnest phoenix added bot @DarkyBot
https://top.gg/bot/700297851397341194
@earnest phoenix your bot is not verified
you need to wait for verification
check #502193464054644737
let newRole = cache.find(role => role.name === "Blessing of Cuteness");
if(!newRole)
return msg.channel.send(`cannot find role: ${newRole} in this server\n please make sure that the role exist in the server`);
else{
if(msg.member.roles.cache.has(newRole.id)){
msg.channel.send(`@${person.user.tag} has already been blessed with ${newRole.name}\ndon't be greedy.`);
} else {
let time = args[2];
if(!time){
msg.channel.send("please specify time in the argument");
}
person.roles.add(newRole.id);
msg.channel.send(`@${person.user.tag} has been blessed with ${newRole.name} for ${ms(ms(time))} (or until this bot dies).`);
setTimeout(function(){
person.roles.remove(newRole.id);
msg.channel.send(`@${person.user.tag}'s blessing has expired.`);
}, ms(time));
}
}
@quartz kindle this is the only way I manage to get find() function working
@earnest phoenix when did you add your bot?
@earnest phoenix That's a question for #general, not #development
Yes it's ok
Hello.
I'm trying to play music on voice channel using ytdl.
I have imported ytdl, opusscript, and ffmpeg is added into windows global variables.
connection.play(ytdl("https://www.youtube.com/watch?v=GG5cE14G2Gg", {filter: 'audioonly'}));
And I'm getting exception from opusscript:
var Module=typeof Module!=="undefined"?Module:{};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[k[...] (looong line)
TypeError: Cannot convert "null" to int
at Object.toWireType (C:\Users\hasht\WebstormProjects\tad1bot\node_modules\opusscript\build\opusscript_native_wasm.js:8:47113)
at OpusScriptHandler$_encode [as _encode] (eval at new_ (C:\Users\hasht\WebstormProjects\tad1bot\node_modules\opusscript\build\opusscript_native_wasm.js:8:36904), <anonymous>:11:26)
at OpusScript.encode (C:\Users\hasht\WebstormProjects\tad1bot\node_modules\opusscript\index.js:69:28)
at Encoder._encode (C:\Users\hasht\WebstormProjects\tad1bot\node_modules\prism-media\src\opus\Opus.js:55:25)
at Encoder._transform (C:\Users\hasht\WebstormProjects\tad1bot\node_modules\prism-media\src\opus\Opus.js:138:30)
at Encoder.Transform._read (_stream_transform.js:189:10)
at Encoder.Transform._write (_stream_transform.js:177:12)
at doWrite (_stream_writable.js:431:12)
at writeOrBuffer (_stream_writable.js:415:5)
at Encoder.Writable.write (_stream_writable.js:305:11)
at VolumeTransformer.ondata (_stream_readable.js:727:22)
at VolumeTransformer.emit (events.js:210:5)
at addChunk (_stream_readable.js:309:12)
at readableAddChunk (_stream_readable.js:290:11)
[...]
at writeOrBuffer (_stream_writable.js:415:5)
at VolumeTransformer.Writable.write (_stream_writable.js:305:11)
Process finished with exit code 7
@discordjs/opus and node-opus dont work either.
What should I do?
thanks
how i do randomtext?


