#development
1 messages · Page 924 of 1
you always return something
if you don't add one yourself then it'll be return undefined; or just return; by default
okay thx
if you want the code to stop from executing use a return
there can't be code below a return statement unless the return is inside of an if statement
bc once it reaches the return the function 'returns' and stops from executing
ŗ̸̉e̶͋̚t̴̽͋u̵̇͋r̸̛̍n̷̛̈ ̴͆͑v̸̐̽o̷͋͌ì̴̲d̶̏̄;̵̽͝

can someone help me for something else?
don't ask2ask
I would like to create a text file that groups all my results, and if the result and I even raised everything
discord.ext.commands.errors.MissingRequiredArgument: url is a required argument that is missing.
params: self, ctx, *, url
python
you're not passing in an url parameter
so?
so???
how come you're even asking
pass in the url param
when you run the command
i do -play <url_here>
remove that *
ok
suddenly someone can help me on what I want to do:
I would like to create a text file that groups all my results, and if the result and I even raised everything
i need url parameter for this
player = await YTDLSource.from_url(url, loop=self.client.loop)
```@copper cradle
wait nvm
but dont work
show you code
@client.command()
async def play(self, ctx, url):
"""Plays from a url (almost anything youtube_dl supports)"""
async with ctx.typing():
player = await YTDLSource.from_url(url, loop=self.client.loop)
await ctx.voice_client.play(lista[0], after=lambda e: funcion2(ctx))
await ctx.send('Now playing: {}'.format(player.title))
You don't need self if the function is outside of a class
just ctx, url?
Yup
player = await YTDLSource.from_url(url, loop=client.loop)
await ctx.voice_client.play(lista[0], after=lambda e: funcion2(ctx))```
play is nonetype
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'play'
voice_client is None
@client.command()
async def play(ctx, url):
"""Plays from a url (almost anything youtube_dl supports)"""
async with ctx.typing():
player = await YTDLSource.from_url(url, loop=client.loop)
===> await ctx.voice_client.play(lista[0], after=lambda e: funcion2(ctx)) <===
await ctx.send('Now playing: {}'.format(player.title))
So I have a problem where I get a Null exception from the top.gg Api
I am using Discord Net and the DBL-dotnet-library.
In my ReadyAsync() I have the following code:
AuthDiscordBotListApi AuthDBApi = new AuthDiscordBotListApi(_client.CurrentUser.Id, Environment.GetEnvironmentVariable("DBO_TOKEN"));
_ = Task.Run(async () => {
IDblSelfBot DB_Bot = await AuthDBApi.GetMeAsync();
await DB_Bot.UpdateStatsAsync(_client.Guilds.Count);
await Task.Delay(1000 * 60 * 10);
});
But the 4th line (IDblSelfBot DB_Bot = ...) returns a NullReference Exception.
Does anyone know what I am doing wrong?
i want to find the options.webhookAuth the docs said The string for Authorization you set on the site for verification. but I can't find that string
How do you get the channel ID and save it that differs from server to server?
how i get the hours? 11v
It's for a welcome com
I'd really appreciate the help rn
I need to get data from this json but can't figure out the right path
[{
"type": "qrcode",
"symbol": [{
"seq": 0,
"data": "Hello Test!!!",
"error": null
}]
}]
I am trying: js await fetch(QR_URL) .then(response => response.json()) .then(json => { console.log(json.symbol.data) }
and that is giving me error Cannot read property 'data' of undefined
why array?
It's from an API I can't change it
response.json() returns a promise
u should probably use await separately here instead of chaining .then
Is there a simple command to make the bot delete new messages in a certain channel?
I want to create a channel, where people can write commands, they will deleted after they write them
if(message.channel.id =" " ) {delete.message(1000)}
something like that?
@heavy anchor its an array, access it as such: json[0].symbol.data
Thank you Tim I will read up on it
So, I tried to make it like that, but I get an error message.
if (typeof options !== 'object') throw new TypeError('INVALID_TYPE', 'opti
ons', 'object', true);
^
TypeError [INVALID_TYPE]: Supplied options is not an object.
The code was this:
if(message.channel.id =="id")
{message.delete(1000);}
delete takes an object in v12
aha
I see
thanks, it works^^
message.delete({ timeout: 1, reason: 'It had to be done.' });
Why even provide the timeout if it's 1ms
hi
i'm trying to overwrite the permissions for every channeljs message.channel.guild.channels.forEach(async(channel) => {await channel.editPermission(message.member.id, {allow: 0, deny: 2048 })})
why can i still speak?
and other users can
when they use that code, with eris
Should I cast my dictionary to a custom class for simplicity purposes or should I keep it as a dictionary?
Im using a config file and when I load it, it gets turned into a dictionary
@sturdy hare are you using js?
yes
Then watch some tutorials on how to setup a webserver with express
It's not hard at all
@white gyro how but you chill out?xD It was just randomly a number I have put in to show the function, maybe there are people who also want to know how I solved my problem.
Once you have a working webserver all you need is to pass the url to the bot's page config
Btw, check whether you have nginx or apache tomcat installed in your vps
If you do have, you'll need to setup a proxy connection
What does this mean?
(node:116) UnhandledPromiseRejectionWarning: SqliteError: database disk image is malformed```
const db = require('quick.db')
module.exports.run = async(client, message, args) => {
let user = message.mentions.users.first() || message.author //This will show us how much money a user has when we mention them
let money = await db.fetch(`money_${user.id}`) //This will fetch the amount of money we have in our account
message.channel.send(`${user} has a balance of $${money}`)
}
module.exports.help = {
name: "balance",
aliases: ["bal"]
}
ScreenShot?
@elfin yarrow
Ok
😁
What does this mean?
@clear wraith something in your database goofed up while writing and now you have a corrupt entry which you can only find and get rid by yourself before the database works again
I don't remember how I fixed the issue but you can do it by exporting your database into sql, and importing it to make a new fresh sql file
Which will work
If the data there doesn't matter too much just delete the database and restart really, but you need to export the database and create a new one with the Sql file
You also need to ignore malformed queries
Alright, Thanks.
I don't remember how I fixed the issue but you can do it by exporting your database into sql, and importing it to make a new fresh sql file
@split hazel I've had this before, how would you do this?
ty
it is on topic
no
please speak english
Translate to turkish
#memes-and-media for other languages
@patent birch translate to English
@gleaming glen
No
No u
@patent birch I took a screenshot
Np
What is the code for setting a bot's status? I want it to say "Playing a.help" as if it's playing a game, but I can't get it to work. here's what I have:
setInterval(function() {
bot.user.setActivity("a.help", {type: "ONLINE"});
})```
@summer torrent Add bot helping?
"type" must be a "WATCHING", "LISTENING" etc. @reef heath
so like... put "PLAYING" then?
no
oh. will it affect how it shows up visually if I choose different options?
I mean like is there a difference between watching and listening?
@patent birch https://top.gg/bot/new
Thx
I mean like is there a difference between watching and listening?
@reef heath watching
🤔
do you want all of the code?
if it works for you, no
where is this code? ready event?
The ready event is when the bot is ready.
Hes asking where is this code in?
bot.on("ready"...
or in a event handler
//creates bot as client
const bot = new Discord.Client();
//token acts as access password
const token = 'NOPE';
//set bot prefix
const PREFIX = 'a.';
//terminal sends message when bot is online
bot.on('ready', () =>{
console.log('bot is online')
})
setInterval(function() {
bot.user.setActivity("a.help", {type: "WATCHING"});
})
What did I miss? The name didn't get updated.
setInterval(async () => {
const guildw = await client.guilds.cache.get('709197832006926380')
const channelu = await client.channels.cache.get('709575417857572984');
const channelb = await client.channels.cache.get('709575836302442546');
const channelg = await client.channels.cache.get('709576263265681481');
channelu.setName(`💮 User Count: ${guildw.members.cache.filter(m => m.user.bot === false).size}`).catch(err => console.log(err));
channelb.setName(`💮 Bot Count: ${guildw.members.cache.filter(m => m.user.bot === true).size}`).catch(err => console.log(err));
if (guildw.members.cache.filter(m => m.user.bot === false).size >= 1000) channelg.setName('💮 Next Goal: 2000').catch(err => console.log(err));
}, 1000);
i'm using Visual Studio
well thats every second, just saying thats against TOS
you might wanna add another 0 to that.
ouch k
but other than that i dont really know.
K thanks anyway
@reef heath put the code in "ready" event
No,
Put the code in the ready event
bot.on('ready', () =>{
console.log('bot is online')
setInterval(function() {
bot.user.setActivity("a.help", {type: "WATCHING"});
})
});```
dont thank me thank NMW03, i just explained it better for you >_>
👀 👀
<333 nmw
np
move #memes-and-media and explain your problem in turkish
Okey sorry my bad
is there any downside to having your bot react with 4 different reactions every 7 seconds for thousands of users? Is there a bottleneck somewhere with this situation? Unfortunately I don't think discord.js lets your bot perform 4 different reactions with just 1 request to the api...?
Well i wouldn't know, but my guess is cpu usage 😔
hi, uh any ideas why await m.findOne({ id: client.user.id }); would be null? m is require('../../models/Bot');
I'm using Discord.js, message.guild.members.cache.get(id).avatarURL() tells me that it is not a function, but client.user.avatarURL() is and works, what is the issue?
Also what are you trying to do @digital ibex
@fallow quiver the difference is you're calling avatarURL on the GuildMember instance, while you called it on the ClientUser (extension of User) for the client user instead. Try using the method on the user (<GuildMember>.user)
Aka it's in the docs that you can't call it on a guild member: https://discord.js.org/#/docs/main/stable/class/GuildMember?scrollTo=user
I figured it must've been some simple oversight like that
search = search.toLowerCase();
if(!(msg.channel.type === 0 || msg.channel.type === 5)){ return;}
if(!members){
members = msg.channel.guild.members;
}
let member = members.find(user => (`${user.username}#${user.discriminator}` === search) || (user.id === search) ||
(user.username === search) || (msg.mentions[0] && user.id === msg.mentions[0].id) || (user.nick != undefined && user.nick === search));
if (member == undefined) member = members.find(user => (user.username.toLowerCase() + "#" + user.discriminator === search.toLowerCase()) ||
(user.username.toLowerCase() === search.toLowerCase()) || (user.nick != undefined && user.nick.toLowerCase() === search.toLowerCase()));
if (member == undefined) member = members.find(user => (user.username.toLowerCase().includes(search.toLowerCase())) ||
(user.nick != undefined && user.nick.toLowerCase().includes(search.toLowerCase())));
return member;
}
``` I am using this user resolver, and when I run the avatar command (a command i made using this), it doesnt find the author's avatar, it pulls from a random server member
Any idea why? Im using eris
can you send me the whole function?
you can try console.log(member) before return member to see what it got
@ember atlas
module.exports = {
resolveUser: function(msg, members, search = '') {
search = search.toLowerCase();
if(!(msg.channel.type === 0 || msg.channel.type === 5)){ return;}
if(!members){
members = msg.channel.guild.members;
}
let member = members.find(user => (`${user.username}#${user.discriminator}` === search) || (user.id === search) ||
(user.username === search) || (msg.mentions[0] && user.id === msg.mentions[0].id) || (user.nick != undefined && user.nick === search));
if (member == undefined) member = members.find(user => (user.username.toLowerCase() + "#" + user.discriminator === search.toLowerCase()) ||
(user.username.toLowerCase() === search.toLowerCase()) || (user.nick != undefined && user.nick.toLowerCase() === search.toLowerCase()));
if (member == undefined) member = members.find(user => (user.username.toLowerCase().includes(search.toLowerCase())) ||
(user.nick != undefined && user.nick.toLowerCase().includes(search.toLowerCase())));
return member;
}
}
this is just my function
do you want me to still console.log it?
yeah sure
and does the avatar command need user input? (or would it resolve to message author by default?)
oh that one got dyno haha
ya 
you can make your function a lot shorter and cleaner by omitting some brackets and combining stuff into one variable (member)
You should be able to easily get the member object from the person who authored the message, instead of having to search every member in the server.
Boss are you using ERis?
Any idea why? Im using eris
Ah sorry
send the avatar command
Also the search is being converted to lower case but the user's username is not.
really 
you're right

