#development
1 messages · Page 883 of 1
constructors are used to assign properties or smth to classes
you can use static in a method like public static yourMethod()
@knotty steeple are you using python or something?
no js
Oh. Depends how you bind your functions.
e.g.
class Utils {
public static reverseString(str) {}
...
}
wait i dont think you need public
no lol
java brain
vys im working on the economy functions for the bot
Sammy if you have properties it's a good idea to use a default constructor to default the values.
you sure you cant just do constructor(public asdadad)
without needing empty prop initialization
That's not a default but yes you can.
i find it stupid how you still need {} after constructor if you do it like that
wack
You need that for all languages?
It's still a function homie.
Can't just not have a body.
class Yeet {
public:
Yeet() {}
};```
now thats funny
C++ for example.
true
I think I found some old lisp code. 
what
like what are you sorting and where's the prop
thanks that helped.... literally nothing
lol
"what do you want to sort?"
"haha vote go console.log 🤤 "
what do you want to sort it by @earnest phoenix
yes but WHAT PROPERTY do you want to sort by
@earnest phoenix What?
by the fact you deleted your messages i assume you worked out the code yourself @earnest phoenix
Yup i need to do it myself cause no one not helping
Nvm
do you want to sort by user id, username
I want top voters you can understand how can we get
i think we need to sort by "<Object>.id.size"
if theres something like:
"faces": [
{
"features": {
"left_eye": {
"x": 0.6406,
"y": 0.3634
},
"right_eye": {
"x": 0.5594,
"y": 0.3714
},
"nose_tip": {
"x": 0.6031,
"y": 0.4748
},
"left_mouth_corner": {
"x": 0.6469,
"y": 0.5225
},
"right_mouth_corner": {
"x": 0.575,
"y": 0.5305
}
},
}
],```
}
would accessing the X of nose_tip be
there's no way to sort by top voters easily
@earnest phoenix I checked but I don't think there's a prop for checking who has the most votes
^
grr too slow
there is, but you need to utilize webhooks and keep track of it yourself
you need to use the webhooks and track them yourself, yea
xx['faces']['nose_tip']['x']
there is, but you need to utilize webhooks and keep track of it yourself
And store in my db ?
faces is an array @tired nimbus
yes
it's a list
Owh God, my eyes!! 
ok
xx.faces['noset_tip']['x'] ?
Someone help me, please, I can barely do CSS.
you still aren't indexing the array
i mean it looks good i guess
i guess
Can you example plz
IC, okay, thanks
xx.faces[0]
correct
Does it take a looooong time to learn to code? Lots of the words I hear are space words from the moon I don’t understand most conversation hahaha it’s almost like you are all speaking in code
Okie dokie
depends on how much ur gonna do
I wanna make 3D graphics stuff
3d model software? 
Does it take a looooong time to learn to code? Lots of the words I hear are space words from the moon I don’t understand most conversation hahaha it’s almost like you are all speaking in code
@atomic shuttle It took me 2 weeks to make a bot, and 2 weeks to get itdecent
programming depends a lot on maths and the ability to logically resolve problems
Okie dokie
I wanna make 3D graphics stuff
@atomic shuttle 3D is way harder I think
modelling is not developing
I want to make realistic shaders and stuff but just rely on Unreal Engine because it takes up lots of space
Not rely*
No I already know how to model
gl lmao
Who can I talk to if my bot was falsley denied
Yeah I wanna make something cool for fun
there's a reason UE and other engines have a giant team working on it
Hmm
contact the mod who denied your bot
shader engines especially rely a lot on evaluating equations and using correct math operations
including trigonometry
it isn't
trigonometry makes me want to rip my hair out lol
Well it sounds like fun to me hmm
any type of math makes me want to die
of course
Okie dokie
I don’t know much about maths but it’s fun for me when I do do it hmm
Hm m m m m m
Beep boop
Hmm okie dokie
Unreal engine is cool but I think it’s missing some stuff for making it run faster hmm
I think they should try to make it so that screen space reflections can be done first and what’s left is ray traced
Instead of all or nothing
But maybe that’s a buffer problem like they need another layer if they do that
Hmm
Idk
It would be really cool if they went back to using real time cube maps for some reflections like the view model. Just make a dual parabolic map thing so filtering seams only show up horizontally
Oh now I’m ranting about graphics hahahahaha
Meow meow
what issues
basically trying to fetch a message via message id and trying to edit it
message.channel.fetch({around: MessageID, limit: 1}).then(msg => {
const fetchedMsg = msg.first();
fetchedMsg.edit(`test`).catch(error => {
console.log(error);
return;
});
});```
this works on v11, but i cant seem to understand why it doesnt on v12
issue is msg.first(); isnt a function.
Are you trying to fetch your own bot's message or other user's messages to edit? @wintry temple
bot's message
check the docs
wow, thanks for the help
Could anyone help me with discord.py music cmds?
https://pastebin.com/vv9Xk5gn thats the code it says ``` value: crate[message.mentions.users.first().id].crate + " crates"
^
TypeError: Cannot read property 'crate' of undefined```
Does the mentioned user have a property in the crates JSON tree?
wow, thanks for the help
@wintry temple
what the fuck do you expect lol. there was a breaking change with the method you're using, check the docs to see the new return type.
@sudden geyser wdym
@earnest phoenix ye, like i havent read the docs already
so where's the problem
already mentioned it, so if you are able to read, feel free to read
Does the mentioned user have a property in the crates JSON tree?
@queen needle, I don't really know how to get more specific than this.
also my internet died so I don't know if it sent twice.
you mean me or him? because i aint the one saying shit like "what the fuck do you expect lol" like a retarded fuck face who thinks they are helping but aint
like do thye exist in the json file
I'm mostly talking to you
well you require the object then assign it. I don't know why you're doing it in two separate message listeners or why it's even in json.
Calling people 'retarded fuck faces' isn't exactly productive
if you had read the docs then you would have seen that fetch returns a Channel object therefore proving you didn't bother to check the docs
"what the fuck do you expect lol" isn't exactly productive
@sudden geyser too lazy to use databases
should take the time
You're right it isn't, so how about instead of you two continuing to argue, treat each other with some respect.
imagine being salty because someone wont spoonfeed you the solution 
its a bit annoying when they dont "spoonfeed you the solution" but it will help a lot in the long run cause then you wont have to ask for help as much
that's a stance i absolutely cannot agree with more
and you understand how it works
it might seem like people are just lazy to not help you but they're pushing you to do it yourself, to learn it yourself, to think by yourself :p
yeah
jesus fucking Christ i am retarded, why am i fetching when i already have the message object
@wintry temple you can use a promise to edit a message ur bot sends
or use async/await
ye, i just realize
@earnest phoenix
I have a array with id's
//Example
const ids = ['2', '3', '3', '6', '2', '1', '6', '2', '4']
How can get duplicate value with count ?
the amount of duplicates?
Yes with duplicate id
Like 2: 3, 3:2, 6:2
is there a better way of doing this?
export function parseQuery(...params: string[][] | any): string {
let output = "";
for (const [[param, value]] of params) {
if (!output.includes('?')) {
output += `?${param}=${value}`;
} else {
output += `&${param}=${value}`;
};
};
return output;
};
my brain hurts
why
from that code
no the code looks amazing
like i dont understand it so my brain hurts from confusion
lol
sorry
tho the code doesn't work properly
ok so it actually does work
I just have to modify the way it works
what is it supposed to do if you dont mind me asking?
@earnest phoenix nvm i got that.
or should i ask that in general
oh my god im so sorry pk i started writing and got interrupted and just forgot about it lol
Lol nvm i got that
I was just pointing it out lol
found it weird to have a union type with any
anyways
export function parseQuery(params: string[][]): string {
let output = "";
for (const [param, value] of params) {
if (output.includes('?')) {
output += `&${param}=${value}`;
} else {
output += `?${param}=${value}`;
};
};
return output;
};
let data = [
['someValue', 'its-data'],
['some-other-value', 'some-other-data']
];
console.log(parseQuery(data)); // ?someValue=its-data&some-other-value=some-other-data
this is the result
now it works
huh why use a 2d array instead of a hashmap (or equivalent)
fair enough I guess
Help ?
async def giverole(ctx, user: discord.Member, role: discord.Role):
await user.add_roles(role)
await ctx.send(f"hey {ctx.author.name}, {user.name} has been giving a role called: {role.name}")```
discord.ext.commands.errors.MissingRequiredArgument: user is a required argument that is missing.
well
the error literally says
you're not passing a discord user
how are you running the command?
@copper cradle yo remember me ?
@copper cradle im useing visual code
I told u i wrote shit in my bit description few days ago
and i was here for a few minutes
U said i dont have to worry about my bot being offline while testing since it wouldn't pass the description review
@copper cradle im using visual studio code
irrelevant
@bitter rivet how does the command work
@optimus#7731 not really
@idle schooner it works by *giverole @idle schooner <@&264889767072628742> like that
-atmods @bitter rivet
@bitter rivet
Please do not mention (ping) more than one or two moderators for help, unless there is an emergency.
Here are some examples of emergencies:
- Raids / Multiple members mass spamming.
- Severe disruption of Discord's ToS (NSFW content, etc)
- Anything that requires more than 2 moderators to handle.
It says user missing
i just realized that fack
@bitter rivet that's not what I asked
wait
@copper cradle im useing visual code
@bitter rivet I was answering to this message
forget about that
he didn't ask tho
I said I didn't ask for your text editor
instead of discord.Member try with discord.User
Oh i am allowed to link
@idle schooner oooohhh
Zsnails there u go
It actually passed description review
wait really?
And they did decline it because it was off
@copper cradle now it saying discord.ext.commands.errors.CommandNotFound: Command "addrole" is not found
I swear it was shit
@bitter rivet well bc discord.User doesn't have that method
I just told you to do it to see what happened
change it back to discord.Member
I wrote things like "please accept my bot, idk what to write here"

