#development
1 messages · Page 943 of 1
@limber flume
You assign Reactorslist as a list
you then dont append users to it atall
so when random.choice() happens
its still a empty list
btw
dont DM me saying halp
hi there
just trying to get username from id (in v12)
firstly i used
const user1 = client.users.fetch("123456789012345678");
for get info of user
console logs look good but when i trying to send it to channel it couldnt send
got an empty message error

fetch is a promise

@limber flume
@modest maple ok so i need to put this ```py
winner = random.choice[reactorsList]
ok
ima google define appending
add (something) to the end of a written document.
wHat aM i AddINg
@bot.command()
async def giveaway(ctx, waitTime, *arg):
reactEmoji = '🎉'
embed = discord.Embed(colour=0xff0000,description=f'**React with {reactEmoji} to participate in this giveaway!**\nTime remaining: **{waitTime} minutes!** 🕰')
embed.set_footer(text='1 winner')
messageObject = await ctx.send(embed=embed)
await messageObject.add_reaction(reactEmoji)
waitTime = int(waitTime) #*60 # amount of seconds to wait
reactorsList = []
print('waiting')
await asyncio.sleep(waitTime)
print('I have waited!')
messageObject = await messageObject.channel.fetch_message(messageObject.id)
allReactions = messageObject.reactions
print(allReactions)
for reaction in allReactions:
print('checking reaction')
print(str(reaction.emoji))
if str(reaction.emoji) == reactEmoji:
print('found reaction!')
print(reaction)
users = await reaction.users().flatten()
print(reactorsList)
winner = random.choice[reactorsList]
await ctx.send(f'The winner of the giveaway for {arg} is <@!{winner}>')
Hello, I would like to know your opinion on Mongoose: is it better than basic mongo?
if you need or want to use its schema system, yes
wait is mongoose just about schemas ?
as far as i know, yes
yes
uh, ok. i hadn't read all the docs. thanks then
mongoose is a means of utilizing schemas with mongodb, which is by its very nature, schemaless
how can you see what server your bot is in?
feel free to @ me
you can do regular mongodb operations like insertOne and stuff manually with mongoose too
tbh mongoose is too good.
i just like being able to be strict with what goes in my database tho
i kinda dislike it
it looks like SQL in noSQL x)
i like the headache that comes from it :)
i wrote a wrapper module thing for mongoose (unreleased) that i dubbed 'common mongo'. it allows me to very easily create document structures, as well as a cache system that caches data for a few minutes before saving and discarding the datas. it literally cut the amount of queries i was doing to mongo from a couple hundred per minute to like, 3...
(per player)
now i can make my document structure in files like that
super easy ❤️
@rocky dagger which library?
help please
client.on("guildBanAdd", async (guild, user) => {
let i = await db.fetch(`bankoruma_${guild.id}`);
if (i === "kapali") return;
if (i === "açık") {
let log = guild
.fetchAuditLogs({ type: "MEMBER_BAN_ADD" })
.then(k => k.entries.first());
let exec = guild.members.get(user.executor.id);```
here error
user.executor is undefined
why
i don't think that property even exists under the user object
OMGGG
do console.log(user)
I'll do it again. The role of the bot is in the role under "banner".
so she made a mistake
Çeviriden mi yazıyorsun
evet
aferin bende diyom niye birşey anlayamıyorum
you cant use markdown in embed titles
You can, but it's limited.
Wait, then how is this possible?
There's a dedicated url property for it. If that's the title, just specify url: <url>
It's hard to explain so just look in the docs for what you can use: https://discord.com/developers/docs/resources/channel#embed-object
@rocky dagger which library?
@blazing portal what do you mean?
js
discord.js?
yes
But idk how to change the title. I don't want the url as the title.
you specify both a title and url property
hi back. I just installed Mongo and its node client and I configured it. but when i launch my bot's beta version with mongo in it, there's the following warning: (node:16857) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
pass option { useUnifiedTopology: true } to the MongoClient constructor.
why? I mean, why put smth deprecated in the newest version of the node driver?
its not deprecated
yet
its a warning that it will be deprecated
well technically it is already deprecated but still exists
so its deprecated but not really
const MongoClient = require('mongodb').MongoClient({ useUnifiedTopology: true})```
so i have to do this ?
yea
wait no
when creating a MongoClient
so
const MongoClient = require('mongodb').MongoClient
const mc = new MongoClient({ useUnifiedTopolgy: true })```
@rocky dagger Depends what exactly you want. All the Servers the Bot is in are saved in client.guilds.cache . so if you want to log all guild names for example you could do client.guilds.cache.forEach(guild => console.log(guild.name));
ok, thanks 👍
does anyone know the name of the software renderer nvidia thing
google does not want to give me it
Why is my bot doing this????
if that user is not in the server, it shows up as "invalid-user" on phone
on pc it shows up as the id
unless your client cached that user before it got kicked/banned/left
Yeah... But why does it spam that if a user is bot leaving?
well thats up to your code, maybe show us the code
nope
module.exports = async (client, member) => {
const channel = client.channels.cache.find(
channel => channel.name === "│joins-and-boosts"
);
if (!channel) return;
channel.send(
`Welcome to our server ${member}!, Please read our rules in the rules channel!`
);
};
@earnest phoenix, That's my code ^
are you maybe running multiple instances of your bot?
i mean't Roman, but you shouldn't run 2 instances
i'd suggest merging
Tim are you here?
I have an events folder that keeps that stuff. And it only says that once...
Hmm
Interesting
maybe you run the script twice
thats what i meant with 2 instances
i have problems to read my data.json file. In the console stands: ReferenceError: Cannot access 'data' before initialization
but it always worked
i have problems to read my data.json file. In the console stands:
ReferenceError: Cannot access 'data' before initialization
can somebody help me please?
your trying to use a variable data before you have declared it.
example:```javascript
data.someProperty
//... later in code
const data = require('data.json');```
I am trying to use deferred promises to let multiple cache misses of the same object resolve to the same promise (and hence not loading the cache object multiple times)
Now when loading a guild with multiple events (messages) at the same time, the guild cache guild.appData will build up. Each event will await the same promise, and as soon as it is finished, the cache should be loaded. The promise then is resolved for all of the events' calls and the cache guild.appData can be accessed from everywhere.
Somehow this principle does not work for roles. I can only access the appData property for the event that triggered the promise-creating in the first place. role objects from other events that came in during the cache loading will not have the property appData stored. However, all events after the cache has loaded, will be able to access the property.
A solution could be not simply letting the promise resolve with nothing, after the cache has loaded, but return/resolve the cached object itself.
Or is there a way to maybe "refresh" the role objects in those events, that follow-up the first event?
What do you think?
so guild.me might not exist, but if it doesnt does await guild.me.fetch() work? or must i manually fetch with the member manager
(discord.js)
You have to fetch from the member manager
ok
I keep getting this error in discord.js:
(node:4) 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: 6)
Can't send code since it's way too long
I need tim 😫 please ping me when he's here 😄
you could just ping him lmao
wait, guild.me might not exist? how?
surely every client has access to its own client?...
also: most important development question of the day:
Do i call my new bot GameBOT, or Arkade/Arcade ?? Any thoughts?
const Discord = require('discord.js');
const client = new Discord.Client();
const config = require('./config.json');
const blacklisted = require('./blacklisted.json');
const fs = require('fs');
const Enmap = require('enmap');
const client = new Discord.Client({disableEveryone: true});
client.commands = new Discord.Collection();
// Command Handler
client.on('message', async(msg) => {
if(msg.author.bot) return;
if(!msg.guild) return;
})
//Bot Login
client.login(config.token)
This is my code, I have a file for blacklisted users (i am updating my bot to v12) and I want to add under if msg.author if the users id is in blacklisted.json to return nothiing
how would I go about doing this
step 1: get a real database (optional, highly recommended)
step 2: convert your blacklisted user ids into an array
step 3: check if that array includes the desired user id.
const fortnite = require('simple-fortnite-api')
const fnclient = new fortnite('');
const { MessageEmbed } = require('discord.js')
const { stripIndents } = require('common-tags')
module.exports = {
name: "fortnite",
description: "fortnite stats",
execute: async(client, message, args) => {
if(!args[0]) return message.channel.send("Please supply a username.");
if(args[1] && !["lifetime", "solo", "duo", "squad"].includes(args[1])) return message.channel.send("Usage: `fortnite <username> <gametype>`\nGameTypes: Lifetime, Solo, Duo, Squad");
let gametype = args[1] ? args[1].toLowerCase() : "lifetime";
let data = await fnclient.find(args[0])
if(data && data.code === 404) return message.channel.send("Unable to find a user with that username.")
const { image, url, username } = data;
const { scorePerMin, winPercent, kills, score, wins, kd, matches } = data[gametype]
const embed = new MessageEmbed()
.setColor("RED")
.setAuthor(`Epic Games (Fortnite) | ${username}`, image)
.setThumbnail(image)
.setDescription(stripIndents`**Gamemode:** ${gametype.slice(0, 1).toUpperCase() + gametype.slice(1)}
**Kills:** ${kills || 0}
**Score:** ${score || 0}
**Score Per Min:** ${scorePerMin || 0}
**Wins:** ${wins || 0}
**Win Ratio:** ${winPercent || "0%"}
**Kill/Death Ratio:** ${kd || 0}
**Matches Played:** ${matches || 0}
**Link:** [link to profile](${url})`)
.setTimestamp()
message.channel.send(embed)
}
}``` i get this error when i try to start the bot https://hastebin.com/ekusigider.sql
I plan to switch to SQL, I havent coded in js in a long time so I have no idea what ur talking about
and json will be fine since I will be hand picking users
@Nerd you should probably remove that string that im certain is a key/token for your fortnite api access
@radiant estuary show your code
i copy and pasted things into the code, that I dont want to add 😄
@radiant estuary don't copy and paste duh
write your own code
and unless you're trying to get the entire bootstrap stylesheet you shouldn't be copy and pasting code
i regenned it
how do i enable non-interactive mode in psql?
every time i try to use -1, it says: psql: fatal: -1 can only be used in non-interactive mode
i haven't been able to find anything from googling
its a strange world we live in, where people are proud to be weeb simps 😄
I get this error
this is my code
I dont get how name is undefined when its any
props.help doesnt exist
prob
okie
ty
Hi uh just a general question, sorry if it is the wrong place, what is super() inside a class, and how would I use it, (I'm a bit confused by it)
let me ask you
does it look like this?
constructor() {
super('volume', 'music', ['vol', 'v']);
}
Ola
super is used to call a function from the parent class of the current class
Tudo bem com vcs
super is used to call a function from the parent class of the current class
@neat ingot wdym by that
do you know what classes are?
then you should know inheritence as well
class example {
constructor(h){
this.h = h
}
//functions and stuff
}```
I am not sure about that
classes can inherit properties from other classes. when it does this, the class that was inherited is called the parent class. super allows you to call functions exclusively from the parent class
so like this?
ohhhhhhhhhhhhhhhhhhhhh
That makes much more sense
So what about in this context
super(length, length);
that would call the parent class's constructor method whilst passing length property as the first two arguments to said parent class function.
ok so im getting an error about something that doesn't exists.....
that would call the parent class's constructor method whilst passing
lengthproperty as the first two arguments to said parent class function.
@neat ingot umm, so it would be like doing new Rectangle()
pretty much
ok so you call the constructor inside a constructor that extends the original
except that, its not creating a new object, its altering the existing instance of the Square class
and use functions from the original constructor
that makes more sense
so say if I wanted to extend the discord client I could do this
class CustomClient extends Client {
constructor(token){
super()
this.token = token
}
super.login(this.token)
}```
?
i want to say yes? but for some reason that i cannot put my finger on, i feel like it not correct syntax 😄
is that not the right way to do it?
no it is, i've just never tried to call a function from the superclass within the constructor of the child class in javascript 😄
Oh yeah I just wrote that now so
i preffer to do my classes 'the old way' in javascript, it feels more explicit imo
if you want an example i can give you one...
class CustomClient extends Client {
constructor(token){
super()
this.token = token
}
connect(){
super.login(this.token)
}
}
new CustomClient("TOKEN").connect()``` Like this?
nah you were more correct the first time. that way the login would never get called and may throw error
ok yea that should work
ok
One message removed from a suspended account.
you clearly cant be bothered to fix it either
One message removed from a suspended account.
One message removed from a suspended account.
class CustomClient extends Client {
constructor(token){
super()
this.token = token
}
connect(){
super.login(this.token)
}
}
new CustomClient("TOKEN").connect()``` Like this?
@golden condor yeah thats correct
super just refers to the class which your class extends
One message removed from a suspended account.
super as a function is equal to new ClassYouExtend()
One message removed from a suspended account.
Great thanks for the help guys, and thanks for being really nice and helping out <3
665217134275854357
client.on("ready", () => {
let activities = [ `${client.guilds.cache.size} servers | ${client.users.cache.size} users`, `${default_prefix}invite | Invite me`, `${default_prefix}support | My server`, `${default_prefix}donate | Donate me`, `${default_prefix}info | About me`], i = 0;
setInterval(() => client.user.setActivity(activities[i++ % activities.length], { type: 'STREAMING', url: 'http://twitch.tv/mrskewer' }), 5000);
});
client.on("guildCreate", () => {
let activitiesCreate = [ `${client.guilds.cache.size} servers | ${client.users.cache.size} users`, `${default_prefix}invite | Invite me`, `${default_prefix}support | My server`, `${default_prefix}donate | Donate me`, `${default_prefix}info | About me`], i = 0;
setInterval(() => client.user.setActivity(activitiesCreate[i++ % activitiesCreate.length], { type: 'STREAMING', url: 'http://twitch.tv/mrskewer' }), 5000);
});
I have set a state on my bot that changes every 5 seconds and contains the number of servers it is on. I want to update these counters every time the bot is added or removed from a server. I tried this code, but it doesn't work since the two setinterval overlap. How do I fix it?
665217134275854357
@flat vine this guy's called discord bot maker
@balmy knoll introduce global variables instead
so that you could simply update these variables accordingly without disrupting the current setinterval
@balmy knoll for the ready event, whatever the size of the collection is is what will be displayed as your status as it's saved. Aka ${client.guilds.cache.size} servers will always be the original number at the start of when the event was fired.
I don't quite understand. How could I fix it?
really all you need to do is update the activity in the ready event once then update it for every new guild created or deleted with a rate limit.
I don't understand. Can you explain with example codes?
for example client.guilds.cache.size is a variable that changes depending on your server count
you just have to keep the onready event and remove the guild create one
because of the setinterval. the client.guilds.cache.size changes if a guild is added
what do I do
it says there is a error within the downloaded mongoose
you.. read what it says
I know but the error is in the module downloaded
man
it tells you
what link to go to
and that will tell you how to fix it
please read the fucking error message
why be so rude cuck head
why be not able to read 
he is just speaking facts lol
if you get pissed off from people asking for help dont help
i get pissed off from people not reading whats literally in front of them

The answer is right infront of you?
read it again :>
<body>
<style>
body {
background-color: #2F3136;
text-align: center;
color: white;
font-family: Arial, Helvetica, sans-serif;
}
h1 {
background-color: #2F3136;
text-align: center;
color: white;
font-family: Arial, Helvetica, sans-serif;
}
div {
background-color: #2F3136;
text-align: center;
color: white;
font-family: Arial, Helvetica, sans-serif;
}
</style>
<h1 style="text-align: center;">
Meltin*[BOT]
<p>le bot discord de la guilde Meltin*pot !</p>
<p>Il est fait pour les joueurs de NosTale FR.<br />Il est utilisé pour modérer des serveurs de familles.
<br />Il est présent sur plus de 60 serveurs à ce jour !<br />Tu est fatigué de chercher les plans des ts/raids ?<br />Tu veux simuler des tentatives de up et de craft ?<br />Montrer à tout le monde ton rang dans le classement ?<br />Afficher les tableaux des parfums, tarots, livres ?<br /><br />Ce bot est fait pour toi !<br /><br /><br />
</p></h1>
<img src="https://www.aht.li/3512102/mb2.png" alt="meltinbot" style="width:668px">
</body>
all of 3 pics show you the answer
@earnest phoenix and what exactly isnt working?
the white color for the text
and also, i don't know how to center the text
Diggy, dont star it. No context 😬
define p in your css
since p if the text
*-*
plus, h1 should be closed accordingly
apologies
and p should be closed too
so not
<h1>my cool header
<p>my cool text under the header
</p>
</h1>
but like this:
<h1>My cool header</h1>
<p> my cool text</p>
<body>
<style>
body {
background-color: #2F3136;
text-align: center;
color: white;
font-family: Arial, Helvetica, sans-serif;
}
h1 {
background-color: #2F3136;
text-align: center;
color: white;
font-family: Arial, Helvetica, sans-serif;
}
p {
background-color: #2F3136;
text-align: center;
color: white;
font-family: Arial, Helvetica, sans-serif;
}
</style>
<h1>Meltin*[BOT]</h1>
<p>le bot discord de la guilde Meltin*pot !
<br />Il est fait pour les joueurs de NosTale FR.
<br />Il est utilisé pour modérer des serveurs de familles.
<br />Il est présent sur plus de 60 serveurs à ce jour !
<br />Tu est fatigué de chercher les plans des ts/raids ?
<br />Tu veux simuler des tentatives de up et de craft ?
<br />Montrer à tout le monde ton rang dans le classement ?
<br />Afficher les tableaux des parfums, tarots, livres ?
<br /><br />Ce bot est fait pour toi !</p>
<img src="https://www.aht.li/3512102/mb2.png" alt="meltinbot" style="width:668px">
</body>
It's almost that
I put white for the title, it stays gray
And the white background, I can't find of how to make it gray
i tryed with div and background but that wont work 🤣
@sudden geyser Wait
@earnest phoenix use inspect element for the background
me my friend making a bot together right
so we have this for guildmemberadd function
var autorole = db.get(`autorole_${message.guild.id}`)
if(autorole === null) return;
member.addRole(autorole)
});```
why is this erroring with
what's the error
addRole undefined
there is no function called addRole in guildmembers
what am i able todo as an alternative to get it working
you would need to use member.roles.add
@turbid bough it dosent give an error but it dosent add the role
would that have todo with my autorole command
nun
@astral yoke the first argument of the guildMemberAdd listener is the guild member.
as for addRole vs. roles.add, that depends on your version.
i have it
How would you get the message in the first place?
but i dont konw if its getting it correctly
how do you know
the message is for message.guild.id because it was undefined
https://tryitands.ee
@earnest phoenix this is the best response
Hope, I managed to change the color by inspecting the element, but not in my css
show your css
It annoys me even more 🤣
Wait what are you trying to do
h1 {
background-color: #2F3136;
text-align: center;
color: white;
font-family: Arial, Helvetica, sans-serif;
}
p {
background-color: #2F3136;
text-align: center;
color: white;
font-family: Arial, Helvetica, sans-serif;
}
body {
background-color: #2F3136;
}
now show how you changed it in the inspector
U need to do
}```
man... call of duty really needs to fix their shit :/
@neat ingot wrong channel
It's super neat now. thx again
@zenith terrace idc, the off topic channel here is filled with absolute trash lol.
and it was just an offhanded comment, not trying to get a whole discussion on it or anything
Tim could you check please please https://discordapp.com/channels/264445053596991498/272764566411149314/714544089672056924
@viral spade how do you define roles before the for loop?
its msg.member.roles.cache
if its roles.cache, then the loop shouldnt even work
for(let role of roles.cache) {
console.log(role) // [3075803708733,Role]
}
it does work
its roles.cache but with the second index extracted
thats why i asked, how did you extract it?
i tried it both ways. first with for (role of msg.member.roles.cache) { role = role[1]; ..}
then with extracting first msg.member.roles.cache.forEach(role => roles.push(role));
both with same result
when i tried resolving the object itself all worked fine
try doing let role instead of role
not declaring it in a for of loop sometimes produces weird results
right, i had that too sometimes. ill try
again, i can only say youre a god..
thank you so much
i think i need to change many for loops 😅
also, is it ok to load the cache for roles that way? (as roles are not that many i guess its ok)? I could also on guild cache load add a field "noXpChannelIds" to the guild cache
the code is the on message code which gets executed almost every time a user writes a message
ctype?
ctype?
@earnest phoenix a compiled lib usually written in c (not so much now) or c++ which scripting languages use to help speed up tasks
uhm
well yes node.js does sometimes use compiled modules. not even to "speed up" a lot of the time
a lot of the time it's just to access c libraries (curses maybe) or to access other system stuff
Nice to know
browsers have support via wasm modules
Tim how's your lib coming
its on hold indefinitely atm
feelsbad
i start digging too much
went from discord to zlib shenanigans
making a zlib sync lib
idek what zlib is tbh
compression and decompression
discord supports zlib compression
when you enable it, you use 80% less bandwidth
in exchange for like 1% more cpu
its stupidly efficient
so they compress the packets or something?
they have two options
packet compression and stream compression
stream compression is a bit better/faster
packet compression is easy to implement
i gave it here where is the users id is not in "owners" in a json file it blocks it from a command, but I want the opposite affect how do i do this
remove the !
thats it
! means "NOT"
it inverts whatever you put in front of it
your code basically says "if not includes"
ahh thank you very much
if you remove it, then it says "if includes"
awesome
thank you very much
@gilded plank
@earnest phoenix pinging luca why?
hey, anyone know if there is a bot for adding or deleting permissions for every roles in a server ?
nope theres none
really ?
maybe dyno could do that, though look on top.gg yourself
I cannot decide what to name my new bot :/
literally spent hours trying to decide lol
i just use my name in it and just brainstorm the fuck out of my time
my last/first bot was 'DekBOT', i dont think Botita would work for this new bot 😛
i have two names i think fit the bot well: G4M3B0T and Arkade just cant decide which one i want to go with
Arkade sounds quite nice in my opinion
i do feel the way i've spelled gamebot is shit for search queries
@earnest phoenix wdym?
arkade is too basic and G4M3B0T too complicated to write
what test? you just do the application ~ the test is if it works when they go to apprrove it 😄
@earnest phoenix just do join logs
you should be good with that
and you'll see if you get a notification that it joined discord bot list
try to get 20 upvotes fast. you will get on the front page for a few days
dont bot your votes tho 
how come you think arkade is too basic? i thought it seemed kinda cool
@neat ingot no i mean it sounds nice
But how do I get them to test it?
@earnest phoenix They get added to a secret server for testing
nah, linck said it was basic 😛
they will test through your commands if they follow the #rules-and-info, ratelimiting guidelines and tos
you cant
they will add it once it is your bots turn for approval
^ fill that in, wait for weeks, hope.
they submitted it already i reckon
probably, but you never know 😛
i mean, some of the questions that get asked in here...
Would this be a good icon for a bot that's based off a Griffin?
@earnest phoenix - I'm a bit late to the party but that's wicked
ok so :U anyone here verified their bot?
most people yeah, why?
im on exactly 75 servers and nothing's showing up
it shows up at 76
:U
bruh discord is a lier
gotta wait a day i guess lmao
thanks
once your bot surpasses 75 servers
meaning 75+
y discord lier meen
waiting for rozette
like 1m year
This process is currently available for bots in 75 or more servers
75 or more
this is official discord page, mind u
or
not exclusively more than
i havent even bothered verifying my bot yet
dont trust stripe tbh 😄
ik imma have to, but yea...
hey how do I add an options object to guild.createchannel in js
its nopt on the docs
// Create a new text channel
guild.channels.create('new-general', { reason: 'Needed a cool new channel' })
.then(console.log)
.catch(console.error);
``` one of its examples
okay thanks
the other useful stuff is mentioned on the .create method in the docs 
i dont keep up with updates so i missed that
TypeError: reaction.message.guild.channels.create is not a function
are the permission overwrites like this js permissionOverwrites: [ { id: message.author.id, allow: ['VIEW_CHANNEL'], }, { id: message.guild.id, deny: ["VIEW_CHANNEL"] }, { id: "693623178253041775", allow: ["VIEW_CHANNEL"] }, ],
wait
give mne as ec
erm im accessing the message through the reaction and the guild through the message
is that wrong
imagine being able to develop a bot 😭
@keen vapor you can always start learning it
so would i have to access the guild by getting it through the client?
presumably yeah, though since i only learn through the docs, i dont really know
oh wait
okay thanks
reaction.message.guild.create(`${type}-${user.username}`, {
type: "text",
permissionOverwrites: [
{
id: message.author.id,
allow: ['VIEW_CHANNEL'],
},
{
id: message.guild.id,
deny: ["VIEW_CHANNEL"]
},
{
id: "693623178253041775",
allow: ["VIEW_CHANNEL"]
},
],
}).then(channel => {
bot.ticket.set(user.id, {
userID: user.id,
channelID: channel.id
})
})
im using discord.js 11.5.1
should I update
11 will be deprecated sooner or later, so i'd suggest to do so
okay
and it is reaction.message.guild.channels
thanks
for my guildCreate file
i have this right
const RichEmbed = require('discord.js')
module.exports = async (bot, guild) => {
const getDefaultChannel = (theGuild) => {
if (theGuild.channels.has(theGuild.id)) return theGuild.channels.get(theGuild.id);
const generalChannel = theGuild.channels.find(channel => channel.name === "general");
if (generalChannel) return generalChannel;
return theGuild.channels
.filter(c => c.type === "text" &&
c.permissionsFor(theGuild.client.user).has("SEND_MESSAGES"))
.sort((a, b) => a.position - b.position ||
Long.fromString(a.id).sub(Long.fromString(b.id)).toNumber())
.first();
let embed = new RichEmbed()
.setDescription(`Hello! My name is DogBot. Thanks for having me here! Use these configs!
db!welchannel <#channel> | Set a channel for DogBot to welcome!
db!byechannel <#channel> | Set a channel for DogBot to log leaving!
db!modlogchannel <#channel> | Set a channel for DogBot to modlog!
db!setprefix (prefix) | Set a prefix!
db!deleteconfig (welcome, goodbye, modlog) | Delete a logging!`)
generalChannel.send(embed)
}
}
anyone know why it dosent work?
it dosent error but dosent send it neither
did you ever call the function.
and do a few debug lines
also are you not returning a bit too early
@astral yoke const RichEmbed = require('discord.js')
i think you're trying to . do js const { RichEmbed } = require('discord.js')
I really wished they'd add named exports to DJS
ill try
assuming you're working with djs v11
mhm
So that we could import { MessageEmbed } from 'discord.js';... Instead of:
import Discord from 'discord.js';
const { MessageEmbed } = Discord;
@earnest phoenix for the .create options. how do u specify the category?
ok so
doing the verify thing
it says the answers must be at least 100 chars
wat
11 will be deprecated sooner or later, so i'd suggest to do so
@earnest phoenix - They will have to upgrade before October
how to say "no" in 100 chars
console.log( `n${ 'o'.repeat( 99 ) }` );
11/10
ah
i mean
@empty owl lemme check
will they accept that
are you talking about discord verification?
yea
probably not then
did .u find the answer
still lookin
They musta added that later. I literally said, "Nope."
what was the question
I'm assuming that's the, "Do you store any Discord data, etc."
oh lmao
yea whyyyyy
wait
Or do you need intents etc
for the Do you store any Discord data, etc if u store ids for a database do u have to say tahta
Infrastructure should 100% be 100+
stev tis this one
@empty owl you could use https://discord.js.org/#/docs/main/stable/typedef/ChannelPosition maybe
I said, "Users are free to DM me"
not the infrastructure one
just put a email @earnest phoenix
Literally that
or a support srever
😠
thanks hope
yea well i have like
oh just link the support server i guess
whatever seems filler enoughx
xd
They don't want an essay for stuff like that
well yea but 100 chars is a lot
like fr why cant i just say "no" or whatever
anyway im kinda dumb so when they say infrastructure what exactly do they mean
hardware? and libraries?
the system your bot runs on
just give them pc spex for the lolz
infrastructure: 1 core 1gb ram
nah i have enough
lol
gtx 69o :p
anyway im kinda dumb so when they say infrastructure what exactly do they mean
@earnest phoenix - I'm using Discord.js. It's running on a VPS provided by Vultr running Ubuntu vx.x.x.x. MySQL vx.x.x.x. Node vx.x.x. Etc
Helps. They don't want you using something with vulerabilities
if your running mongodb to store things, it doesnt matter the version
well yea i guess thats fair
but there are vunerabilities in thousands of things, and all database libs
Yeah so just mention that you regularly audit when they ask about security
mongo: https://www.cvedetails.com/product/25450/Mongodb-Mongodb.html?vendor_id=12752
sql: https://www.cvedetails.com/vulnerability-list/vendor_id-185/product_id-316/Mysql-Mysql.html
Mongodb Mongodb security vulnerabilities, exploits, metasploit modules, vulnerability statistics and list of versions
Security vulnerabilities of Mysql Mysql : List of all related CVE security vulnerabilities.
CVSS Scores, vulnerability details and links to full CVE details and references.
i could do on..
im using litedb
clearly
best db
ok so its a kinda niche bot so doesnt have to scale well anyway
hey guys. Sorry to bother. Do you know where i can find on docs something like "get the user who invited the bot"? Cause i did not find anything (discordjs)
whatever sent the form
ty
can you find out the user who invited???
@ancient lichen - Redirect URI, yeah
@ancient lichen theres no endpoint that could tell you who exactly invited the bot
idk if you can, it'd be neat if you could
redirect url shouldnt give user ids out like that i dont think
cause i want to send a pm to the people who does
but i guess most bots cant access audit log
Ofc they do
How do I calculate the total number of members my bot serves?
@earnest phoenix
you can specific that the bot needs audit log perms
it still returns bot.guilds.get(...).create is not a function
@empty owl what version of djs are you on
bot.guilds.get("692557750940598323").create(`${type}-${user.username}`, {
type: "text",
parent: "714633231030419566",
permissionOverwrites: [
{
id: message.author.id,
allow: ['VIEW_CHANNEL'],
},
{
id: message.guild.id,
deny: ["VIEW_CHANNEL"]
},
{
id: "693623178253041775",
allow: ["VIEW_CHANNEL"]
},
],
}).then(channel => {
bot.ticket.set(user.id, {
userID: user.id,
channelID: channel.id
})
})
i updated to 12.2
wait
bot.guilds.cache.get()
i didnt
discord has no reason to include a user id in the redirect url cause when they rediurect to their site, the user is logged in automatically via cookies.
oh
@earnest phoenix - Supplying redirect URI will return whatever data you ask for. Username, ID, discrim
i mean, they might, but thats a bit of a security breach imo
@empty owl you forgot the .channels after the get
gotit
It's no different than using OAuth to log into Top.gg
Gives them your ID/username, etc
On redir
when I update to 12.2.0 i get } catch {
^
SyntaxError: Unexpected token {
full error
lemme try 12.2.0
i mean, they might, but thats a bit of a security breach imo
@neat ingot - You can't just put any URI. It has to be one added in your own dev portal
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/rbd/pnpm-volume/360bef0c-b00e-4b72-bb55-b5b0a5690682/node_modules/.registry.npmjs.org/discord.js/12.2.0/node_modules/discord.js/src/index.js:8:11)```
can you send the codeblock from line 41 of your Client.js
i dont have a client.js
even if it did include that information
oh that an actual discordjs error
How do I calculate the total number of members my bot serves?
@gritty bolt
your bot doesnt recieve that redirect
@gritty bolt what lang
@empty owl can you try updating your nodejs version
okay
discord.js
if js bot.users.size
your bot doesnt recieve that redirect
@neat ingot - Your server does?
Forward that info to the Discord client
hmm maybe it could i guess
catch (e)? @empty owl
what
idek tbh
that still feels like a breach of security to me
so i can just do const userCount = bot.users.size()? @empty owl
what does? @neat ingot
Not at all - that's how OAuth works. Lol
yea
if you dont need the info dont use oauth
being able to have your client listen for who added all bots in your server? you dont think thats a breach? i do.
there is no } catch {
simple as that
oh
weird
np
Your bot knows the guild and all members, channels, topics, etc in the guild
only those its given accesss to*
how come this dosent work with the error TypeError: serverQueue.connection.play is not a function
i mean, idc either way tbh, it just seems like they would want to hide that data as much as possible
cant u set oauth scopes
updating node works
and just letting anyone get access to that data, that in itself is a seecurity concern if not a breach.
if u cant just tell discord to up their game
updating node works
@empty owl yeah someone had that problem too, thats why i thought updating node might help
yea hes saying that the bot can pick up who invited the bot to the server
well as people have said if u usin oauth it's because you need that data no?
the bot wouldnt have your login oauth when your adding the bot via link
like, it'd have your bot clients login, sure, but not the login details from your web browser where you clicked the link
Not login details. User ID and username
Same as gets supplied when you log into Top.gg
ty
do you have an example of how your bot would get that information after the fact?
like, an example of getting the username of who invited the bot?
oh wait
now the messageReactionAdd doesnt trigger
Identify scope + bot
...
- Redirect uri
(That URI is an example and will 404)
so yea it needs scopes
so then not your bot, but your website
and it will say on the invite page
your website url would get that call
your website generally is your bot
and you would have to forward it to your bot
well i guess
If your website has guild counts or anything else, it's connected to the Discord bot
i also have raw events on
my website has that data, it is 100% not part of the bot
well i mean yeah
my bot sends pings to my website ip with that data like it does to top gg
with proper authorization right 
ofc
i have raw events on
but yes, you have to forward oauth data to bot
bot.on('raw', packet => {
// We don't want this to run on unrelated packets
if (!['MESSAGE_REACTION_ADD', 'MESSAGE_REACTION_REMOVE'].includes(packet.t)) return;
// Grab the channel to check the message from
const channel = bot.channels.get(packet.d.channel_id);
// There's no need to emit if the message is cached, because the event will fire anyway for that
if (channel.messages.has(packet.d.message_id)) return;
// Since we have confirmed the message is not cached, let's fetch it
channel.fetchMessage(packet.d.message_id).then(message => {
// Emojis can have identifiers of name:id format, so we have to account for that case as well
const emoji = packet.d.emoji.id ? `${packet.d.emoji.name}:${packet.d.emoji.id}` : packet.d.emoji.name;
// This gives us the reaction we need to emit the event properly, in top of the message object
const reaction = message.reactions.get(emoji);
// Adds the currently reacting user to the reaction's users collection.
if (reaction) reaction.users.set(packet.d.user_id, bot.users.get(packet.d.user_id));
// Check which type of event it is before emitting
if (packet.t === 'MESSAGE_REACTION_ADD') {
bot.emit('messageReactionAdd', reaction, bot.users.get(packet.d.user_id));
}
if (packet.t === 'MESSAGE_REACTION_REMOVE') {
bot.emit('messageReactionRemove', reaction, bot.users.get(packet.d.user_id));
}
});
});
``` this taken from diuscordbotguide thing

also that screenshot i posted. thats the endpoint for the requester that the bot gets access to
anyway
from people with similar problems
100% not a security issue
because it's listed very clearly when you're inviting the bot
Reaction to a message that's not cached
Which you'll need both message and reaction partials for
wait but if i have raw events on doesnt it not matter if its cached or not
wdym
i mean i guess if you have raw events most of the time you'd already have the message???
what
idk
hi um this no work
it dosent give me an error and it does everything legit but it just dosent play
-botcommands
Hey! Bots aren't given permissions to send responses in this channel. Please use #commands or #265156322012561408 to run commands. In addition, bots with commonly used prefixes cannot read or send messages in any channel. This is done to prevent spam and bot abuse.
Guy since i am very new to coding anyone can help me quick isnt it for changing the bot status something like this?
bot.on('ready', () => { bot.user.setStatus('available') bot.user.setPresence({ game: { name: 'with depression', type: "STREAMING", url: "https://www.twitch.tv/monstercat" } }); });
any error logs?
nope 😦
there has to be an error
Hmm it dont show me an error
you're missing a semicolon at the end of bot.user.setStatus('available')
v12
Replace game for activity: https://discord.js.org/#/docs/main/stable/typedef/PresenceData
You can also set the status (online/idle/dnd/offline) in setPresence so bot.user.setStatus('available') is unnecessary/doesn't do much anyway.
@sudden geyser Thank you ❤️ Now its working
How to check my bots all servers list
in,?
So anyone know how to make a login/register for html/css.
?
Wdym? Im talking about a form
😑
Ok ill give a example of what i mean
Everyone ignored the 😓
can you give me the structure
make a loop?
@pale vessel can it be in the morning or when u get on discord in tomorrow im not on my pc. I asked because i was wondering just to get a idea
that would be Object.keys(obj)
@cosmic girder i can show you lol
Rn?
when did djs v12 come out again
<form>
<input type="text" id="username" placeholder="Username" />
<input type="password" id="password" placeholder="Password" />
<button type="submit">Login</button>
</form>
<style>
form, input, etc {
/* styling */
}
</style>
forms are really basic
also doesn't that only give the name @pale vessel or
Oh ok ty, i needed that for my website that i have for my bot its setup but i want to make a login/register .
Oh and is there any way that its like Sign In With Discord And ot signs you in with ur discord.
oauth
oh well luckily i was just working on the exact same thing
Oh ok pretty simple
https://discord.com/developers/docs/topics/oauth2 this page will help u
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Ty
lmao "pretty simple" yet you don't get the basics of html
solid advice tho, use auth code instead of implicit
@sick cloud i do tho ill show all my code in html its just the form format is tricky
you can't-
@valid frigate v12 has been in development for years but it got pushed to stable in march
:bruh:
what
crazy how its been in development for years
actually no clue what they did but im checking out the repo cuz it looks interesting
d.js next soon xd
you can't create an oauth implementation just with html
ya don't say
well
actually the djs guide had a tutorial on how to implement oauth without a backend server
yes
implicit grant
poop stinky
they do go on to explain later how to use the more traditional flow but its funny lol
considering that a lot of people start out there without learning it properly
is a horizontal style like this better
sure
thats a pretty standard way of doing it
Does anyone know how to scale a bot? I want to start a bot but I don't want to make it to where it could have 100k servers and I have no idea how to scale it to multiple servers.
depends what lib
wouldnt that be premature optimization
i'll move to element later ¯_(ツ)_/¯
@sick cloud I'm using discord.js
idk if this is development per say but what is a discord bot dashboard
Are you talking about creating one for your bot or like the dashboard for you bot on discord.com?
a discord bot dashboard is simply a place where users can edit how ur bot behaves on servers they own
mee6.xyz is a good long standing example
mee6 stinky
@desert orbit kurasuta maybe
is it like about yo'ur bot?
we just said what it is lol
okay thank you
ty imma look into that
dumb design question time, search icon is for search and moon(goes to sun) is for light dark switcher
should it be search moon or moon search (positions)
var Owlbot = require('owlbot-js');
var owlclient = Owlbot("");
const { MessageEmbed } = require('discord.js')
module.exports = {
name:"define",
description: "get a defintion",
execute: async(client, message, args) => {
let word = args.slice(0).join(" ")
if(!word) message.reply("What word are you defining")
if(word) {
owlclient.define(word).then(function(result){
let data = result
let embed = new MessageEmbed()
.setColor("RED")
.addField("Definition", data.definition)
message.channel.send(embed)
});
}
}
}```when i do _define hello it sends the embed but it says undefined under definition
k
{
0|npm | pronunciation: 'həˈlō',
0|npm | definitions: [
0|npm | {
0|npm | type: 'exclamation',
0|npm | definition: 'used as a greeting or to begin a telephone conversation.',
0|npm | example: 'hello there, Katie!',
0|npm | image_url: null,
0|npm | emoji: null
0|npm | },
0|npm | {
0|npm | type: 'noun',
0|npm | definition: 'an utterance of â; a greeting.',
0|npm | example: 'she was getting polite nods and hellos from people',
0|npm | image_url: null,
0|npm | emoji: null
0|npm | },
0|npm | {
0|npm | type: 'verb',
0|npm | definition: 'say or shout â',
0|npm | example: 'I pressed the phone button and helloed',
0|npm | image_url: null,
0|npm | emoji: null
0|npm | }
0|npm | ],
0|npm | word: 'hello'
0|npm | }```
@sick cloud it says this
wait what do i do
then there you go
definition is undefined because there's multiple
you could do either data.definitions[0].definition or map and show them all
oh
now this happens
0|npm | (node:58669) UnhandledPromiseRejectionWarning: Error: timeout of 5000ms exceeded
0|npm | at createError (/root/bot/node_modules/owlbot-js/node_modules/axios/lib/core/createError.js:16:15)
0|npm | at Timeout.handleRequestTimeout [as _onTimeout] (/root/bot/node_modules/owlbot-js/node_modules/axios/lib/adapters/http.js:217:16)
0|npm | at listOnTimeout (internal/timers.js:549:17)
0|npm | at processTimers (internal/timers.js:492:7)
0|npm | (node:58669) 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: 4)
how can i stop this
get a better host
i use digital ocean
modify the lib's timeout then
how to do that
add a .catch
thats not going to do anything
it helps with the exception
but they don't want the exception at all
why doesnt this work im trying to learn coding for discord bots:
const Discord = require('discord.js')
const client = new Discord.Client();
client.once('ready', () => {
if (message.content === 'jsbot') {
message.channel.send('Ree');
});
client.on('message', message => {
if (message.content === 'jsbot') {
message.channel.send('Ree');
}
wait
thats not it
one sec
that is it
is that everything? Do you login with your bot
yes
client.login(Token)?
yes
Well, inside your ready function, you have message but message is not defined in there
Also you are missing a }
where?
And a )
so
Your editor should tell you this
why doesnt this work im trying to learn coding for discord bots:
const Discord = require('discord.js')
const client = new Discord.Client();
client.once('ready', () => {
if (message.content === 'jsbot') {
message.channel.send('Ree');
});
client.on('message', message => {
if (message.content === 'jsbot') {
message.channel.send('Ree');
})}
im using notepad bc im on laptop and its already slow enough xD
im testing it on my pc and typing the code on my laptop
but is that code right?
@sick cloud exactly
It's not
i got it
visual studio code is pretty lightweight
client.once('ready', () => {
if (message.content === 'jsbot') {
message.channel.send('Ree');
});
ok yeah thats not how this works at all
missing }, wrong event entirely
wrong event, and the event is already on the code under that part
!!help
@earnest phoenix
Hey! Bots aren't given permissions to send responses in this channel. Please use #commands or #265156322012561408 to run commands. In addition, bots with commonly used prefixes cannot read or send messages in any channel. This is done to prevent spam and bot abuse.
best database for discord bots? i currently have one for guild settings (sqlite3 - enmap) and another for the economy (quick.db). i made the first one ages ago and didnt wanna interfere with it so i just got another db. should i combine them into one or just get a different db for both of them and transfer the data?
or do i already have a decent system going, idk much about databases.
thanks
mongo
There isnt rlly a best DB
^ true
not too big but as my bot gets more popular they will gradually increase
Mongo is easy to use and alot of people like it for that, but... its slow and requires caching. Postgres is Quick but requires SQL knowledge
ill look into mongo, thanks to both of yous
how to fix that the bot count the mention that by phone is multi arg?
as in the phone it will show like this:
@frozen willowample example#1234
by combining ClientUser#username and ClientUser#discriminator
how?
for example by using
message.channel.send(`${user.username}${user.discriminator}`)
something like that ig
dont take my word, i dont code in js
i just know how to read the docs
how can i check mentioned user badges ?
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
@earnest phoenix use user.user.tag
wrong method
thank you mobile very cool
oh they finally added the verified bot flag
nice
the flags on the user object from what you linked is only available when using oauth
and fetching the current user from the oauth token
i thought the verified bot flag was there all the time since it was added
nah i saw it just now
can i use node index.js > log.log 2> log_err.log in heroku ??
not sure
kk
dude i dont want to get ban xD
@pale vessel Now how i can read the log file :))
😢
you cant get banned from heroku for something you can enter in your console
they would restrict access to that if you couldn't
oof
shit
so I use vscode insiders with my js bot & pm2 and every time I save a file (like with ctrl+s) the bot restarts
whyy
happens with all the bots in the vps
maybe you have this on
@cinder patio but u have to pay to see ur logs
pm2 free version, give u only realtime logging
that was for Lumap