So first you look with the name not being lower cased then you check again for if the user's username is lower cased (which is kind of slower with little benefit except for cases).
Can you show the avatar command?
are you sure you provided the correct arguments
async execute(callisto, msg, args) {
const member = resolveUser(msg, args.join(' '));
if(!member) {
return callisto.createMessage(msg.channel.id, `${error}Invalid user!`)
}
callisto.createMessage(msg.channel.id, {
embed: {
author: {
name: `${member.username}#${member.discriminator}`,
icon_url: `${member.avatarURL}`
},
color: `${defaultColor}`,
image: {
url: member.avatarURL
},
timestamp: new Date
}
})
}
}
module.exports.cmd = Avatar;
The second argument should be the guild members collection
The third argument should be the search.
so msg, null, args.join(" ")
I think it pulls a random member due to "some person's username".includes("") will pretty much return anyone
oh
by the way, it's not really resolveUser because it returns a member
you might want to make it return member.user
Hi, I'm just wondering if it's possible to make a bot with ES9 or if it is only applicable to Javascript.
You need it to return msg.member if no args were passed (empty search).
Well you can make a bot using javascript 🤔 @rose warren
I'm trying to get my bot to host on heroku/github 24/7 so that it stays on. i got to the very last step but my worker dyno will not show up, and idk what the problem is. please help
if you have used this before or use it now, please help
the code in my procfile reads:
Worker: node index.js```
index.js IS the name of the file that stores my code
It's worker not Worker
that's really the issue?
and it's Procfile
OKOK sorry haha
Of course it can be, things are case sensitive
try refreshing
refreshing what? heroku? i did
refresh the resources page
then you suck
...dang-
like... take a screenshot?
ye
Try deploying your github repo again, otherwise it's probably because it can't find the procfile.
i'm sure they turned on automatic deployment
Hey tenpi, just going off of what you said earlier. How come big bots hit the api limit very frequently if they’re sharding?
Too many people flooding in one channel?
No, there's always an option to "deploy" the code again
are you sure you pushed your changes
yes
in the github desktop app under history?
in "actvity"
exists on both actually
view build log
latest one?
yeah
There might be run time errors in your app
something is wrong with your procfile
On your github repo it's still "procfile"
Git ignores filename case changes by default
Oh
but he changed Worker to worker
oh ik what u mean
yeah git doesn't detect a change
just add a newline and push
use git config core.ignorecase false
are you serious
Or delete and remake the file
git push
right?
i'll delet and remake
uh okay i fixed Procfile but
oh wait hang on
YES WOOHOO
THANK YOU BOTH MWAH MWAH
np
I am using FS with Javascript to write to a file, upon restart however the file seems to revert, I am calling the fs.writeFile() in an imported file, is there a way in said imported file to force it to save the file?
Y'all considering a saved playlist feature?
Who is y'all
I know I can add a bot to keep from disconnect but a command or feature to save would be nice
Devs @smoky spire
Command being no disconnect would be nice
Devs of what
Ah fux .. Thought I was in Rythm lmao .. Please delete my messages
Essentially all I want to do, is at the end make sure that the changes are saved to the next reboot
You'll probably need to save it in a database so that it persists when the bot restarts
Changes I make in the main file persist, but any changes in the imported command file disappear after the reboot
It's weird and I don't really get it
yes
because it's all in memory
you shut the process down
memory goes bye
use a database
java -jar Lavalink.jar
try pm2 start java -- -jar Lavalink.jar
-- means that whatever is coming afterwards, you pass to the process instead of treating them as pm2 arguments
so what this really means is
hey pm2, please start java and give it the args -jar Lavalink.jar
Create a pm2 config file
Read more here: https://pm2.keymetrics.io/docs/usage/application-declaration/

why are you using eris-sharder? are you clustering?
yes
how much
I use it so in the future I'll not have to worry about shards being dicks
nvm, it wont connect
password is good, host is set as "localhost"
even in the application.yml
Are you sure it's running then
yes it is
pm2 logs <whatever you named the app> --lines 100
im definitively blind
👏
https://cdn.lumap.me/d5165tf2.png whats the best one? im trying to implement ll to my discordjs bot
eris later
What version of djs do you use
12
I would recommend shoukaku
Is this normal ??
no
:((
so how i can fix
xD
oh
i know why
i do 1 request per 1 min
now they blocked
how many requests per minute?
oh nvm
Well yeah you're being ratelimited, time to optimize your code eh
yes
Some of the servers seem to have been deleted because of shard. xd
how do i make a command handeler?
language, library?
what library are you using
discord.js
channel.fetchMessages({ limit: 100 })
``` Is this an invaild option in v12
OOh thank you that helps alot 🙂
slice
catching errors on .send() should catch that too
What does this error mean?
Could not extract html5player key: https://www.youtube.com/s/player/376e3c34/player_ias.vflset/en_US/base.js
are you using ytdl-core-discord?
im using ytdl-core
afaik that was fixed in the last ytdl-core update
ok
no
-faq 2 @tranquil wedge
@tranquil wedge
let date = Date.prototype.getDate() + Date.prototype.getMonth() + Date.prototype.getFullYear()
(node:1092) UnhandledPromiseRejectionWarning: TypeError: this is not a Date object.
Why am I getting this error?
please dont do that
what do u want
full year full day full month
is this for server info or something
ah
u cant just add it like that
so how can I
U got to use the new Date(); so
var Date = new Date();```
I dont think that prototype is part of the date
also that
if(command === "date") {
let date = Date.getDate() + Date.getMonth() + Date.getFullYear()
message.channel.send(date)
}```
Currently have this code
(node:2770) UnhandledPromiseRejectionWarning: TypeError: Date.getDate is not a function
cuz it isnt
how do you make a bot that send a message every 3 message by a user?
I used a google answer lmao
I tried to find something but that's the first thing I found
maybe look at the docs
u have to use the constructor first
cool i just woke up so im being stupid
@earnest phoenix u want a bot that sends a messages every 3 user messages?
yes
I am trying to recreate tembot from LilyPichu discord server
I think it’s twitch sub only
fucking
request(options, function(err, result) {
if(err) console.log(err);
let xp = JSON.parse(result.body);
console.log(xp);
return;
})
ahm how i can stop request
cuz it keep console.log
return is not working
stop calling it
const attachment = new Discord.Attachment(canvas.toBuffer(), 'picture.png');```
oh wait
why is this not working in v12?
oof i am dumb
(node:6397) UnhandledPromiseRejectionWarning: TypeError: Discord.Attachment is not a constructor
i couldnt find it in the guide of v11 => v12
is it not allowed to have a server leaderboard
say like total xp earned on the server idk
actually why wouldnt it be
Hello. I have my bot set up to run on heroku 24/7 but it keeps going offline every couple minutes anyways. what do i do?
¯_(ツ)_/¯
@knotty steeple why would it be allowed or why wouldnt it be allowed?
why wouldnt it be allowed
go ahead and do it cuz lots of bots have server leaderboards
are there some examples?
@reef heath heroku automatically closes the websocket connection if there’s no activity
don’t host using heroku
you’re wasting your time
pretty much
idk because having a list of servers your bot is in isnt allowed
Then what do I host with?
dont want it offline? use an actual paid host
a vps
There's no code that could keep renewing the connection to Heroku?
there is, but don’t use heroku
they force you to pay stupid sums of money if you use them for too long, the environments are very heavily containerised would running other services is near impossible, and the stability is awful
I'm just saying like.. I'm a kid. I don't have any source of income or a card to even pay for a paid host
¯_(ツ)_/¯
DigitalOcean minimum is $5/month
you can get cheap vps for $3/mo
glitch is good enough for a very basic bot
its the same as heroku, but more people use it, and its also easier to use
Can I plug my digitalocean referral code 
a referral can get you 3 months to use $100 of credit on DigitalOcean
huh
i could pay for a $10 host if i save money from school
if u use glitch then u can use uptimerobot to keep it alive for free
nothing really else to explain, use glitch to make the bot then use uptimerobot to keep it up :/
what is uptimerobot
glitch is meant for the web, websites and webservices, so it automatically sleeps when not in use, then it wakes up when it received a connection/request
discord bots use websockets, which is a kind of connection that glitch doesnt count as a request
so you simply need to periodically make a web request to your glitch project while your bot is running
to keep it alive
Using an actual VPS would still be a lot better though
hello, i need help, im tryting to do a command that read a file where i put
Premium: ["486460106792239104", "648133423722135563"]
}```
But when i put in the command
const premiums = data.config.premiums
if(premiums === message.author.id) {
messahe.channel.send(prob);
}
im tryting to doto this
{
Premium: ["486460106792239104", "648133423722135563"]
}
only work with 1 id
and i want 2 or 3 or more ids
but idk how
premiums["id"]
but i want more ids
Hi there! Is no way to read group messages from other bot? On Discord.Net
u can just check if premium[id] exists
id being the user id
tho idk does this work with arrays
i need help with something
if(premiums.includes(message.author.id))
how do i fix this
@indigo cloud what are u running
visual studio code
a discord bot\
oooh
this is the code i have set for now
i am not really good at coding tho tried to follow a yt video
you didnt save the file
also, how did you run it? (what did you type in the terminal)
console
uuh how do i save it lmao
nvm thanks
yikes
👍
Hi there! Is no way to read group messages from other bot? On Discord.Net
@rigid raven noone? :(
also learn js from a site instead of a video saying how to make a bot specifically
@rigid raven you mean group DMs?
alright
bots cant access group DMs
wait u know codelyon?
i am following his tutorial
@earnest phoenix horny much
I > bots cant access group DMs
@quartz kindle I mean read a bot on the same server chat, like users do
read the docs
im not understanding what you mean
CodeLyon is good
messages from bots come through just like regular messages
but his code is outdated
Did anyone ever had this problem on ytdl core?
ERR_INVALID_ARG_TYPE
The "url" argument must be of type string. Received undefined.
It happens randomly, and I try&catch everything but I still get this error. It does not happen on the same video and it is a rare event.
@knotty steeple need xd
@cinder dove you tried giving it an undefined string
use some api
@quartz kindle
thay provides with it
just check if the url is defined before giving it to ytdl
premiums: ["486460106792239104", "648133423722135563"]
}```
and i try it removing prmeiums: []
put it in a string
and only put "" wit the ids
The problem is it happens like once in 100 times. Very rarely and random
or double quotes
and nothin
I can't troubleshoot it ;/
put premiums in dougle quotes
@earnest phoenix json files require quotes on keys too
" <- quote
""
ok
im not understanding what you mean
@quartz kindle haha sorry, my english sucks, I mean:
I have two bots on a server. And one of them says something. Can I read this message from the other bot?
@cinder dove show your code, where you put ytdl(url)
messages from bots act like normal messages from users
Yup sec.
@earnest phoenix show code
what is premiums defined as
if(premiums.includes(message.author.id)) {
return message.channel.send(`prob`)
}```
premiums.premiums
ok
or add .premiums where u require
ok
ok, now work, thanks
discord.py bot. i have a clear command, but when there is lets just say 5 messages and i say clear 100 messages it returns cleared 100 messages. is there anyway i can clear 100 messages but it only says the amount of messages that have been actually cleared like mee6?
and ALSO how do i make my bot delete its own messages after about 5 seconds
no one?
count the amount of items you have when you get the messages to delete
that will be your number of actually deleted messages
const song = null;
const songInfo = null;
The ytdl.getInfo function:
try {
songInfo = await ytdl.getInfo(url);
song = {
title: songInfo.title,
url: songInfo.video_url,
duration: songInfo.length_seconds
};
} catch (error) {
// then I either return copyright protection message, either use the search, I will skip the copyright handler:
const results = await youtube.searchVideos(search, 1);
songInfo = await ytdl.getInfo(results[0].url);
// then I define song like I do to an URL
//The other YTDL function I use on the second file on the play function is:
var stream = await ytdlDiscord(song.url, { highWaterMark: 1 << 25 });
The error i've mentioned earlier can happen while shifting the queue (after a song ends - it starts another) or when you use play. I use try and catch for all of those mentioned above, and also using if url === undefined returns, but still getting the error..
The bad thing is that It doesn't lead me to where the error is and since it is happening so rarely, I didn't know for about 2 weeks this error is in my code.
I've searched it up online but seems useless. @quartz kindle
@earnest phoenix yea ik
but how do i make it return that
in ctx.send
i have it set to {amount}
so it sends the amount that I said
but not that has actually been cleared
count the amount of items history().flatten() returned
😐
that is python fundamentals
i have 0 experience in python and i know how to do it, or well learned with a 5 second google search
i searched
alot
and couldn't find shit
For all those people who find it more convenient to bother you with their question rather than search it for themselves.
@cinder dove the error can happen in any of the youtube/ytdl functions, there is nothing saying from which it is, so you can just check them all:
if(!search) return
if(!results[0] || !results[0].url) return
if(!song || !song.url) return
each before the line that uses it
you can return an error or a warning if you like
I'm pretty sure it may be this one var stream = await ytdlDiscord(song.url, { highWaterMark: 1 << 25 });
However I really don't understand where I went wrong in this code 🤔 .
Thanks for the suggestion. I will someday need to fix this to encounter bad reviews.
song.url should be defined from the getinfo earlier, however it just gives me this error once in a while.
getInfo might not have found anything
you always have to account for the possibility that whatever function you use finds no results or an invalid result for some reason
if(message.guild.channels.cache.find(m => m.name === `ticket-${message.author.username}`)) { return message.channel.send(`❌ Vous avez déjà un ticket ouvert.`) }
why this doesn’t work?
you tell us
also
use a database for tracking tickets
The issue is - it says ''starting playing X (video title) + (link)"
then it joins and gives me this error. (at a random time, not always)
as your user can change their username and discriminator anytime they want
uh yes thx
or user id
still inconvenient since someone can change the channel name
@cinder dove if you think it has the proper results, then check if you're not using global variables in a way that multiple commands start overriding each other
so im trying to make a lavalink musc bot and i followed along with the menudocs video this is my code(https://hastebin.com/wopuxacuxe.js) but whenever im in a vc and i try to say -play <song name> it says you need to be in a voice channel any idea why?
What version of Discord.js are you using.
Pretty sure it's guild (map based), however it could be part of the issue. Will take this into further tests.
You're using a bunch of properties/methods from v11 that are no longer present/have changed in v12.
that's the reason why you don't follow youtube "tutorials"
follow official docs and samples and build your code from there
i don't know which library you're using for interacting with LL
Here we go.
used:
if(!song || !song.url) return
console.log(song.url) // This got logged
var stream = await ytdlDiscord(song.url, { highWaterMark: 1 << 25 });
First time i got the string error. Second time it worked (same thing was logged in the console). @quartz kindle
Official documentation for the lavalink client, Erela.js
You can check the docs for the properties that have changed: https://discordjs.guide/additional-info/changes-in-v12.html
alr i got the deleted thing
, delete_after = 5
thats all it was
await ctx.send ('Message', delete_after = 5)
(node:5124) UnhandledPromiseRejectionWarning: TypeError: voice.permissionsFor is not a function
wha
menudocs lied to me
was that even a v11 function
cos im searching rn and its not
i cant find
what keyboard are you ok
when someone is missing permissions to execute a command as if i type command '+nuke' it will trigger but if someone sends '+nuke' it says absolutely nothing. how do i make it say sorry you are missing permissions or wtv
?
@hardy vector https://discord.js.org/#/docs/main/stable/class/GuildChannel?scrollTo=permissionsFor
https://discord.js.org/#/docs/main/v11/class/GuildChannel?scrollTo=permissionsFor
yeah, in both v12 and v11 it exists, which means your variable is probably the wrong type
If you are using the commands extension, you can use built-in permission checks
wdym commands
const permissions = voice.permissionsFor(client.user);``` this is wrong?
this is full error js (node:5124) UnhandledPromiseRejectionWarning: TypeError: voice.permissionsFor is not a function at Object.execute (/Users/sadashivappakenchannavar/Desktop/lavalink bot 2/commands/play.js:10:35) at Client.<anonymous> (/Users/sadashivappakenchannavar/Desktop/lavalink bot 2/bot.js:51:31) at Client.emit (events.js:311:20) at MessageCreateAction.handle (/Users/sadashivappakenchannavar/Desktop/lavalink bot 2/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14) at Object.module.exports [as MESSAGE_CREATE] (/Users/sadashivappakenchannavar/Desktop/lavalink bot 2/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32) at WebSocketManager.handlePacket (/Users/sadashivappakenchannavar/Desktop/lavalink bot 2/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31) at WebSocketShard.onPacket (/Users/sadashivappakenchannavar/Desktop/lavalink bot 2/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22) at WebSocketShard.onMessage (/Users/sadashivappakenchannavar/Desktop/lavalink bot 2/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10) at WebSocket.onMessage (/Users/sadashivappakenchannavar/Desktop/lavalink bot 2/node_modules/ws/lib/event-target.js:125:16) at WebSocket.emit (events.js:311:20) (node:5124) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:5124) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
play.js line 10 is this
const permissions = voice.permissionsFor(client.user);
yeah... but i already told you what's your issue
L
you gotta work for Google @zenith terrace
@hardy vector
your error has been found
in plain sight
lol
@earnest phoenix I should 
client.channels.cache.find(m => m.name === `ticket-${message.author.username}-${message.author.discriminator}`).send(`<@${message.author.id}>`, embed)
and this why doesn’t work..?
Any error?
and this why no error?
cannot ready proprety send
but the channel exists...
ah the name it’s good
then theres ur error
VinxVinxToday at 11:18 AM
cannot ready proprety send
help pls
@earnest phoenix send the whole log
@indigo cloud youre using a very outdated tutorial
alright
@earnest phoenix thats not very helpful lol
One Google search would say that you're using an outdated version
@earnest phoenix can you send the whole error?
ye
1|main | at Object.exports.run (/pala/commands/new.js:36:112)
1|main | at Client.<anonymous> (/pala/main.js:34:29)
1|main | at Client.emit (events.js:315:20)
1|main | at MessageCreateAction.handle (/pala/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
1|main | at Object.module.exports [as MESSAGE_CREATE] (/pala/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
1|main | at WebSocketManager.handlePacket (/pala/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
1|main | at WebSocketShard.onPacket (/pala/node_modules/discord.js/src/client/websocket/WebSocketShard.js:436:22)
1|main | at WebSocketShard.onMessage (/pala/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)1|main | at WebSocket.onMessage (/pala/node_modules/ws/lib/event-target.js:125:16)
1|main | at WebSocket.emit (events.js:315:20)```
Can you send the line where the error occurs?
new.js at 36:112
client.channels.cache.find(m => m.name === `ticket-${message.author.username}-${message.author.discriminator}`).send(`<@${message.author.id}>`, embed)
uh no is }
sorry, is }
but
wait
you're trying to send a message to the discriminator of the author
no, imao is not } xd is client.channels....
If I understand correctly
no i trying to send a message in the channel name
type :
@mention
[there is embed here]
spean french @earnest phoenix
?
speak
french
francais
osti
why?
ftp
pcq
a tu peur?
i don’t have permission for speak french in this channel
moi jparle francais
to speak french is go to the channel #memes-and-media
non
ta peur
no
@earnest phoenix
No
English only
non
francais
i just don’t have permissions
compris?
stop please
lol
ok
ignore me
go to #memes-and-media for french
either way, all languages which are not english should be kept in #memes-and-media
smh
Calls that racism lol
imao
no i trying to send a message in the channel name
type :
@mention [there is embed here]
discordjs v12.2
ah cool
ueah
just do channel.send("<@" + user.id + ">", { embed });
you can mention the user with just the user if u want
client.channels.cache.find(m => m.name === `ticket-${message.author.username}-${message.author.discriminator}`).send(`<@${message.author.id}>`, embed)
and this why doesn’t work..?
@earnest phoenix this is entirely the opposite of what i told you to do
ok
why cry
your user can change their username and discriminator anytime they want
messing up your ticketing system
uh yeah
ok
i put the channel id in my database and i get after the channel id?
yup
and i send the message so?
okk
correct
thx u

