#development
1 messages · Page 1327 of 1
children[0] will likely bring you the same shape you had before
where you want to acess meme.data.children
@solemn latch idk what that means
those [Object] in [children] are where the memes are at
hot means hot page, so you'll get a lot of results
just get the first one of the children, that'll be ONE meme
ok then what do i do
wdym?
meme.data.children[index]
i want to access my mailbox, so i walk to my mailbox and read whats in it. if i find a letter with a bill in them, i take it to my desk and write a check and put it in a new letter and send it.
if you want to access children.data.thumbnail
you need to use that in the location you want it.
assign that to a variable and use it or use that directly multiple times
you should really look into how to use objects
here, you need to know how to play with arrays first
and arrays
so i think my bot has some infinite loop somewhere; i run pm2 list every once in a while and i see cpu usage to 100%, and the bot is entirely unresponsive
how am i supposed to debug this?
@opal plank yo btw, my bot got added to 43 servers, and till today he was not even 24/7. i ran him on my pc, node .
for (thisPrefix of prefixes) {
// Magic
}
thisPrefix is not defined
WTF?
whats prefixes
ill try
I am on mobile and i have made a bot and i cant host 24/7 help lol
That fixed it
use a VPS
What dat
Ahh cool ill try thx im new to the bot thing
@tardy hornet eeey nice, just remember that your production bot shouldnt be going offline
Okay--I'm redesigning my bot's command handler (Discord.js v12 and Node v14), and I want to define my metadata using multiple functions. Here's my code.
module.exports = class BaseCommand {
async meta() {
async function core({name, level}) {
this.name = name;
this.level = level;
}
async function settings({aliases, testing}) {
this.aliases = aliases;
this.testing = testing;
}
async function help({description, usage, notes}) {
this.description = description;
this.usage = usage;
this.notes = notes;
}
}
}
I would then proceed to use it like:
meta() {
core({ name: "a", level: 27 });
settings({aliases: ["1", "2"], testing: true});
help({description: "games", usage: "a", notes: null});
}
Would the following work, or would it produce errors? (I'm asking this as I cannot reproduce it, since I'm not able to recreate my bot's environment and I don't want to push this change to the main branch of my bot.)
Why is message.mentions.users.first(); returning undefined?
Yes, I am mentioning someone
Chances are that the message doesn't have a user ping in it.
It does
Try members.first()
@green vale What I'm doing is I have a class called Command with a construcer like for example:
this.run, this.name, etc
Then in the command file u can do class <command> extends Command and have ur contructor and super and run method in there
members doesn't work either
Yeah, that's currently how my bot is structured. I don't really like super() as it's a bit cluttery and I'd like to separate each aspect of the command metadata into different functions.
mentions: MessageMentions {
everyone: false,
users: Collection [Map] {},
roles: Collection [Map] {},
_channels: null,
crosspostedChannels: Collection [Map] {}
},
That's odd.
Collection [Map] {}
honoured, I don't really know a different way to do it, you could have objects in the constructor but then I'd prefer to use a super imo
Fair--what I said above is what I want to do, I just wanna know if that would be feasible
@green vale honestly, the second code block doesn't sit right with me, but I might just be too new to understand why you're using meta() like that.
its a method
this.meta() would return all the functions inside of there
Well yeah, but like method () {function()}?
Yes you'd do this.meta().core({name:"a", level: 27}) to "configure" it
oh that's cool
Classes are really flexible and that's why I enjoy using them
yea
anyways, I'm happy to show you my interface for my commands so you can sort of see how I did it, slightly less oop-y but it gets the job done rlly well
imo if u know js basics, OOP and are feeling ready I'd learn to use classes
I'd love to see it, sure!
any ideas how I would resolve my issue?
how do i get what shard my bot is on? discord py?
how do i get what shard my bot is on? discord py?
@drifting wedge if u sharded ur bot isn't it supposed to be on all ur shards?
Chicken, I've never actually experienced that before, maybe you're using the wrong message object?
?
no, the content seems right
like basicaslly i want a command to find what shard the bot is on
so like if i have 10 shards
oh like that
how can i find which one bot is in?
wich shard that instance is on?
yes
I've never sharded before but can't u do client.shard
the py lib docswould tell you
oh yeh he used py
sooo anyone knows how I could fix my issue
is there a way to get the maximum amount of posts in a subreddit with the reddit API?
hello o have a probleme
so I can get the maximum amount of posts in a subreddit instead of the last 100 or 200 or something
that's been happening for the last week
the api probably has a max number
its very common to have 100 as a max
@earnest phoenix server side error
my api only has 50 max from one request
oww
wait for them 2 fix
I do 100 but if I go over 300 it says list index not found
anyone try faunadb?
else if (command === 'purge') {
if(!message.member.hasPermission("MANAGE_MESSAGES")) {
return message.reply("You cant delete messages.....").then(m => m.delete(5000));
}
if (isNaN(args[0]) || parseInt(args[0]) <= 0) {
return message.reply("Thats not a number you thick shit").then(m => m.delete(5000));
}
if (!message.guild.me.hasPermission("MANAGE_MESSAGES")){
return message.reply("sorry i cant delete messages").then(m => m.delete(5000));
}
let deleteAmount;
if(parseInt(args[0]) > 100) {
deleteAmount = 100;
} else{
deleteAmount = parseInt(args[0]);
}
message.channel.bulkDelete(deleteAmount, true)
.then(deleted => message.channel.send(`i deleted \`${deleted.size}\` messages.`))
.catch(err => message.reply(`Something went wrong... ${err}`));
}```
(node:11032) UnhandledPromiseRejectionWarning: TypeError [INVALID_TYPE]: Supplied options is not an object.
at Message.delete (c:\Users\alexg\Downloads\LightBot\node_modules\discord.js\src\structures\Message.js:537:44)
at c:\Users\alexg\Downloads\LightBot\index.js:120:73
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
<node_internals>/internal/process/warning.js
(node:11032) 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_internals>/internal/process/warning.js
(node:11032) [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.
<node_internals>/internal/process/warning.js
oh i see the error
"Thats not a number you thick shit"
i made a music bot and it turns on but will not connect to the Voice Channel
like it wont do anything for the !play cmd
is it erroring
no there is no error its just wont work
switch (args[0]) {
case 'play':
function play(connection, message){
var server = servers[message.guild.id];
server.dispatcher = connection.playStream(ytdl(server.queue[0], {filter: "audioonly"}));
server.queue.shift();
server.dispatcher.on("end", function(){
if(server.queue[0]){
play(connection, message);
}else {
connection.disconnect();
}
});
}
thats the code for the !play
can anyone help me
@polar girder you have a function play, but you never call that function
ok
then what i do?
as in you need to do:
function play() {
console.log('currently running code in play function');
}
play(); // <-- call the function```
Why is message.mentions.users.first(); returning undefined?
Yes, I am mentioning someone
It shouldn’t?
is members also undefined?
^
my friend help me so i dunno
or, are you awaiting the message(if you sent it)
are u talkin to me?
yeah i was @tulip ledge
oh i thought u were talkin to me lol
yes it also returns undefined
could it be cuz I'm doing this message = new Message(this, JSON.parse(JSON.stringify(message)), message.channel);?
there ya go
im confused, who are you mentioning in the new Message()
why do you need the message constructor
It's a class extended on, the discord message
oh psh
I'm not mentioning anyone in the new Message
It's just that message is an "extended" version of the discord message
@sonic lodge my problem is the bot wont respond to the command i have it if like ur not in a vc its gives u a error but it doesnt do anything
like i said, call the function
try running the command again with sudo at the beginning
ok
hey pool so i do this right? play(); @sonic lodge
What are you using? Ubuntu?
im so confused
Call the function by doing play()
You made a function should prob know how to call it
Hi guys I want to make a command that changes the current guild's command prefix
I'm already using a database (mongodb)
And I was wondering if you guys can help me thx (discord.js)
I already did
@blissful coral my friend is helpin me so im lost
Then what do you need
but I want to know how to set it the the prefix
Good evening! Is it possible to have an on_message() function but using the bot.commands lib ?
(I want my bot to add random reactions on random messages but still having its normal comportment with commands and all)
@polar girder if he doesn’t know what he is doing then he doesn’t need to be helping
he isnt here so i tried doin it myself @blissful coral
@balmy anchor do const prefix = your db checking prefix per guild
ok thx ill try
Good evening! Is it possible to have an
on_message()function but using the bot.commands lib ?(I want my bot to add random reactions on random messages but still having its normal comportment with commands and all)
@dapper compass I'm using Discord.py and I heard that it was possible to divide our code with an on_message event at top, and then the bot.commands part..
I think I found what I'm searching for
ummmm @blissful coral is there a way of not having to deal with function?????
well i mean im a dumb as all get out with JavaScript
functions are also generally the first few things you should learn and are extremely basic programming
You wanna look it up then
i did
Function is one of the most basic things in JavaScript
im doing it rn
Should I do it like this?
@blissful coral im lookin rn
Should I do it like this?
@balmy anchor @blissful coral
?
(Sorry for the mention)
😦 sorry
didnt knew sry dude
What people do to make multiguild xp levels, they make a table for every single guild the bot joins?
mysql
i did already lol
whats the issue?
i want to make a per-server prefix
make a table(mongo calls it a document or something?) with the guild_id and prefix
i already did but to define the prefix i'll just put there my default bot prefix?
you should only make a row in the database if they have changed the prefix from default
if they do have one, then get it
like !settings setprefix <prefix>
and then it'll update?
ok i think i got it ill try 1 sec
make sure to rather than checking constantly, you map your prefixes on startup
^
so you save up on database calls