hmm
if you're passing the first argument as a mention it should work
wdym'
don't know why it doesn't lol
the command is being run like this right?
*giverole @bitter rivet @rolementionhere
yes @copper cradle
wdym
user: discord.Member = {}
not working FACK
lol
i was spelling it wrong i kept doing addrole but i meant to type giverole i would of never known until a guy mention me and said your spelling it wrong
....
@copper cradle
lmao
Guys I need to create a database, if I use SQLite, will I have to switch from it in the future, if my bot get's big enough?
yes
how long does it take to approve bots
a few weeks
if(!member.guild.me.hasPermission("MANAGE_CHANNELS")) return;```
Why is not good?
what are you even trying to do wtf
^^
Need a bit more info. Put in a bit more code, tell us what your trying to do, and what error your getting. No one can really help with the info given.
^^
the event and the 2nd line are not of any use combined alone as far as i can see
some days i hate mysql. why? heres an example:
https://hatebin.com/havobzjefp
anyone have any idea why that does what it does?
just use postgres if youre gonna go through the effort of mysql
you dont need console.log({c}) you can just do console.log(c)
c is an array with two items, because looping over collections treats each item as an entry, the same as doing Object.entries()
so c = [key,value]
so you need to do c[1].name
Sry that i am asking here but I forget css how to change the front and the color at one time.
Oof I'm sry i mean css anyway..
font and colour are separate css
.mydiv {
font-family: Arial, Something-Serif, Blah;
font-size: 2.3rem;
}```
Ok thanks
no problem 🙂
color: color;
for color
yeah and that
Thanks
where the colour can be a named colour, rgb(), rgba() or #rrggbb hex etc
ok
@earnest phoenix that wont work
the bot isnt in the server anymore
@digital ibex context please
in the messageUpdate event fires, i get that
thats all i know
module.exports = async (client, message, oldMessage) => {
let oof = require('../../models/Guild');
let guild = await oof.findOne({ id: message.channel.guild.id });
let alchannel = guild.alchannel;
client.createMessage(alchannel, {
embed: {
title: 'Message Edited'
}
})
}
haven't finished it and i get that
then alchannel is undefined
consolelog it
ok
i need help about system files. Do DLL have classes?
data typessss
ok
module.exports = async (client, message, oldMessage) => {
let oof = require('../../models/Guild');
let Guild = await oof.findOne({ id: message.channel.guild.id });
let alchn = Guild.alchan;
let embed = {
title: 'Message Edited'
}
console.log(alchn)
client.createMessage(`${alchn}`, { embed })
}
i still get that
and it spams
Why can't the bot find the owner of this server?
owner is not cached
how would I make it so if you join a server, you get a 'verified' role in all servers
but then once you leave that server it gets taken away
Other bots can see, why? @quartz kindle
listen to memberAdd and memoberDelete events
@tiny grotto you need to fetch the user/member
@quartz kindle its just that I can't figure out how to give it in all servers
the role
to my problem: c is "enmap" named npm package list or smh, and it worked before i did edit the embed, i just added some fields
and if it exists or not
@royal portal js for(let serverID in listOfServerIDs) { let member = await client.guilds.cache.get(serverID).members.fetch(userID) await member.roles.add(role) }
I'll try that
(node:2484) DeprecationWarning: ClientUser#setGame: use ClientUser#setActivity instead
how I can solve this problem ??? I try everything I think... :/
read the error
vait
so
omg stonks :d
(node:2484) DeprecationWarning: Collection#find: pass a function instead
I get this problem now :/
its deprecation warning
not error tho
but if you wanna solve, pass a function instead
like collection#find(c => c === "example")
function instesd ("id", "836628382727")
@signal acorn so what kind of help do you genuinely need?
@queen violet
Crap
Uh sorry