what is this
OR?
can u send me the symbol
it's just two |
||
next to each other
thx
@mossy vine show how you form the gateway url
and what you're logging that returns undefined
guys help
no thats not the problem
the problem is jsdoc
i had to rewrite my exports as
// define variable x in a cool way
module.exports.x = x```
Why is music coming off in windows? laggy..
and i cant do const { x } = require('./x.js') anymore
err ok
i have to do const { x } = require('./x.js').x
exports.x doesn't work?
Is there an article that I can fix
the problem is jsdoc shits itself if i dont export it like this
weird
hey
i export normally and jsdoc is fine with me
answer me too
not sure what's going on cyber
hello starman
honestly
Why is music coming off in windows? laggy..
@earnest phoenix
I am trying to limit my bot usage in general, for some reason the bot sends me the DM, but runs the command anyway, is there an oversight that I am making
if(cmd_f) {
if(cmd_f.help.genlocked == true && config[message.guild.id].genlocked > 0 && message.channel.name.startsWith("general")) {
message.channel.messages.fetch({ limit: 2 }).then(messages => {
messages.forEach(m => {
m2 = m.createdTimestamp;
})
console.log(m2, message.createdTimestamp, m2 + config[message.guild.id].genlocked)
if(m2 + config[message.guild.id].genlocked > message.createdTimestamp) {
message.author.send("This server has been gen-locked, you aren't able to use commands when chat has seen activity");
locked = true;
}
})
}
if(!locked) {cmd_f.run(client, message, args);}
}
thanks for your input tim
yw :^)
@fallow quiver async functions do not interrupt the code flow if you dont use the await keyword
you could just use export but I have a feeling that it'll bitch at you
the async part is carried on independently, everything outside the async function is independent and continues running normally
@earnest phoenix i would make it so that when the vote webhook is received, it will store the id of the user as well as a timestamp. then i would use a set interval (of maybe 30 minutes) to check if 12 hours has passed since the timestamp for each user in the database and remove the entry for that user if the 12 hours has passed. there are probably better ways to do this though. /shrug
@quartz kindle but the async isn't called until after the if statement, right?
no
you either await messages.fetch(), or you put the locked logic inside the .fetch() together with everything else
i just made error message for about every command 😭
how i can do this?
@earnest phoenix i would make it so that when the vote webhook is received, it will store the id of the user as well as a timestamp. then i would use a set interval (of maybe 30 minutes) to check if 12 hours has passed since the timestamp for each user in the database and remove the entry for that user if the 12 hours has passed. there are probably better ways to do this though. /shrug
is djsv11's ```js
Error: Client network socket disconnected before secure TLS connection was established
the same as djsv12's
```js
AbortError: The user aborted a request.
const matches = mention.match(/^<@!?(\d+)>$/);
if (!matches) return null;
return client.users.cache.get(matches[1]);
there's my meme regex
to get a user from a mention
but i want to modify the function to return an array of all mentions it finds
yeah youre only getting the very first match
if (I ask for banana) return banana
but if i pass it an entire string
matches.filter(it => matches.indexOf(it) % 3 == 1).map(it => client.users.cache.get(it))
will it return an array of them all
Yes
gets every 2nd argument
(/regex/g).match(string) returns an array of matches
<@id> <@id>
oh ok
i think thats right, ill need an array of what the matcher outputs
im glad javacord has its own function to get mentioned users
const matches = content.match(/^<@!?(\d+)>$/g);
if (!matches) return null;
return matches.filter((i) => matches.indexOf(i) % 3 === 1).map((i) => client.users.cache.get(i));
so literally that should work
and then i get an array of users
they should be in order right
like if i send @thattonybo @user2 @user3 itll return ['thattonybo', 'user1', 'user2']
(obv being full users though)
Why don't you use message.mentions.members instead of trying to regex it?
also remove the ^ from the regex
thats the beginning of a string
@glad charm hes making his own lib iirc
Oh.
yeah good luck finding mentions.members on mine
also, they're out of order even on other libs
hm
that returns a []
Quick question I had to make 2 lines for my ggping so it’ll say “my ping is”
“Numbersms”
I can’t figure out how to get it on one line without erroring
Hey, I asked here yesterday how to stop a file from executing if in another file, that gets executed from the first file, an error occurs. Is that possible in a nice way? (I can link to an old message if you want to answer)
it wont work anyways
anyone here know anything about discord.py?
@sick cloud ur regex should be /<@(!)?(\d+)>/g
^ $ indicate the start/end of the string...
i got told to remove it
it returns the match if it matches one
Also you should require the numbers to be the length of mentions to be safe so it doesn't find @zinc aurora
it doesn't remove the <@ >
because its what it matched
Yeah
why learn to starboard when you can use a starboard bot on top.gg wink
to get the ids just replace the <@ and >
or substring
don't forget the !
anyone knows what's a nice way to make some utility commands so I can use them multiple times easily? I thought about client.utility as a collection. Are there nicer ways?
Just make a utility class of a lot of static methods.
Or are you talking about commands that are utility commands?
its time for another episode of bad code by TheNoob27:
let mentions = []
string.replace(/<@(!)?(1|\d+{16,20})>/g, (s, _, id) => {
mentions.push(id)
return s
})

or do you have a quick simple example?
Nah but google does. What language are you using
okay. JS