I actually had a problem with that, I ended up making so few database calls that mysql would dc me after 8 hours
did you install pm2?
yes
is node installed
can you try running your bot with just node just incase?
ok
if it works, then idk :p
Alright my problem i fixed early now it responds to the cmd but it crashes after i SAY "!play" and gives and error saying "Type Error: Cannot Read Property 'connection' of undefined"
Alright my problem i fixed early now it responds to the cmd but it crashes after i SAY "!play" and gives and error saying "Type Error: Cannot Read Property 'connection' of undefined"
@polar girder no i meant no "iplay" its "!play 'songname' "
ok i think i did that lol @solemn latch
?bins
you mean the 275e?
are you using a char that the font doesnt have?
whats a char?
make sure whatever your doing .connection on is defined
@solemn latch wut u mean
character
if you do
hi.connection
and hi doesnt exist, you cannot do .connection
so you must check if hi exists first
Problem solved you are a genius
nah, just lucky guess
switch (args[0]) {
case 'play':
function play(connection, message) {
var server = servers[message.guild.id];
server.dispatcher = connection.playStream(ytdl(server.queue[0], {filter: "audioonly"}));
server.queue.shift();
server.dispatcher.on("end", function(){
if(server.queue[0]){
play(connection, message);
}else {
connection.disconnect();
}
});
}
aight ty
thats what i think my problem is but i dunno
that bit of code @solemn latch its just i dunno what to do 😦
ngl, i dont even see where you are reading .connection in that code
i fugired it out its cause its outdated lol
🤷♂️
switch (args[0]) {
case 'play':function play(connection, message) { var server = servers[message.guild.id]; server.dispatcher = connection.playStream(ytdl(server.queue[0], {filter: "audioonly"})); server.queue.shift(); server.dispatcher.on("end", function(){ if(server.queue[0]){ play(connection, message); }else { connection.disconnect(); } }); }
@polar girder is the play function even being called
we mentioned that earlier he made it sound like he was going to google it
why node wont install
on my vps
i did sudo apt-get install nodejs
and it tells me ask ur admin
ask your vps provider then?
its google cloud
good thing google cloud has support
yeah
const { Client, Message } = require('discord.js')
const ytdl = require('ytdl-core')
const PREFIX = '$'
const client = new Client({ disableEveryone: true })
client.on('ready' , () => console.log('Active'))
if(Message.author.bot) return
if(!Message.content.startsWith(PREFIX.length)) return
const args = message.content.substring(PREFIX.length).split(" ")
if(message.content.startsWith(`${PREFIX}play`)) {
const voiceChannel = message.member.voice.channel
if(!voiceChannel) return message.channel.send("You Need To Be In A Voice Channel")
const permissions = voiceChannel.permissionsFor(message.client.user)
if(!permissions.has('CONNECT')) return message.channel.send("I don't have permissions to connect to this channel")
if(!permissions.has('SPEAK')) return message.channel("I Don't Have permission to speak in this channel")
try {
var connection = await voiceChannel.join()
} catch (error) {
console.log(`There Was An Error Connecting To The Voice Channel: #{error`)
return message.channel.send(`There Was An Error Connecting To The Voice Channel: #{error`)
}
const dispatcher = connection.play(ytdl(args[1]))
.on('finsish', () => {
voiceChannel.leave()
})
.on('error', error => {
console.log(error)
})
dispatcher.setVolumeLogarithmic(5 / 5)
} else if (message.content.startsWith(`${PREFIX}stop`)) {
if(!message.member.voice.channel) return message.channel.send("You Need To Be In A Voice Channel To Stop The Music")
message.member.voice.channel.leave()
return undefined
}
Client.login(process.env.TOKEN)
whats wrong with it?
lots of things
just saying "whats wrong with it" isnt really that useful for people
lmao
you can only use await in async functions
thats not even the first of your problems
next you will likely get "cannot read property bot of undefined"
ok
the entire structure of your code is wrong
so do i just remove await?
you need to create a message event listener
ok this is complicated
await is needed if you need the promise resolved
this is going to be "fun"
you're working on the wrong thing, you're trying to use Message, but Message is the class itself, not the instance
you dont use Message directly like that
you need to create a message event listener
the same way you have a ready event listener
so like what do i need to change or add?
like this
client.on("message", message => {
// code here
})
that is the correct message to work on
not the Message you're getting from discord.js
so the first line i replace with this?
does anyone know if i can use shadowColor to text in canvas?
or is it just to objects?
no, you need to put all the code you have after client.on("ready") inside a client.on("message")
except client.login()
check the guide for discord.js
and start from there
@stark abyss there is shadowBlur
shadowBlur got it thanks tim
closest thing you can get
ok ok
client.on('ready' , () => console.log('Active'))
client.on('message', async message => {
if(Message.author.bot) return
if(!Message.content.startsWith(PREFIX.length)) return
const args = message.content.substring(PREFIX.length).split(" ")
its that right?
@quartz kindle
Close the ready event if you haven’t already
And you capitalized Message on message.author.bot
Everywhere is capitalized
Needs to be lower case
now i got an error of emitter.on is not a function damn my code is full of problems
Message.content.startsWith(PREFIX.length)
Is that right...?
Not Message.content.startsWith(PREFIX) ?
i fixed it yeah i just noticed it to
anyone else hate nodejs has no multithreading support 
Yep
so easy to block the main thread
Yeah
i think there was someone that added threading support to nodejs
Ooooo
dont know how well that works
Prob not well
or if its just a boring worker process
i am little confused on how createLinearGradient works
im not good with server side of things why is my is my thing doing this
Error: Cannot find module '/home/container/index.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
where as my other server here at my home is not doing this
Would anyone make me a music bot for free? Don't care if the code is copied or whatever. Like from a yt video or something. Just needs to work. Saying this cause I want the bot to be 'custom'. So its our bot and not like groovy or rhythm. Code could literaly be copied from them, but don't know how to do that kind of stuff so thats why im asking. Like no nothing about bots and making them. Thanks, sorry bout long msg if u made it this far. Dm me if u are willing
i swear to JESUS CHRIST i have an error saying my token is undefined
f
bismillah
If someone answers animeboi's question can you also dm me with the source code
Would anyone make me a music bot for free? Don't care if the code is copied or whatever. Like from a yt video or something. Just needs to work. Saying this cause I want the bot to be 'custom'. So its our bot and not like groovy or rhythm. Code could literaly be copied from them, but don't know how to do that kind of stuff so thats why im asking. Like no nothing about bots and making them. Thanks, sorry bout long msg if u made it this far. Dm me if u are willing
@sand shore i mean im making one and i dont understand code as well but i mean if u want a crappy one here u go!
ask somewhere else
i mean i can its mine wont login cause coding is like that
const { Client, Message } = require('discord.js')
const ytdl = require('ytdl-core')
const PREFIX = '$'
const token ='';
const client = new Client({ disableEveryone: true })
client.on('ready' , () => console.log('Active'))
client.on('message', async message => {
if(message.author.bot) return
if(!message.content.startsWith(PREFIX)) return
const args = message.content.substring(PREFIX.length).split(" ")
if(message.content.startsWith(`${PREFIX}play`)) {
const voiceChannel = message.member.voice.channel
if(!voiceChannel) return message.channel.send("You Need To Be In A Voice Channel")
const permissions = voiceChannel.permissionsFor(message.client.user)
if(!permissions.has('CONNECT')) return message.channel.send("I don't have permissions to connect to this channel")
if(!permissions.has('SPEAK')) return message.channel("I Don't Have permission to speak in this channel")
try {
var connection = await voiceChannel.join()
} catch (error) {
console.log(`There Was An Error Connecting To The Voice Channel: #{error`)
return message.channel.send(`There Was An Error Connecting To The Voice Channel: #{error`)
}
const dispatcher = connection.play(ytdl(args[1]))
.on('finsish', () => {
voiceChannel.leave()
})
.on('error', error => {
console.log(error)
})
dispatcher.setVolumeLogarithmic(5 / 5)
} else if (message.content.startsWith(`${PREFIX}stop`)) {
if(!message.member.voice.channel) return message.channel.send("You Need To Be In A Voice Channel To Stop The Music")
message.member.voice.channel.leave()
return undefined
}
})
client.login(token);
thats my code
thanks wow
the problem im having is it wont login in why
ima hust use my pc as a server
for discord.py: Can someone tell me how to properly use get_user_vote(user_id: int)
ayo @solemn latch my bot is running and connected to the VC but there is no sound how do i fix?
🤷♂️
Woo this is the full code fromt he documentation
async def get_user_vote(self, user_id: int):
"""This function is a coroutine.
Gets information about the user's upvote for your bot on top.gg.
Parameters
==========
user_id: int
ID of the user you wish to lookup.
Returns
=======
vote status: bool
Info about the user's upvote.
"""
await self._ensure_bot_user()
data = await self.http.get_user_vote(self.bot_id, user_id)
return bool(data['voted'])
would i put it in a commands.Cog.listener()
IT WORKS LETS GOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
well if it accespts it like that, try get_user_vote(self, user_id=ID)
Does anyone knows why does it sends a message 500x times almost lol?
Because you send it and then it reacts on that message
Not from there
XD
Where?
wdym?
wdym?
@balmy anchor You react on every message sent by the bot, but the message you send then is also a message what triggers that event over and over again
client.on('message', message => {
if(message.content === 'lock') {
message.channel.updateOverwrite(message.channel.id, { SEND_MESSAGES: false, VIEW_CHANNEL: true});
message.reply('Locked')
}
}}
who can tell me how to change this to lock all the channels
@lost stone
?
and spoonfeeding is sorry about the q?
@solemn latch he just helped me
i hate a person who says spoonfeed , he didnt spoonfood me he forkfeeded me
im using it for my bot and i dont care if he uses this
yikes
@balmy anchor thanks❤️
for what?
still against rules
its about the rules dude, just follow them
so if i dm him this its still against the rules idk?
its not in the server, but your avoiding the rules which are inplace to help
spoonfeeding is bad for those learning
feeding someone pre-made code doesnt help in any way, as they are likely not gonna learn from it and simply copy paste it, whcih will in turn make them just come back for more when they are stuck in the same thing
yeah but I just wanted to help tho u guys know this lol
i know your intentions werent bad
just please give them docs or a rough explanation of what they need
if they still struggling, provide some more help ontop
Nothing I can say about it
Giving the source code is not necessarily a problem, but the issue is it teaches newbies to write in only one style rather than seeing how to implement it themselves.
what the hell
idk
talk to them
Woo and Not Erwin I can understand why u guys are saying that but it doesnt means I cant help him u know
😛
show the number of this rules @solemn latch
Xignotic#0001
you two might be taking this too personally, i reminded erwin about spoonfeeding today too 🤷♂️
ive been asked to not do it multiple times
how do premium bots work? like to give users access to them?
i dont have any premium features added yet, but i do have it setup
how does it work?
i just have patreon bot that gives a role and the bot checks for that role
How can I have my bot's github repo be public and keep the token private/hidden
on payment => add id to whitelist => when command is run, check if the user who issed the command is part of the whitelist
what is the best way for payment?
setup for $3 > $5 > $10 roles
best? idk
as many as possible
paypal, stripes and patreon are the most used afaik
i use venmo for some stuff. sites that use venmo im 10x more likly to buy from
is patreon the best for subscriptions?
patreon has done some really crappy things to people
@solemn latch ?
How can I have my bot's github repo be public and keep the token private/hidden
@thin turret store the token in a file that you don't push to GitHub, such as a.envfile.
subscriptions r the best, cuz its like recurring
It can be any file as long as your credentials are stored there.
Then use that file to pull your credentials in your source code.
so just like token.env and require it to index as any other file?
omg i finnaly got my bot to work
ay
gg
gj
Elite what language are you using
djs
stupid thing need its own folder
Epic thanks
Keep in mind as long as you keep the credentials stored in some file you don't push to GitHub, it's fine. You could even have a .json file you don't push then require it.
exports.run = (client, message, args) => {
const serverQueue = client.queue.get(message.guild.id);
if (!message.member.voiceChannel) return message.channel.send('You are not in a voice channel!');
if(!serverQueue) return message.channel.send('Not playing anything right now');
serverQueue.loop = !serverQueue.loop;
return message.channel.send(I have now ${serverQueue.loop ? Enabled:Disabled} loop.)
};
can someone please tell me why the only response i get is 'You are not in a voice channel' even if i am ;-;
because .voiceChannel is probably resolving to undefined because the property doesn't exist.
You're probably looking for .voice.channel, assuming you're using Discord.js v12
How do I check if a bot is connected to a voice channel?
depends on the language and library
that's weird, last time i actually did so, voice.channel according to VSC doesn't exist
the question just above yours is the same practically @haughty bough
.voice.channel
What version of Discord.js are you using
my bot seems to love crashing when it doesnt have perms to join a voice channel
you need to check perms for pretty much every request that does something
yeah i made the invite requie the perms
That's not enough
you also need to check in code
discord.js v12
What version of Discord.js are you using
@sudden geyser
ok will do
nvm i see why now
yup
constants.jpeg be tripping
https://hastebin.com/tavedidoci.typescript
(node:18665) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body DICT_TYPE_CONVERT: Only dictionaries may be used in a DictType at RequestHandler.execute (/rbd/pnpm-volume/6da398da-dcf5-499a-9395-ab3ac6de59c5/node_modules/.registry.npmjs.org/discord.js/12.3.1/node_modules/discord.js/src/rest/RequestHandler.js:170:25) at processTicksAndRejections (internal/process/task_queues.js:88:5) (node:18665) 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: 1) (node:18665) [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
it actually works! i am doodoo brain
Plebus the stacktrace doesn't tell us much. Are you able to debug where it's coming from which may have caused the error.
thanks
all that shows that error, and with the kick cmd, all i changed is await banMember.ban(banReason); to await kickMember.kick(banReason); and it works
the question just above yours is the same practically @haughty bough
@solemn latch I'm trying to check if the bot I'm working on is on a voice channel, if it is, it will come out of it. I tried to use message.member.voice.channel, but it tells me sorry if the member who sent the message is on a channel (I think it must be ".member", right?). ps: I'm a beginner 😦
any Member class has .voice
message.member.voice.channel would be the person who sent the message.
if you wanted for example the bots member object, you could use message.guild.me
.me being the bot itself.
ohhh i fixed because i forgot to put correct parameters :/
if you wanted for example the bots member object, you could use
message.guild.me
.me being the bot itself.
@solemn latch This solved my problem! Thank you very much
np
hi
im sending an array to my frontend and its getting transferred into a number for some reason
so im sending: ['123', '123'] and its in the frontend its 123,123
any idea how i can turn it back into an array? i've tried google but the commas are screwing everything up
array.toString() does that
1 sec
did you send it as text?
do I have to make a mysql connection in every single command that its gonna use the db or can I make the mysql connection in the main and use it somehow in other command file
both work fine
that's probably the problem
so it dsnt matter if I make a connection in every command?
you want to display it as an object instead
yes, just make sure you're closing the connection after done
the way im doing it is like res.render('e', { array: ['123', '123']})
in the frontend?
yes
this is what i done js const roles = JSON.stringify(<%- modRoles %>); document.getElementById('modroles-to-show').innerHTML += roles
isnt stringify turning the array into a string
yes
which drops the []
nope
o
that's .toString()
1 sec
try logging modRoles
it logs the mod roles of the server, im using a different pc on discord and different to code
my other pc is too slow to handle discord now lol
so it logs the array just fine
server side yes, not client side
what does it look like on the frontend?
like id,id,id 123456789,123456789,123456789
can you try console.log(<%- modRoles %>)
looks like it's a string yea
you can just JSON.stringify() it on the back end actually
way easier
aa very nice
alssosooon one last thing
im doing a similar thing to the way mee6 has the mod role and u click on it and it gets removed as a role, how do i go about doing this?
i just realised im talking about how discord does it too
discord use their rest api i guess
as for bots, i think it handles it on the backend
can't you do an API request on the backend from the input from the frontend?
or maybe a websocket server between the dashboard and your bot with some kind of authentication. the bot handles the request on the backend
yeah, but like the way it like does overflow
uh idk how to explain
nvm, im confusing myself here somehow. thanks for the help tho
any way to get accurate mem use/mem cap info with node?
User - Front end - Back end - 3rd party APIs
any way to get accurate mem use/mem cap info with node?
@tame kestrel for the running process or system?
i c
thank you
Np safe
does anyone know how i can do embed.set_image with https://top.gg/api/widget/servers/742073065034481756.png?noavatar=true
python
just pass in that string as the URL?
@carmine summit try removing await and console.log it
just pass in that string as the URL?
@faint prism didnt work
there was a blank embed
no fix...
have you tried (url="thelink")
yea
wb set_thumbnail(url="url")?
hmm lemme try that
@carmine summit try removing await and console.log it
@blissful coral no fix
i got another blank embed @faint prism
ive restarted it many times
is cache undefined or something... try logging it
console.log(message.member.roles.cache)
@stable snow could you possibly fetch the url, and turn the response into a buffer?
returned the roles
hmm ok
like this?
also
@commands.command()
async def servers(self, ctx):
servers = 'https://top.gg/api/widget/servers/742073065034481756.png?noavatar=true'
servers = requests.get(servers)
embed=discord.Embed()
embed.set_image(url=servers.content)
print(servers)
embed.set_thumbnail(url=servers)
await ctx.send(embed=embed)```
@sonic lodge
if i ?eval it
works fine
show code
fetch, as in use the fetch api
whats that
k
it said not a well formed url
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embed.image.url: Must be 2048 or fewer in length. Not a well formed URL.
In embed.thumbnail.url: Not a well formed URL.```
@sonic lodge
well when you fetch the image, the response isn't a url, but instead a buffer
how do i make it a buffer
it is a buffer, you just need to attach it to the message as a file
oh ok
this seems like it would help with that: https://discordpy.readthedocs.io/en/latest/api.html#discord.File
😐
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: expected str, bytes or os.PathLike object, not Response
@commands.command()
async def servers(self, ctx):
servers = 'https://top.gg/api/widget/servers/742073065034481756.png?noavatar=true'
servers = requests.get(servers)
file = discord.File(servers, 'servers.png')
embed=discord.Embed()
embed.set_image(url='attachment://servers.png')
print(servers)
await ctx.send(file=file, embed=embed)```
servers.content
OH yeHA
Ignoring exception in on_command_error
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/runner/VxRP/cogs/botlists/topgg.py", line 76, in servers
file = discord.File(servers.content, 'servers.png')
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/file.py", line 73, in __init__
self.fp = open(fp, 'rb')
ValueError: embedded null byte
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 333, in _run_event
await coro(*args, **kwargs)
File "main.py", line 198, in on_command_error
raise error
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 903, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 859, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ValueError: embedded null byte```
yikes
i feel like i should stop before my smol python knowledge breaks your computer bot
lmao i use rEpL
that is nested inside 3 funtions?
@opal plank recursion
im gonna go PATCH method rather than proper stuff tbh

await =>
function => join channel
inside join channel => if fail , retry
inside retry function => if fail, retry again & attempts ++ / if attempts > maxAttempts return ??
fml
i works already though, but the display is bugging me a ton cuz its not properly waiting for the responses. The shards are working just fine
hm @stable snow, maybe discord.File(BytesIO(servers.content), 'file.png')?
if it doesn't work ima stop there lol
I don't understand why that got messed up ;-;
@opal plank .map() is not a function let rolesArray = message.member.roles.cache.map(r => r.id)
hm @stable snow, maybe
discord.File(BytesIO(servers.content), 'file.png')?
if it doesn't work ima stop there lol
@sonic lodge ok
omg it worked
ty @sonic lodge
how to detect a blank line
is it just ' '
test frame 2 Bokura ga Ita
"I want to go back and change the past. If I could - I would, if that would stop you from crying."
~Motoharu Yano
as you can see its messing up
it works fine if if i don't leave the rest of line blank
each of those errors you can click and it will take you to where the typescript compiler didn't like whatever you're doing
@foggy cove
One message removed from a suspended account.
damn i wanna cry
One message removed from a suspended account.
One message removed from a suspended account.
you dont have to retype everything
welcome to typescript, where, y'know, you TYPE
lmao
so you type your scripts in typescript, very nice
erwin my guy do you think u can help me 
with?
if the lagg does kill my pc first for emulating massive traffic i might be able to lmao

first thing
var
stop that shit
you dont need scoped variables to be declared globally
okay I will use let or const
my bot runs on a server and god i cant count how many times ive crashed it
is that canvas?
yes
my brain has been beaten to a pulp debugging my sharding rn
ok
well do you know a way i can tell if it's blank? like it's console logging a blank line i if i can somehow detect that and do something i can fix it
define blank
you mean empty string
yeah that
var words = text.split(' ');
I am doing that and this also picks up empty line i believe is there a way to prevent that?
@opal plank are you using .concat on it
because concat is known for being very slow
exbrain pliz. _a has a value, then i concat an array with _a, now the array is empty? WOT?

hewo, i have question, i think it's a stupid question but i don't understand. i want to send random image from my file, this is my code
module.exports = {
name: "chino",
description: "show random chino pic",
async execute( message ) {
var files = fs.readdirSync("./Picture/Chino")
let chosenFile = files[Math.floor(Math.random() * files.length)]
message.channel.send(chosenFile);
}
}
and it just send the picture's name
@opal plank .concat returns a new array
lul
oh that explains it
Theres ya answer
fml
yeah also I recommend using the spread operator to merge two or more arrays instead
concat is very slow compared to it
@pearl trail Because that isn't how you do a file attachment

oh, so how ;-;
var words = text.split(' ');
I am doing that and this also picks up empty line i believe is there a way to prevent that?
Examples
// Send a basic message
channel.send('hello!')
.then(message => console.log(`Sent message: ${message.content}`))
.catch(console.error);
// Send a remote file
channel.send({
files: ['https://cdn.discordapp.com/icons/222078108977594368/6e1019b3179d71046e463a75915e7244.png?size=2048']
})
.then(console.log)
.catch(console.error);
// Send a local file
channel.send({
files: [{
attachment: 'entire/path/to/file.jpg',
name: 'file.jpg'
}]
})
.then(console.log)
.catch(console.error);
// Send an embed with a local image inside
channel.send('This is an embed', {
embed: {
thumbnail: {
url: 'attachment://file.jpg'
}
},
files: [{
attachment: 'entire/path/to/file.jpg',
name: 'file.jpg'
}]
})
.then(console.log)
.catch(console.error);
@pearl trail
.readdirSync returns an array of the names of the files and directories in an array. Of course it only returns the name of the file. You need to use the name of that to get the file's local path.
owh, but i have more than 1 image,
the examples above are also good
i want to pick random
So pick the random image, and use the name of that image in the file path
yes, so use what you have so far to get the name of the string, and plug the name into the code above to send the file
the more i code the dumber i get, its insane
lemme try
relatable
are you writing code at 2 in the morning
its midnight rn, and i got no alcohol, so that might be some of the causes
Erwin finishing off his free trial of brain cells 
don't worry, some more will respawn tomorrow
this should work now
actually
i might stream this
for those who want to see tears

why i always get Error: ENOENT: no such file or directory, stat '/Users/arya/Documents/Bot/Music Bot/Neko-Bot-master/Users/arya/Documents/Bot/Music Bot/Neko-Bot-master/Picture/Chino'
that was it
nice
they still going over what they should be
but the spawner is working fine
i just need to put the websocket to sleep until the whole thing finishes
the only thing i can do is wish some luck. 
sankyu
this code is legit a nightmare
im not even kidding
idk if you caught the actual code in the background

time to push this to the main branch and watch as shit legit dies
time to test on prod again

no nononono
finally, thank you spooky extreme
This is a bit of a general question but does anyone know good ways to store data. What I mean by that is like when you mute someone (example) and maybe want to store that mute in a database, so that it can be fetched even after restarting your code. I know that you would use a file system but is there any efficient way to do it, and if so, pls dm me or ping me with tips
@earnest phoenix database
its called a database
but what kind
any
hm so i can just look one up?
up to you, right tool for the right job
alright, i'll look into it
i'm new to bots and this was the biggest obstacle for me
people get spooked by databases, but the basics can be learned in an afternoon
if you actually research the topic
in which platform?
Discord
i think 70 something
@solemn latch just so ik, when ur using a standard database, is it easy to index and modify? or would u have to rewrite files to alter them
it would've been on many more if i didnt have the auto-leave guilds function
inactive guilds / bot hells it just leaves
Why?
cuz its a streaming bot, why would i want to be in any server thats not a streamer/active server?
cuz its a streaming bot, why would i want to be in any server thats not a streamer/active server?
@opal plank true
U make any money?
not currently, no
indexes are super simple, modifying is all databases do(lookups are easy too)
Also how does it work? Like night bot?
you are not directly editing files in most databases
alr tysm @solemn latch
Same idea?
you are comparing apples to oranges tbh
well, both are chat bots, though they work in different manners

twitch is a pain and a half to deal with though
discord is the easy mode of bots, not gonna lie
tons of bots lol
My bots at 91 servers, so it’s doing ok I’d say
isn't twitch just irc?
IRC?
I guess just is underplaying it but
yeah
Also wuts iirc?
though not JUST IRC
yeah haha
And iirc? An acronym?
now everyone just be like : ey, i got a lib that does what i want
Oooh ty
IRC is not iirc btw
Ik
we talking about IRC
discord js makes it so ez 
not only d.js
anything you need you have readily available
try finding a js lib for youtube

oh well that's just like, the javascript experience
not for other chats
discord is the easy mode of bots
people dont ever have to deal with connections or handling anything tbh
its like: hey, heres my token, take care of everything for me
-twitch does the connection for you, but nothing else
-youtube throws you at the lions
-discord provides everything you need, handy methods, connection handling, everything pre-made packed with a hug
youtube has been the worst so far
there are no chatbot libs for it
here's the docs, have fun
discord bots are the easiest compare to the real world shit
some websites has so much code
or even like actual servers
I’ve been making an economy bot and I’ve been struggling on making the jobs does somebody have code I can use?
thats the worse way to be a developer
is to source code the main part of the bot economy
Sorry
I’ve made everything else and I’m just having trouble do u have any tips on what to do
i can help with it
@thick raven jobs? Do what you can
What you can’t, Google
What you can’t Google, probably ask scltxn
Lol
lmao
how can i get the avatar url of a specific ID
i have let usericon = message.author.avatarURL(); for the avatar url of the author of the message
resolve the id to a user first
i know the ID
you can use client.users.cache.get(id)
its my bots ID
just use client.user.avatarURL() then if it's the bot
So uh, when I do db.push with a number as value, Instead of it being an array, it becomes a number. Then when I do db.push again, Its gonna error that it is not an array
db.push("foo", 10)
db.get("foo")
//Returns 10
//Expected ["10"]
db.push("foo", 11)
//Gives error that "foo" is not an array
the initial value must be an arrayjs db.set("foo", [10]); // [10] db.push("foo", 11); // [10, 11]
Ok thanks
How can I get a role ID by mention
ya know @rolename
without .replace()
nah im just gonn use .replace
ah right
message.mentions.roles.first()
message.guild.roles.cache.get(args[0]) || message.guild.roles.cache.find(r => r.name == args[0]) || message.mentions.roles.first()
```??
i wanna set setInterval() in a collection by forEach() but with different time... how to do it? discord.js

i wanna set setInterval() in a collection by forEach() but with different time... how to do it?
if you can then dm me...
You need to put your image url where they accept it
That's the author photo
.setAuthor('Some name', 'https://i.imgur.com/wSTFkRM.png', 'https://discord.js.org')
^^
Oh.
.setAuthor(message.guild.name, message.guild.iconURL())
@feral aspen
i finally got this shit to work properly, its now respecting the 2500 limit
Can't seem to understand why it needs a 3rd link @tame kestrel
The third link is an override iirc, it's optional
si
slave0 
console spam

slave0 dying hard
idk why tbh
slave0 has 1057 channels, it failed over 1,5k
im waiting for them all to populate to see a shard6 spawning
i should add a failed count and then route the traffic to more stable shards tbh if too many fail
im fairly certain the shard0 got ratelimited
@opal plank why the hell are you ddosing twitch in the first place