@earnest phoenix i need help in bots cmd i have made some cmds and working nice i need more for fun and also for nsfw
I meant to send that with context
But dep, I can't try and see
I have no access to the bot, it's my friends bot
@signal acorn hmm like what kind of commands? Explaion some
for fun and nsfw
For example 8ball... Or claptext... Or what?
Incase your wondering dep
@earnest phoenix what was your issue?
for example in nsfw .(i rly cant explain) l
@earnest phoenix can u suggest me a link from where can i get some new cmds
https://discordjs.guide for js
@signal acorn you can store nsfw files for it to show as a random pick but you can also fetch them from the stored subreddits with a module
for js
He told me to listen to the person that said to try and see what code peice could work for the bot, but I have no access to the bot whatsoever, it's not my bot, it's my friends bot
It's all good!
Hmm
oh ok
Please regenerate your token
ok
my bot is broken can someone help
my only code is
const Discord = require("discord.js");
const client = new Discord.Client();
const token = "*token*";
var prefix = `-`;
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on("message", (msg) => {
if (msg.content === "ping") {
msg.reply("pong");
}
});
client.login("token");
I type node . and it dosent load and my terminal says:
\Users\Jon\Desktop\Discord Bot\index.js at Function.Module._resolveFilename (internal/modules/cjs/loader.js:961:17) at Function.Module._load (internal/modules/cjs/loader.js:854:27) at Module.require (internal/modules/cjs/loader.js:1023:19) at require (internal/modules/cjs/helpers.js:72:18) at Object.<anonymous> (C:\Users\Jon\Desktop\Discord Bot\index.js:1:17) at Module._compile (internal/modules/cjs/loader.js:1128:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10) at Module.load (internal/modules/cjs/loader.js:983:32) at Function.Module._load (internal/modules/cjs/loader.js:891:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) { code: 'MODULE_NOT_FOUND', requireStack: [ 'C:\\Users\\Jon\\Desktop\\Discord Bot\\index.js' ] } PS C:\Users\Jon\Desktop\Discord Bot>
Looks like discord.js isn't installed
ok thanks
I installed discord.js and regenerated my token as I forgot to censor it the 1st time I sent my error and my terminal is saying my token is invalid
From the code above it looks like you're passing the token string
To make it pass from a variable remove the quotations
And it should work
Not your token, in the top variable token you're defining your token, which is a string and should have quotation marks around it
The bottom line where you're referencing token, should not have quotation marks
I can regenerate it .-.
ill wrap you round in quotes
@slender thistle
wait my token has " around it
oi this is #development, at least do it in #memes-and-media smh
and it still won't come on
not fully
s
Can a mod tell me if:
A command that shows information about a cerain role with its permissions included, should be avalible to anyone or not
It's not a privacy breach, such data is stored publicly. You just can't access it with the Discord client without proper permissions. 
Ohh ok, i will make it without req then, thx for anwsering
anything, you can only find with the client, example guild names, they should be private.
ohh ok
Should they
Yeah, we consider non-consensual listing of guild names a privacy breach
If you want, you can have a command to show how many servers, but not the specific servers
Ok, i dont have a command that shows all guilds so im fine, i only show the number of guilds the bot is in
Yeah that’s fine then
Thx for taking ur time guys 😄
hello
how cna i fix this
its coming from: ```js
client.on('messageUpdate', async (message, oldMessage) => {
let gu = require('./models/Guild');
let guild = await gu.findOne({ id: message.channel.guild.id });
let alchan = guild.alchan;
client.createMessage(alchan, {
embed: {
title: 'Message Edited'
}
})
})
Is that sequelize? @digital ibex
eris.js
Can we see the model file for guild
Are you trying to set the timeout to that huge number?
if you remove the code, it doesnt happen anymore?
oh, thats smthing else
thats smething to do with can't send a message to the action log
because there is none set up for that guild
kk
tim, its ```js
client.createMessage(alchan, {
embed: {
title: 'Message Edited'
}
})
what is alchan
print('o----')
print(' ||||')
@wary needle

it's was a drawing of a dog
@wary needle gimme a challenge of something to make, i'm hella bored
I got a quick question. i used the Discord.js guide to set up a Bot but now that I'm at it programming, i cant find any role or roles argument.
wdym u can't find any roles?
Hm got it
Yeah Lemme show you
show me wot u want to happen
i'll do them tho mr sylte
not the code part, or if u hav sum then show it
i don't kno much djs, but from what i remember its <member>.roles.add
member.addRole(role).catch(console.error)
yeah but wnn i type members.role or AddRole isnt there
its like not gettign showed as a possible command
Use v11
@quartz kindle do you know why ```js
client.createMessage(alchan, {
embed: {
title: 'Message Edited'
}});
gideon
it doesn't have to show there
its all in the docs
@digital ibex is alchan a string or number
@surreal wind member or members is not a free-floating global variable, you still need to access it from somewhere depending on the context
@surreal wind in your current context, you have access to message, and you can access the message author's member object via message.member then you can access this member's roles via message.members.roles
and so on
Ah ty
@digital ibex console.log(alchan,typeof alchan)
kk
686997585541726264 string spams it
in the console
oh, it only sent it twice, nvm
ok so im gonna be setting up a shop for my bot and i want to know if this might be a good way to store the things that can be bought
"shop": [{
"item1": {
"price": 69
},
"item2": {
"price": 111
},
"item3": {
"price": 256
},
"item4": {
"price": 420
},
}]```
that looks like it should work @knotty steeple
just put Date.now() in a variable
@earnest phoenix Oh, thank you very much for that 🙂
https://gyazo.com/56e8ebc135315db81b78a4fe6b6c02c8
how i do it?
but on whatsapp
Do what on WhatsApp?
my page in embed
the same way
dont work
look into opengraph, twitter cards, oembed etc
is lang="es" or lang=es ?
the first
can anyone tell me why its not working
const { Command } = require('discord.js-commando');
const snekfetch = require('snekfetch');
const Discord = require("discord.js");
module.exports.run = async (bot, message, args) => {
const { body } = await snekfetch.get('https://random.dog/woof.json');
const embed = new Discord.RichEmbed()
.setColor("#00ff00")
.setImage(body.url);
message.channel.send(embed)
}
module.exports.help = {
name: "dog"
}
oh ok i get it
"can anyone tell me why its not working"
if ur gonna ask for help next time provide more details
like if u are getting an error and what it is
Also snekfetch has been deprecated, might wanna use node-fetch instead
also why are u using commando
in that code u dont need it
seems as though u have ur own command handler
or most likely a stolen one
u dont need args either
@knotty steeple na its from my frnds bot nut i get it
its not stolen
we are working on a project i was try some new cmds but i got the solutionn
i hate when people do module.exports.whatever
either export it once or do exports.whatever for each one
currently I'm a bit puzzled.
I'm trying to get STDOUT of my discord.js Shards, because they can print some useful information to process.stdout.
Does anyone know if I can attach to every shard and listen to their stdout?
So if o try to use this code:
let role = message.members.roles.get("700852729739870309");
message.members.addRole("role");
I recive this error:
TypeError: Cannot read property 'roles' of undefined
but why?
@static sable does their logging not appear in your console/terminal?
it should by default
I'm usign the ShardManager to spawn Shards. very basic everything.
my shard is having a ready listener:
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
which get's lost since that process is a child_process and it's output won't get redirected to the main process stdout
are you running on windows or linux?
you can try this ```js
shard.stdout.on('data', data => {
console.log(data.toString());
});
are you running on windows or linux?
@quartz kindle yes. (I mean, both)
what is that? ```html
<meta property="og:updated_time" content="1440432930" />
timestamp of when something got updated
@calm coyote #commands or #265156322012561408 for commands
okay I could fix it.
monkey-patched ShardManager and Shard to spawn with silent:true so I can listen for stdout of each shard.
which enables me to log my shard's outputs
manager.on('shardCreate', shard => {
console.log(`Shard [${shard.id}]: created.`);
shard.on("spawn", shardProcess => {
shardProcess.stdout.on("data", chunk => {
console.log(`Shard [${shard.id}]: ${chunk.toString()}`);
})
});
});
@static sable Which JS library are you using?
discord.js
yeah that's what I was trying first, but that just works if I'm using process.send() instead of console.log() though
But I want to listen for errors etc and those would get swallowed else
How2embed
Whatlibrary
Node.js
not a library
Alright, i give up. i cant find anything about that error. and i dont know how to fix it, he keeps saying:
message.members.addRole("700852729739870309e");
^
TypeError: Cannot read property 'addRole' of undefined
nevermind how i change it, there is always something that's undefined for him
@sudden geyser
message.members doesn't exist
Not a library.
Alright, i give up. i cant find anything about that error. and i dont know how to fix it, he keeps saying:
message.members.addRole("700852729739870309e");
^TypeError: Cannot read property 'addRole' of undefined
nevermind how i change it, there is always something that's undefined for him
@surreal wind its message.member
It's basically js
Still not a library
it's a language
Discord.js, Eris, etc.
But i am within an area wher i have to use message.member
Ig discord.js
But i am within an area wher i have to use message.member
@surreal wind which library are u using? discordjs, or discordio?
yes
what version
Discordjs
all libraries work differently
Uhhh
discordio is deprecated btw
Discordjs
@surreal wind then change your code to:message.member.addRole("700852729739870309e");
I guess I'll dig through my own code
then should work
In Discord.js, either create a new message embed class then send it, or send the raw object. https://discord.js.org/#/docs/main/stable/examples/embed
does ur bot has permissions to add roles?
The example is for v12. If you're v11, you'd use RichEmbed instead of MessageEmbed
He should have. let me double check
btw, anyone here is a tester or admin on this? i need to clear soemthing about a bot i had rejected
i had no chance to tell anything 😦
Your bot was likely declined because it broke one of the "bot rules" listed in #rules-and-info.
To find out why your bot was declined and by who, use the search feature in #mod-logs:
@frozen valve yeah he has permission to Manage Roles
@frozen valve yeah he has permission to Manage Roles
@surreal wind whats the log on ur bot?
you mean the error message?
the log
i need to see more context
can you share more of the usecase?
code and stuff
client.on('message', message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
if (command === 'ping') {
message.member.send('Pong.');
}
else if (command === 'role') {
message.member.send('please select the role !player if you are a participant or !watcher if you a here to cheer them on..');
}
else if (command === 'player') {
message.member.send('Thank you for signing up for the event - good luck to you..');
// let role = message.members.roles.find("700849600973766667");
message.member.addRole("700849600973766667");
}
message.member.addRole("700852729739870309e");
^
TypeError: message.member.addRole is not a function
at Client.<anonymous> (D:\Discord Bot\DiscordBot\Lumi\Index.js:30:24)
at Client.emit (events.js:315:20)
at MessageCreateAction.handle (D:\Discord Bot\DiscordBot\Lumi\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (D:\Discord Bot\DiscordBot\Lumi\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (D:\Discord Bot\DiscordBot\Lumi\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31)
at WebSocketShard.onPacket (D:\Discord Bot\DiscordBot\Lumi\node_modules\discord.js\src\client\websocket\WebSocketShard.js:436:22)
at WebSocketShard.onMessage (D:\Discord Bot\DiscordBot\Lumi\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10)
at WebSocket.onMessage (D:\Discord Bot\DiscordBot\Lumi\node_modules\ws\lib\event-target.js:120:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (D:\Discord Bot\DiscordBot\Lumi\node_modules\ws\lib\websocket.js:801:20)
how tf do u not know what library ur using
more likely u just stole it and followed some instructions
im not talking about u
no.
```js
lient.on('message', message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
if (command === 'ping') {
message.member.send('Pong.');
}
else if (command === 'role') {
message.member.send('please select the role !player if you are a participant or !watcher if you a here to cheer them on..');
}
else if (command === 'player') {
message.member.send('Thank you for signing up for the event - good luck to you..');
// let role = message.members.roles.find("700849600973766667");
message.member.addRole("700849600973766667");
}
nice
*client
pls make a command handler
u should add commands instead of handling the message this way
but thats another refactor
Uhm, yeah about that, i tried after teh Guide
and it didtn work at all, so i wetn back
pls take ur time typing
do you know the version of the library you're using?
you need to be in a guild environment
like come on, the library is even in the stacktrace error
if (!message.guild) return;
add this line after checking if the message comes from a bot.
or add it to the if.
how can I make a promise-mysql connection that I can use in multiple modules?
(!message.guild || message.author.bot) return;
how can I make a promise-mysql connection that I can use in multiple modules?
@wheat jolt create a module, try using TypeOrm if you're with TypeScript, otherwise you can use Sequelize
And with that added, i can use guild functions, to addRoles as example?, nice let me try that
no, it prevents users from DMing your bot
@wheat jolt create a module, try using TypeOrm if you're with TypeScript, otherwise you can use Sequelize
@frozen valve I never used sequelize
can't I just use promise-mysql?
can't I just use promise-mysql?
@wheat jolt you can use whatever you feel comfty with
if you know many libraries that will help you, thats fine, but im telling you, you need to create a module in order to reuse it everywhere
But yeah if you're not good with SQL, use a wrapper like Sequelize
I'm sure there's more awesome ones aswell
i don't care
i was supposed to
you can't connect on root only from localhost so
i dont care about your server
and you don't even know the ip :)
I tried this but ofc it's not good
http://alex.is-bad.com/2dK7oEp.png
this is what I get on a console.log
u have to use async await or then
how do u use it?
show me the code where u use it
http://alex.is-bad.com/4wVD1xT.png
this is the all db.js
and these are the lines I use to console.log
http://alex.is-bad.com/3ML3EZ2.png
the problem is that you are not fullfilling the promise
try this:
db.then((conn) => console.log(conn));
this is the all db.js
and these are the lines I use to console.log
http://alex.is-bad.com/3ML3EZ2.png
@wheat jolt you can remove thethenpiece of code
yeah this wont add up. trying the addRole command with Guild instead i get the same error, that guild is not defined. i give up. apparently I'm to new to JS to understand that right away. Welp it was a nice Try to get to understand it, but just wont make any sense for me. Ill rather go back programming in ABAP xD
what's so difficult lol
yeah this wont add up. trying the addRole command with Guild instead i get the same error, that guild is not defined. i give up. apparently I'm to new to JS to understand that right away. Welp it was a nice Try to get to understand it, but just wont make any sense for me. Ill rather go back programming in ABAP xD
@surreal wind we didnt ask you to use guild, we told you to use the command within a guild
its still message.member
thanks
@wheat jolt all ok
yeah
but that's what i don't get, if i add message.member.guild.addRole("role"); it tells me the function doesn't exist, but i need it to be within the entire setup, after answering to add the chosen role to the person that received the message.
please read the docs
please read the docs
@pale vessel lol ur avatar makes me think you're angry lol
i am
i am
@pale vessel is that your secret? hulk style?
the discord.js docs? i used discordjs.guide so far but that didn't really help at all otherwise i wouldn't be asking
ok Gideon, quick question
where are you testing your bot?
did you made a test server and invited the bot?
yes
or did you direct message the bot?
No im communication via a channel in a discord to the bot
the respnse is sent to me in a DM
ic
Can someone help me with a JDA issue?
-ask2ask
Don't ask to ask.
Just ask your question, it wastes time if you say "i need help" or "can someone help me?" instead of just saying what the problem is. Save your time and other people's time and just ask the question.
Please read https://dontasktoask.com/ for an explanation on why this is an issue.
who here is experienced with discord.js v12? If I need to message into a specific guild in a way that is shard-safe; do I use Client#guilds#resolve?
fetch
It conserns me that this method doesn't return a promise
well that doesn't look cross shard
use fetch
guilds has no fetch, unfortunately
GuildManager*
I would help you but https://oliy.is-just-a.dev/69m1ed_3647.png
and mine wont embed
I love it
no ssl
btw, is it just me or discord.js docs is dead
it's github
yeah
GitHub is being an issue rn
weird, cloudflare might be having an issue
or my proxy
hm
it just embeded in my server
oh well
but fetching is safe with sharding right?
instead of looking for the guild I can just have the channel snowflakes in my configuration
and fetch those
i need help with making a command that runs and embed when sent
so far i have this
const Discord = require('discord.js');
module.exports = {
name: 'testembed',
description: 'Testing an embed',
execute(message, args) {
const exampleEmbed = new Discord.MessageEmbed()
.setColor('#0099ff')
.setTitle('Some title')
.setURL('https://discord.js.org/')
.setAuthor('Some name', 'https://i.imgur.com/wSTFkRM.png', 'https://discord.js.org')
.setDescription('Some description here')
.setThumbnail('https://i.imgur.com/wSTFkRM.png')
.addFields(
{ name: 'Regular field title', value: 'Some value here' },
{ name: '\u200B', value: '\u200B' },
{ name: 'Inline field title', value: 'Some value here', inline: true },
{ name: 'Inline field title', value: 'Some value here', inline: true },
)
.addField('Inline field title', 'Some value here', true)
.setImage('https://i.imgur.com/wSTFkRM.png')
.setTimestamp()
.setFooter('Some footer text here', 'https://i.imgur.com/wSTFkRM.png');
message.channel.send(exampleEmbed);
},
};
i don't know why this isn't getting executed
when i type my command
why
Is it possible to mix js and JSON into a bot?
@late plank Yes, just make sure to check whether the guild you are looking for was found/returned
is this redundant? is the 2nd line really needed in js?
If you want client to be available to every method inside your class, then no
js and JSON are two entirely different things, @earnest phoenix
ye makes sense aight thx
lol JSON is a file type yeah
js is a language, while JSON is a notation
JS is used to lose sanity, JSON is used as a database.
JSON can be used as a database, still. It's just not recommended in comparison to actual proper databases
Do you have any good hosting suggestions?
@heavy marsh host.pls works good but requires some effort and it's paid, heroku requires minimal effort and is free, glitch puts hard limits on your bot but is also free but sucks
Wouldn't recommend Glitch either, DigitalOcean/Vultr/Linode all work
I use host.pls
I mean paid onces. Reliable, safe, fast and not that expensive
What is this
Vultr's smallest instance
@hasty sparrow got it; thanks
@heavy marsh host-pls.com
alright folks; one more question
I'm getting these every once in a while
(node:6689) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Access
at RequestHandler.execute (/home/headline/bots/discord-compiler/node_modules/discord.js/src/rest/RequestHandler.js:170:25)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:6689) 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:6689) [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.
This makes it very difficult to track down where access is missing, I believe nearly all of my code should be covered to handle permissions errors, but there must be one case that I'm forgetting or otherwise missing. Any tips for tracking this down or do I just have to scour my codebase and nitpick
@frozen valve Any other Ideas ,what it might be? No matter what i try, going through with a guide it always ends up telling me something isn't a function or its not defined.
-dotpost
Please do not post dots to clear your messages/get attention. It adds absolutely nothing to the conversation and just causes spam If you need to get attention, then say hello everyone. If you need to clear your messages, then press the Esc key. If you do not follow these instructions you will be muted.
@glad charm that message was accidental
NICE
@glad charm there's a grammatical error in that warning, by the way
You're missing the period after causes spam
Lol thanks.
how i do that?
https://gyazo.com/0de20e5901507cd819cbb9e29f410900
hi yall im trying to figure out how to log info-level messages from jda and this wasn't working, what can i replace net.dv8tion.jda with?
<configuration debug="true">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<logger name="net.dv8tion.jda" level="INFO" />
<root level="warn">
<appender-ref ref="STDOUT" />
</root>
</configuration>
how i do that?
https://gyazo.com/0de20e5901507cd819cbb9e29f410900
@earnest phoenix
that's just a hyperlinked image, in html a image tag inside of an anchor tag
how i do hyperlinked image
in html a image tag inside of an anchor tag
reading comprehension 🌈
what about markdown cuz i forgot
iirc [](hyperlink)
how i add ads for win money? :v
adsense
adblock™️
ublock origin and anti adblock killer script equals profit
how would i send a message to a user without initiating the bot in discord.js?
I use ublock origin
i'm not sure if discord.js allows you to use REST alone
you can't send a message without starting the bot
@frozen valve Any other Ideas ,what it might be? No matter what i try, going through with a guide it always ends up telling me something isn't a function or its not defined.
@surreal wind please doconsole.log(message.member.addRole)
and show me whats the output
haha, would want to but it's the only framework i know (for a quick discord bot deployment), any suggestion on a good framework/library for discord apis?
case("k/play"):
const voiceChannel = message.member.voiceChannel;
if(!voiceChannel) return message.channel.send("**No voice channel**");
try {
var connection = await voiceChannel.join();
}catch (error) {
console.error(error);
return message.channel.send(`Error -> ${error}`)
}
``` help im using v12
It tells me im not in a voice channel, but im in one
haha, would want to but it's the only framework i know (for a quick discord bot deployment), any suggestion on a good framework/library for discord apis?
@gilded gazelle
it really depends on what languages you're willing to work with
when a shard gets the ready event the guilds field will only contain guilds for that shard right?
Yes
@jovial nexus what version of Discord.js are you using.
v12
that is voice.channel on v12
<Member>.voiceChannel was replaced with <Member>.voice.channel in v12
@surreal wind please do
console.log(message.member.addRole)
@frozen valve got an undefined
Thxxx
@sudden geyser is this good? js case("k/play"): const voiceChannel = message.member.voice.Channel; if(!voiceChannel) return message.channel.send("**Necesitas estar en un canal de voz para usar este comando**"); try { var connection = await voice.Channel.join(); }catch (error) { console.error(error); return message.channel.send(`Log del error -> ${error}`) } break
check the docs! Channel should not be capitalized.
@frozen valve got an undefined
@surreal wind thats the problem, the bot can not add roles
Okay, then i gotta look, i know he has the permission but ill recheck, thank you
addsense is +18?
sh*t :v
i know
like pennies per click
depends
which is better?
ok
Okay, then i gotta look, i know he has the permission but ill recheck, thank you
@surreal wind https://www.reddit.com/r/discordapp/comments/69u737/can_someone_plz_explain_me_how_addrole_works/dh9ekoy/
0 votes and 11 comments so far on Reddit
@surreal wind https://www.reddit.com/r/discordapp/comments/69u737/can_someone_plz_explain_me_how_addrole_works/dh9ekoy/
@frozen valve Thanks but i still get the undefined log message xD as said, i guess Js isn't for me
0 votes and 11 comments so far on Reddit
hi hi im doing some stuff with sql
const Database = require('better-sqlite3');
const db = new Database('././src/Bakery.db');
const rows = db.prepare("SELECT * FROM users order by money desc limit 10;").get()
console.log(rows)
im trying to get the top 10 users based on money
thing is rows only actually logs 1
but i literally tested that query and it does return multiple rows
so idk why its not working in code
what does this mean??
whatever ur putting is undefined
how do i fix it?
define it 🤔
make it not defined
im defining it...
You did not define it as a string
Hi
Your bot @invalid-user was declined. Reason: Your bots help command gets rate limited instantly due to the number of messages you send so quickly, please limit the number of messages your bot sends.
u can say off-topic for anything
how do i define it as a string?
"string"
suggest me cmds plz
no
joinedAt()?
@jovial nexus
@copper cradle i already fixed that
if (message.content.startsWith("k/play")) {
const voicechannel = message.member.voice.channel;
if(!voicechannel) return message.channel.send("**Necesitas estar en un canal de voz para usar este comando**");
try {
var connection = await voicechannel.join();
}catch (error) {
console.error(error);
return message.channel.send(`Log del error -> ${error}`)
}
const dispatcher = connection.play(ytdl(args[1]))
.on('end', () => {
console.log('Canción terminada');
voicechannel.leave();
})
.on('error', error => {
console.error(error);
return undefined;
});
dispatcher.setVolumeLogarithmic(5 / 5);
}
``` my new code
nice code from github lol
@jovial nexus what's the error? are you getting any errors?
stop using var
this is the error
args[1] is undefined
Are you sure it's not args[0]?
how are you calling the command?
are u sure u dont want to join the args
*occurring
if i put args[0] it crashes
well fix that issue
you can't just say uuuh args[0] crashes I'm gonna use args[1]
without even knowing that the number means
it doesnt show more
how about you console.log(args) to see what your args actually are?
I was gonna say that
then args[0] is correct
ofc it is
but it still crashes
Hey, do I need to have a bot in order to get an API key
how would u get how long a member has been in the guild with eris?
@jovial nexus that doesn't matter
your code is erroring somewhere else
show your code again
if (message.content.startsWith("k/play")) {
const voicechannel = message.member.voice.channel;
if(!voicechannel) return message.channel.send("**Necesitas estar en un canal de voz para usar este comando**");
try {
var connection = await voicechannel.join();
}catch (error) {
console.error(error);
return message.channel.send(`Log del error -> ${error}`)
}
const dispatcher = connection.play(ytdl(args[0]))
console.log(args)
.on('end', () => {
console.log('Canción terminada');
voicechannel.leave();
})
.on('error', error => {
console.error(error);
return undefined;
});
dispatcher.setVolumeLogarithmic(5 / 5);
}
well, your console.log broke it lmao
a medias
the reason you can put .on() in a new line, its because you're actually doing connection.play().on() because connection.play() returns a dispatcher
which means .on() can only be used on a dispatcher
dispatcher.on()?
you put console.log in the middle of them, causing it to become console.log().on()
if (message.content.startsWith("k/play")) {
const voicechannel = message.member.voice.channel;
if(!voicechannel) return message.channel.send("**Necesitas estar en un canal de voz para usar este comando**");
try {
var connection = await voicechannel.join();
}catch (error) {
console.error(error);
return message.channel.send(`Log del error -> ${error}`)
}
const dispatcher = connection.play(ytdl(args[0].url))
console.log(args)
dispatcher.on('end', () => {
console.log('Canción terminada');
voicechannel.leave();
})
dispatchers.on('error', error => {
console.error(error);
return undefined;
});
dispatcher.setVolumeLogarithmic(5 / 5);
}```
now this
oh ok
args[0] is just a string, not an object, where did you get that code from?
if (message.content.startsWith("k/play")) {
const voicechannel = message.member.voice.channel;
if(!voicechannel) return message.channel.send("**Necesitas estar en un canal de voz para usar este comando**");
try {
var connection = await voicechannel.join();
}catch (error) {
console.error(error);
return message.channel.send(`Log del error -> ${error}`)
}
const dispatcher = connection.play(ytdl(args[0]))
console.log(args)
dispatcher.on('end', () => {
console.log('Canción terminada');
voicechannel.leave();
})
dispatcher.on('error', error => {
console.error(error);
return undefined;
});
dispatcher.setVolumeLogarithmic(5 / 5);
}``` like that?
i got it from a tutorial from the docs of the discord.js server
I am trying to make a bug report command that sends the report to my guild to a specified channel and I keep getting this error TypeError: Cannot read property 'cache' of undefined and idk what I have wrong
var myGuild = bot.guilds.cache.find(g => g.id == '694557723978891344');
var logChannel = myGuild.channels.cache.find(c => c.id == '701924697289523291')
const bugReport = new Discord.MessageEmbed()
.setTitle("Bug report")
.setDescription(`<@${msg.author.id}> reported\n${argsresult}`)
.setColor('#FF0000')
.setTimestamp()
.setFooter(msg.author.username, userAvatar)
logChannel.send(bugReport);
},
first
don't use == always ALWAYS use ===
and async
iirc find returns a promise
but I'm not sure tho
ok tim you can take this I can't think right today
wait
which one is the undefined one
show the rest of the log
at Object.execute (/Users/macbookpro/Desktop/GoogleDrive/KnightBot/commands/bugreport.js:22:34)
at Client.<anonymous> (/Users/macbookpro/Desktop/GoogleDrive/KnightBot/bot.js:76:15)
at Client.emit (events.js:323:22)
at MessageCreateAction.handle (/Users/macbookpro/Desktop/GoogleDrive/KnightBot/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/Users/macbookpro/Desktop/GoogleDrive/KnightBot/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/Users/macbookpro/Desktop/GoogleDrive/KnightBot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
at WebSocketShard.onPacket (/Users/macbookpro/Desktop/GoogleDrive/KnightBot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:435:22)
at WebSocketShard.onMessage (/Users/macbookpro/Desktop/GoogleDrive/KnightBot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)
at WebSocket.onMessage (/Users/macbookpro/Desktop/GoogleDrive/KnightBot/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:311:20)```
what's on line 22
var myGuild = bot.guilds.cache.find(g => g.id == '694557723978891344');
console.log(bot.guilds);