#development
1 messages · Page 1330 of 1
though for your situation, its recommended to use promises instead
@blissful coral
I know but like I am having brain farts on how to do them
ah ok
message.author
Litterly the message author
lmao
does anyone know the endpoint to get a guild role?
<message>.guild.roles.cache.get()
Eh
im not using a library
i cant find it in the docs so i just assumed i'd have to do it myself but im just here to make sure
😎

idk if you can even get just one role
Hey! I am trying to make dashboard, they have to login trought their discord account.
Now I want to make, that it joins the support server! How?
@earnest phoenix ?
I cant find docs
when they authorise themselves u want them to join ur server?
Or auto
button
const promises = [];
for (let i=0; i < some_value; i++) {
promises.push(new Promise((resolve, reject) => {
// do something with stuffs with callback
conn.query("some_query", (err, result) => {
// do stuff with result
if (some_condition) {
// found!
resolve(true);
}
else resolve(false);
});
}));
}
Promise.all(promises).then(values => {
if (values.some(found => found)) {
// actually found!!
}
else {
// ohnoes, not found!
}
});
@blissful coral
phew
typing this out
well

can't really solve this any other way
when they authorise themselves u want them to join ur server?
nutella?
basically you wrap the callbacks in promises
actually you can do this without promises as well
just have an array
and push the response
but still you need to wait
so uh
using the promise.all is probably a better option though
i'd do it similar to that anyways lul
is it good to host on heroku?
depends
after 550 hours, what does happen
idk
idk how heroku works but u shouldnt be working on a project for 550+ hours
what sql library you using @blissful coral
(assuming u get 550 hours per project)
is it good to host on heroku?
@vagrant prawn If you want a bot, no
If you want something like an API or DBL webhook listener, yes
@fluid basin mysql
conn.query("all_channel_in_guild", (err, results) => {
if (results.some(r => r.id === channel_id) {
// already exists
}
else {
// doesn't exist
}
});
Would that run before the rest is executed though
what can i use as database for heroku
no
they offer postgres I think
but it takes hours as well
but short answer: nothing
why no
yes
ok, thanks
@blissful coral i just do this for my callback stuff:
function someFunctionThatTakesACallback(callback) {
// do smth
// once it's finished run the callback
// with necessary parms
callback(1, 2, 3);
}
let lol = someFunctionThatTakesACallback(function() {arguments.map()});
(the arguments.map(); thing is an example)
wtf is that a void callback
@fluid basin well
It isn't running before?
const promises = [];
for (let i=0; i < channels.size; i++) {
promises.push(new Promise((resolve, reject) => {
// do something with stuffs with callback
connection.query(`SELECT * FROM config WHERE guildid = '${message.guild.id}' AND id = '${channelarray[i].id}'`, (err, result) => {
if (result[0] !== undefined) {
console.log(`Gotcha Bitch`)
resolve(true);
}
else resolve(false);
});
}));
}
Promise.all(promises).then(values => {
if (values.some(found => found)) {
console.log(`Actually found bitch`)
}
else {
console.log(`Not actually found`)
}
});
ok
don't need for loop too
Okay
I love that console
kek
vsc
wait why not using a loop?
It has to check for each one
because I am inputting 3 IDs at a time
So it needs to check all 3 and if one exists return
ah
how do i shard across multiple hosts?
then you just need to filter later
Multiple hosts?
yes
if (results.some(r => r.id === channelarray[i].id)) {
I mean
I can't do this here then
Because I don't have i
i doubt my bot will get big but i may as well try for fun
uh
const found = results.some(r => channels.includes(r));```
there ya go
.some will go through every item in results
and check if channels has (includes) the item
and stop when there is a first "true"
damn its just my bad obsession with 1-liners
so if (results.some(r => channels.includes(r)))
@blissful coral
okay

actually collection has a .has method
so you can just .has(r.id)
gosh
why me spooning so much rn
LOL
lmfak

prolly me
actually its more efficient
rather than query the db for the amount of entries you have
yeah i don't think serenity will do that at all
How do I simulate [0] in an object?
get the keys/values?
hmm
I have this code js db.once('open', function() { console.log(messageLink); const messageReminderConst = new messageReminderModel({user: user, messageLink: messageLink, time: global.time}); messageReminderConst.save(function(err) { if(err !== null) console.log(err); const data = schedule.scheduleJob(data.time, remindUser(data, bot)); console.log("Successfully saved reminder." + messageReminderConst); const successEmbed = new discord.MessageEmbed() .setTitle("Reminder saved sucessfully.") .setColor("#00FF00"); userObject.send(successEmbed) }); }); }); } });
I'm not sure how to define data, I want to make it the object that I just saved into the db
can anyone help?
i don't see why it wouldn't
serenity is an oddball of a library
instead of exposing all of the shard stuff like most libraries do (like a shard id offset), it does all of that for you
which isn't what you want
i don't see anything in the docs for a shard offset
let me check the shard manager
are you using Client @strong tundra
yeah i am
is there any way you can pass a ShardManager instance to it
(i haven't used serenity before so)
i'm not sure
if you can, you can do it
so, i dont know what i did, but it looks like that the collector.on("collect") event never triggers, no matter what, it seems that the regular message event is triggered instead. Anyone knows why?
because ShardManager has an offset
hmm
i only see an index, initial value, and total value
unless i'm misunderstanding?
ShardManager::new(ShardManagerOptions {
// ...
// the shard index to start initiating from
shard_index: 0,
// the number of shards to initiate (this initiates 0, 1, and 2)
shard_init: 3,
// the total number of shards in use
shard_total: 5,
// ...
});
these are the three you need
it doesn't seem to
just from the docs tho
can someone help with this? https://discordapp.com/channels/264445053596991498/272764566411149314/767037717636186112
because serenity automatically manages the shard index
you can't set it
which is required for clustering
my quick skim of start_shard_range is just starting a set of shards that the manager already has
but since serenity manages that for you, it's useless for this
it's preferable to have a separate shard manager that you can control
hmm
hi do you know how to make a command to see a member's pings and a serverinfo command
The Shard is transparently handled by the library, removing unnecessary complexity. Sharded connections are automatically handled for you.
this is the killing blow in the documentation
@stone thunder member ping dont exist
so you have to do some weird and wacky shit
serverinfo command learn your programmation language
hmm
the alternative that you do is that you let serenity manage all of your shards on each container
but then only start the ones that the container should be doing
so
Hey guys how to lock the nsfw cmd in nsfw channel
client.start_shard_range([ 10, 19 ], 999);
i'm not sure if you can get the shards that serenity thinks it needs for this
@clever vector check if the channel is nsfw (msg.channel.nsfw is true or not)
no you cannot
but yeah
it seems this is what serenity recommends for clustering
since the comment next to that method is This should be used when you, for example, want to split 10 shards across 3 instances.
No I mean I want to put like the nsfw have something the channel perm on the start
so you get the shard count that you need, then do an example of what i did
im trying to get a guild role and i cant seem to figure out how to get a guild role, any ideas?
im using v8
yea
v8? v8 of what?
py i would guess
oh
so if i were to split my bot among three instances, i could have a central thing that gives bots total amount and range and have serenity just take those values and start the cluster?
v8 dapi rest version
yeah
oh your getting it from the api itself?
ah that isn't too too bad then
if you get the shard count that discord recommends from the gateway
yeah
you can write a tool that autostarts the instances for you
take a couple of arguments as params
and you're done
ah cool thanks a lot
updating your bot is going to be fun though :p
@digital ibex https://discord.com/developers/docs/resources/guild
you update your central executable, kill all your instances and reboot them
the roles field
ah true
thats all the roles
however that would take ages on a massively clustered bot
is that a problem?
wdym?
hi
i dont think
i'll look at it
im not trying to get all the roles
im just trying to get one
let pkmns = [["Weedle", "https://bit.ly/3nX5gVk"], ["Kakuna", "https://bit.ly/2T0vzf9"], ["Beedrill", "https://bit.ly/3dAhUoi"], ["Pidgey", "https://bit.ly/3lXgbN2"], ["Pidegotto", "https://bit.ly/2H7689i"], ["Pidgeot", "https://bit.ly/2HbfgK7"], ["Scyther", "https://bit.ly/3k6lxFe"], ["Rhyhorn", "https://bit.ly/31xNG0L"], ["Rhydon", "https://bit.ly/3o3hvQ7"], ["Rhyperior", "https://bit.ly/3nZISum"], ["Horsea", "https://bit.ly/3nZITyq"], ["Seadra", "https://bit.ly/346t3dy"], ["Kingdra", "https://bit.ly/2HhEAxS"]]
let pkmnsImg = pkmns.map(item => item[1])
let pkmnsList = pkmns.map(item => item[0])
let pkmn = Math.floor(Math.random() * pkmns.length)
const embed = new Discord.MessageEmbed()
.setTitle("A wild pokémon has appeared!")
.setDescription("Guess the pokémon and type \`!catch <pokémon>\` to catch it!")
.setColor("YELLOW")
.setImage(pkmnsImg[pkmn])
bot.channels.cache.get(channel).send({embed});
let p = pkmns[pkmn]
if (args[0] === "catch") {
if (args[1] === pkmnsList[pkmn]) {
message.channel.send(`You have caught a ${pkmns[pkmn]}`)
}
else {
message.channel.send("That is the wrong pokemon")
}
}
when i type the correct args[1]
it doesnt send any msg
does anyone know why
i dont even get an error
@digital ibex as far as i can tell you cannot get just one role
from the api
you fetch all the roles, and get the one you want
ok
even discordjs seems to not get one role when you .fetch(roleID)
// We cannot fetch a single role, as of this commit's date, Discord API throws with 405
const roles = await this.client.api.guilds(this.guild.id).roles.get();
was just making sure cuz eris uses v7 and uses the role id/role endpoint which v8 doesnt have
thank
@strong tundra https://github.com/serenity-rs/distributed-worker-sample
might've already done the work for you
the sharder should be independent of the library
in theory it should always work
but yeah try that*
see if it helps
better to reuse than go from scratch
const fs = require('fs');
const port = 5500;
const DiscordOauth2 = require("discord-oauth2");
const oauth = new DiscordOauth2({
clientId: "",
clientSecret: "",
redirectUri: "http://localhost:5500",});
http.createServer((req, res) => {
let responseCode = 404;
let content = '404';
if (req.url === '/') {
responseCode = 200;
content = fs.readFileSync('./index.html');
}
res.writeHead(responseCode, {
'content-type': 'text/html;charset=utf-8',
});
const url = require('url')
const urlObj = url.parse(req.url, true);
if (urlObj.query.code) {
const accessCode = urlObj.query.code;
console.log(`The access code is: ${accessCode}`);
const access_token = `${accessCode}`;
oauth.getUser(access_token).then(console.log);
}
if (urlObj.pathname === '/') {
responseCode = 200;
content = fs.readFileSync('./index.html');
}
res.write(content);
res.end();
})
.listen(port);```
It gives me this error ``DiscordHTTPError: 401 Unauthorized on GET``
can anyone help me with this?
hmm how can i fix this?
if (args[0] === "catch") {
if (args[1] === pkmnsList[pkmn]) {
message.channel.send(`You have caught a ${pkmns[pkmn]}`)
}
else {
message.channel.send("That is the wrong pokemon")
}
}
can anyone tell me why im getting no message when i type the correct args[1]
have u defined args?
whats the structure of pkmnsList
db.once('open', function() {
console.log(messageLink);
const messageReminderConst = new messageReminderModel({user: user, messageLink: messageLink, time: global.time});
const data = messageReminderConst.save(function(err) {
if(err !== null) console.log(err);
schedule.scheduleJob(data.time, remindUser(data, bot));
console.log("Successfully saved reminder." + messageReminderConst);
const successEmbed = new discord.MessageEmbed()
.setTitle("Reminder saved sucessfully.")
.setColor("#00FF00");
userObject.send(successEmbed)
});
});
});```
```TypeError: Cannot read property 'time' of undefined
at C:\Users\Samst\Desktop\RemindMe\core.js:102:43
at C:\Users\Samst\Desktop\RemindMe\node_modules\mongoose\lib\model.js:4838:16
at C:\Users\Samst\Desktop\RemindMe\node_modules\mongoose\lib\helpers\promiseOrCallback.js:24:16
at C:\Users\Samst\Desktop\RemindMe\node_modules\mongoose\lib\model.js:4861:21
at model.<anonymous> (C:\Users\Samst\Desktop\RemindMe\node_modules\mongoose\lib\model.js:502:7)
at C:\Users\Samst\Desktop\RemindMe\node_modules\kareem\index.js:315:21
at next (C:\Users\Samst\Desktop\RemindMe\node_modules\kareem\index.js:209:27)
at C:\Users\Samst\Desktop\RemindMe\node_modules\kareem\index.js:182:9
at C:\Users\Samst\Desktop\RemindMe\node_modules\kareem\index.js:507:38
at processTicksAndRejections (internal/process/task_queues.js:79:11)```
can anyone help me with this?
@gritty bolt Congrats you just leaked your file path
Why I always tell people to send ONLY the first line of the error
ye
Yeah
that shouldn't really be an issue
its not like thats gonna do something
theres nothing in there thats sensative
Yeah
only thing you get is his desktop username is samst
make sure your sending the auth header
and a correct one
that has perms for what you want to get
global is not defined...
global is always defined is it not
anyway, it seems data.time is undefined
which makes sense since he is defining data as = to the thing he is using data.time in
hi i got error
So, I am making a “server count” command and it returned undefined with no error.
Line I used: client.guilds.size
at Client.<anonymous> (C:\Users\Adwait Misra\Desktop\YesBot\main.js:15:54)
at Client.emit (events.js:314:20)
at MessageCreateAction.handle (C:\Users\Adwait Misra\Desktop\YesBot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\Adwait Misra\Desktop\YesBot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\Adwait Misra\Desktop\YesBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\Adwait Misra\Desktop\YesBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\Adwait Misra\Desktop\YesBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\Adwait Misra\Desktop\YesBot\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:314:20)
at Receiver.receiverOnMessage (C:\Users\Adwait Misra\Desktop\YesBot\node_modules\ws\lib\websocket.js:797:20)
im trying to make data the object im saving
const client = new Discord.Client();
const prefix = ';';
client.once('ready', () =>{
console.log('YesBot is online!')
});
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.channel.send('Pong 🏓')
}
})
is there any error
since its showing error
add a .catch(err => console.log(err)) at the end
const data = messageReminderConst.save(function(err) {
schedule.scheduleJob(data.time, remindUser(data, bot));
});
but how are you acessing data in that function if its defined after the function is ran @gritty bolt
Make it /\+/
add a .catch(err => console.log(err)) at the end
@agile lance for my error?
what do you mean by that
So, I am making a “server count” command and it returned undefined with no error.
Line I used: client.guilds.size
@agile lance for my error?
@earnest phoenix That’ll make it log the error :3
k what i do?
the const data is physically before the function, but its running after
const client = new Discord.Client();
const prefix = ';';
client.once('ready', () =>{
console.log('YesBot is online!')
});
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.channel.send('Pong 🏓')
}
})
@earnest phoenix Make it /\+/
k
so your doing
data.time
then doing
const data = function
@carmine summit
client.guilds.size returned undefined? Somebody help please
client.guilds.cache.size
Wait actually no. Make it .split(" ")
client.guilds.cache.size
@ivory seal Thank you.
you cant use something that cant exist yet.
np
if you want to use data, it needs to be outside the function thats called
that defines data
but im trying to define data as the object i just saved into my db
http://localhost:5500/?code=randomcodehere
<html>
<head>
<title>My First OAuth2 App</title>
</head>
<body>
<div id="info">
Hoi!
</div>
<a id="login" style="display: none;" href="https://discord.com/api/oauth2/authorize?client_id=767021465676546118&redirect_uri=http%3A%2F%2Flocalhost%3A5500&response_type=code&scope=identify">Identify Yourself</a>
<script>
window.onload = () => {
const fragment = new URLSearchParams(window.location.hash.slice(1));
if (fragment.has("access_token")) {
const accessToken = fragment.get("access_token");
const tokenType = fragment.get("token_type");
fetch('https://discord.com/api/users/@me', {
headers: {
authorization: `${tokenType} ${accessToken}`
}
})
.then(res => res.json())
.then(response => {
const { username, discriminator } = response;
document.getElementById('info').innerText += ` ${username}#${discriminator}`;
})
.catch(console.error);
}
else {
document.getElementById('login').style.display = 'block';
}
}
</script>
</body>
</html>``` and this is my html same error i am getting
@ivory seal I did that and now it says
TypeError: cannot read property of ‘size’ of undefined
so how can I define data before I save it>?
thanks working
<Client>.guilds.cache.size should work
i mean, you already have the data in the object
{user: user, messageLink: messageLink, time: global.time}
no reason you cant just change const data
to be the object
http://localhost:5500/?code=randomcodehere<html> <head> <title>My First OAuth2 App</title> </head> <body> <div id="info"> Hoi! </div> <a id="login" style="display: none;" href="https://discord.com/api/oauth2/authorize?client_id=767021465676546118&redirect_uri=http%3A%2F%2Flocalhost%3A5500&response_type=code&scope=identify">Identify Yourself</a> <script> window.onload = () => { const fragment = new URLSearchParams(window.location.hash.slice(1)); if (fragment.has("access_token")) { const accessToken = fragment.get("access_token"); const tokenType = fragment.get("token_type"); fetch('https://discord.com/api/users/@me', { headers: { authorization: `${tokenType} ${accessToken}` } }) .then(res => res.json()) .then(response => { const { username, discriminator } = response; document.getElementById('info').innerText += ` ${username}#${discriminator}`; }) .catch(console.error); } else { document.getElementById('login').style.display = 'block'; } } </script> </body> </html>``` and this is my html same error i am getting
@solemn latch please help
rather than whats saved(which is practically the same here i think?)
yeah it is
can someone help me install node.js on google cloud Vps running ubuntu
ReferenceError: remindUser is not defined```
```js
module.exports = {
//Reminder Function
remindUser: async function remindUser(data, bot) {
try {
console.log(data.user);
const userId = data.user.replace(/\D/g,"")
const dmChannel = await bot.users.fetch(userId)
console.log(dmChannel);
let reminderEmbed = new discord.MessageEmbed()
.setTitle(data.messageLink)
.setDescription("You asked me to remind you at this time of the message linked above. Click the link to view the message. If the link does not work, the message may have been deleted or you do not have access to it anymore.")
.setColor("#FF0000");
await dmChannel.send(reminderEmbed)
data.remove();
} catch (err) {
console.log(err);
}},
//Then I use it here (same file)
messageReminderConst.save(function(err) {
if(err !== null) console.log(err);
schedule.scheduleJob(data.time, remindUser(data, bot));
console.log("Successfully saved reminder." + messageReminderConst);
const successEmbed = new discord.MessageEmbed()
.setTitle("Reminder saved sucessfully.")
.setColor("#00FF00");
userObject.send(successEmbed)```
did you follow the guide i linked to you yesterday @charred nimbus ?
can someone help me install node.js on google cloud Vps running ubuntu
yes
it dosent work
still admin auth issues?
have u defined args?
@ivory seal ye i have
yes
did you try running it as sudo/root?
ok
otherwise, contact google cloud support imo
or why dont i run the built in SSH
if (args[0] === "catch") {
if (args[1] === pkmnsList[pkmn]) {
message.channel.send(`You have caught a ${pkmns[pkmn]}`)
}
else {
message.channel.send("That is the wrong pokemon")
}
}
for some reason im not getting any message
ok wait
Woo do you know how to fix the error I sent above
let pkmns = [["Weedle", "https://bit.ly/3nX5gVk"], ["Kakuna", "https://bit.ly/2T0vzf9"], ["Beedrill", "https://bit.ly/3dAhUoi"], ["Pidgey", "https://bit.ly/3lXgbN2"], ["Pidegotto", "https://bit.ly/2H7689i"], ["Pidgeot", "https://bit.ly/2HbfgK7"], ["Scyther", "https://bit.ly/3k6lxFe"], ["Rhyhorn", "https://bit.ly/31xNG0L"], ["Rhydon", "https://bit.ly/3o3hvQ7"], ["Rhyperior", "https://bit.ly/3nZISum"], ["Horsea", "https://bit.ly/3nZITyq"], ["Seadra", "https://bit.ly/346t3dy"], ["Kingdra", "https://bit.ly/2HhEAxS"]]
let pkmnsImg = pkmns.map(item => item[1])
let pkmnsList = pkmns.map(item => item[0])
let pkmn = Math.floor(Math.random() * pkmns.length)
i still am confused about
remindUser: async function remindUser(data, bot) {
async function remindUser(...
or
remindUser: async function(...
ive never seen both combined
i have no idea how that works
the name is optional
let pkmns = [["Weedle", "https://bit.ly/3nX5gVk"], ["Kakuna", "https://bit.ly/2T0vzf9"], ["Beedrill", "https://bit.ly/3dAhUoi"], ["Pidgey", "https://bit.ly/3lXgbN2"], ["Pidegotto", "https://bit.ly/2H7689i"], ["Pidgeot", "https://bit.ly/2HbfgK7"], ["Scyther", "https://bit.ly/3k6lxFe"], ["Rhyhorn", "https://bit.ly/31xNG0L"], ["Rhydon", "https://bit.ly/3o3hvQ7"], ["Rhyperior", "https://bit.ly/3nZISum"], ["Horsea", "https://bit.ly/3nZITyq"], ["Seadra", "https://bit.ly/346t3dy"], ["Kingdra", "https://bit.ly/2HhEAxS"]]
let pkmnsImg = pkmns.map(item => item[1])
let pkmnsList = pkmns.map(item => item[0])
let pkmn = Math.floor(Math.random() * pkmns.length)
@solemn latch here are the arrays
Msbuild and nodejs?
was my webhook correct?
'http://127.0.0.1:5000/dblwebhook'
Only i install quick.db
i think you want to use includes rather than [] @vale garden
kk let me try
(node:15872) UnhandledPromiseRejectionWarning: TypeError: fn is not a function
uh
const server = client.guilds.cache.find(${config.mainserver});
thats a local ip, the ip needs to be your webhooks public ip @earnest phoenix
is the code line of error
Does someone has experience with sharding?
const client = new Discord.Client();
const prefix = ';';
client.once('ready', () =>{
console.log('YesBot is online!')
});
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.channel.send(`Pong 🏓 Latency is ${Date.now() - message.createdTimestamp}ms. API Latency is ${Math.round(client.ws.ping)}ms`)
}
})
when i do this it replies 2 times
why?
you have two instances of your bot running more than likely @earnest phoenix
maybe u running it to time?
do you have your bot running 2 times?
xD
@solemn latch alr so this is what i did if (pkmnsList[pkmn].includes(args[1]))
thats a local ip, the ip needs to be your webhooks public ip @earnest phoenix
@solemn latch how can I find a public ip on python?
no
only 1 terminal
open
and i realized that even if i enter the wrong arg it doesnt send anything
in visual studio code
just pkmnsList.includes(args[1])
(node:15872) UnhandledPromiseRejectionWarning: TypeError: fn is not a function
uh
const server = client.guilds.cache.find(${config.mainserver});
thats what it said the error orrcured in
dude but
theres a ` ` ther
@solemn latch im making a pokemon bot and, i need the arg to be the exact pkmn generated
@solemn latch i think its the built in google ssh is the admin panel
find takes a function @zenith knoll
how to embed this cmd handler
What do you mean, send an embed?
so it send Pong!
your just checking if it exists right @vale garden ?
i wanted to make it embeded
thats what your if does
You could use the MessageEmbed class from discord.js
pkmsList is an array
.includes checks the array, and if its in there, it returns true
is Discord.NET a good library
your just checking if it exists right @vale garden ?
@solemn latch no my bot spawns in a pokemon, and if the user enters its name correctly he catches it
I use discord.net
so i need it to be that exact pokemon
use dsharpplus or disqord
@earnest phoenix why use those? Wasn't dsharpplus abandoned?
find takes a function @zenith knoll
@solemn latch so i should use get?
uh
no?
dsharpplus is being actively maintained
you're probably thinking of just dsharp
You could use the
MessageEmbedclass fromdiscord.js
@sudden geyser like this?
Probably
you need to define Discord
see how Discord is underlined red
or just use a function in your find @zenith knoll
ok
ya
That's probably an error, most likely you never defined it.
at the top do Discord = require('discord.js')
Indentation Error
ok i need to define DC Lib?
this is what i sent in dapi the other day in regards why dnet sucks ass
unstable ws, methods that should be exposed are internal, dependency on its own objects, the lib does multiple requests when you'd expect it to do only one
the last reason is why larger bots can't survive on the lib
hitting way too many ratelimits
and the lib is overall slower than its competitors
python gang
MISSING )
ew
why is that a most likely, you can see the first line of the file
@vale garden then just check if args[1] equals the saved pokemon?
yeah that isnt working
Modify line 9 needs to be )}
your not doing that in the first code you gave
your putting the saved pokemon var, and putting it into something else
@solemn latch that admin thing was the built in google ssh
ah
Woo you are in like 4 conversations rn lol
wdymby putting it into something else
good to know for next time thanks for letting me know the solution @charred nimbus
np
pkmn is the variable already you chose
ye
And do const Discord = require('discord.js')
chan = server.channels.find(ch => ch.id == tickets[message.author.id].ticketid)
and i get a not a funciton error
i defined server
why
That's probably an error, most likely you never defined it.
@sudden geyser ?
dude pkmn is just the number
your just trying to get the thing you already have
there is a lot happening that is worng
well yea
Try it and see, there's no red underline.
ok
wait, why are you not just getting the pokemon in your pkmn var
Typically you hover over those red squiggly lines to see the error
🤔
how do i make a redirect oath link?
wdym
so like they add the bot, then it redirects them
Guys can someone join my discord server and se what i need to put?
First of all, you have an indention error
chan = server.channels.find(ch => ch.id == tickets[message.author.id].ticketid)
and i get a not a funciton error
@zenith knoll
I defined server const server = client.guilds.cache.get(${config.mainserver});
Guys can someone join my discord server and se what i need to put?
@solemn latch pkmnsList is the array of pokemo names, and pkmn is the number, so pkmnsList[pkmn] chooses a random pokemon from pkmnsList
You need to define Discord by
const Discord = require('discord.js')
Send me the code afterwards
Try it and see, there's no red underline.
@sudden geyser Thank You!
@vale garden
can someone help pls lol
With????????
chan = server.channels.find(ch => ch.id == tickets[message.author.id].ticketid)
and i get a not a funciton error
@zenith knoll
I defined server const server = client.guilds.cache.get(${config.mainserver});
??
Toppat typically giving us the full error is more helpful
ok
It's likely that .find is not a function
@vale garden
@solemn latch ik i can do that but either way its the same
🤷♂️
PS D:\dbots\Modmailtemplate - Copy> node .
(node:12308) UnhandledPromiseRejectionWarning: TypeError: server.channels.find is not a function
at Client.<anonymous> (D:\dbots\Modmailtemplate - Copy\index.js:67:32)
at Client.emit (events.js:315:20)
at MessageCreateAction.handle (D:\dbots\Modmailtemplate - Copy\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (D:\dbots\Modmailtemplate - Copy\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (D:\dbots\Modmailtemplate - Copy\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31)
at WebSocketShard.onPacket (D:\dbots\Modmailtemplate - Copy\node_modules\discord.js\src\client\websocket\WebSocketShard.js:436:22)
at WebSocketShard.onMessage (D:\dbots\Modmailtemplate - Copy\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10)
at WebSocket.onMessage (D:\dbots\Modmailtemplate - Copy\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (D:\dbots\Modmailtemplate - Copy\node_modules\ws\lib\websocket.js:797:20)
(node:12308) 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:12308) [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.
when i do it, it works with the code i showed @vale garden
ok let me try
Bruh
Subtraction
noop
thank you @solemn latch
npnp
ok
There
how can i add a redirect in my oath2
Cwickks the only thing wrong with Toppat's code was they didn't access the .cache property before calling .find. There's no need to look in the client's entire channels collection as that's unnecessary.
so like after they add bot to server it redirects them
cant you just use redirect url parameter?
yes but idk how lmao
https://discord.com/api/oauth2/authorize?client_id=741285379188981841&permissions=2147483383&scope=bot&guild_id={g.id}&redirect_uri={server_url}/guild/?edit={g.id}
this work?
it doesnt lol
hi, I am using mongodb atlas, when I connect to db with my test bot (1 server, 2 shards) the db ping is about 30, but when I connect to the db with my master bot (13000 servers, 13 shards) the db ping is over 20000. What is the reason?
i wanna start coding bots in an another language (something like java, c#) what should i use?
Hey guys I have an issue with my bot
i wanna start coding bots in an another language (something like java, c#) what should i use?
@gentle lynx ts?
Hey guys I have an issue with my bot
@sly marten DONT ASK TO ASK
caps
i wanna start coding bots in an another language (something like java, c#) what should i use?
@gentle lynx there are a lot to choose from. JavaScript? Python? C? C++? C#? Rust? a lot
hm
heck even php
whats rust
systems programming language
hi im back
if(!message.member.roles.cache.has(r => r.name == “role name”)) return message.reply("You do not have access to this command!")```
How do I make it so it’s trigger by role name not ID?
@sly marten DONT ASK TO ASK
@drifting wedge so the prefix of the bot is nk; but even if I type like $help or any other prefix, it replies too. How tf do I fix this
aight ty
check the message starts with prefix
@solemn latch do you think this is correct?
let pkmnsList = [["Weedle", "https://bit.ly/3nX5gVk"], ["Kakuna", "https://bit.ly/2T0vzf9"], ["Beedrill", "https://bit.ly/3dAhUoi"], ["Pidgey", "https://bit.ly/3lXgbN2"], ["Pidegotto", "https://bit.ly/2H7689i"], ["Pidgeot", "https://bit.ly/2HbfgK7"], ["Scyther", "https://bit.ly/3k6lxFe"], ["Rhyhorn", "https://bit.ly/31xNG0L"], ["Rhydon", "https://bit.ly/3o3hvQ7"], ["Rhyperior", "https://bit.ly/3nZISum"], ["Horsea", "https://bit.ly/3nZITyq"], ["Seadra", "https://bit.ly/346t3dy"], ["Kingdra", "https://bit.ly/2HhEAxS"]]
let pkmnsImg = pkmnsList.map(item => item[1])
let pkmns = pkmnsList.map(item => item[0])
let pkmn = pkmns[Math.floor(Math.random() * pkmnsList.length)]
let pkmnImg = pkmnsImg[Math.floor(Math.random() * pkmnsList.length)]
const embed = new Discord.MessageEmbed()
.setTitle("A wild pokémon has appeared!")
.setDescription("Guess the pokémon and type \`!catch <pokémon>\` to catch it!")
.setColor("YELLOW")
.setImage(pkmnImg)
bot.channels.cache.get(channel).send({embed});
if (args[0] === "catch") {
if (args[1] === pkmn) {
message.channel.send(`You have caught a ${pkmns[pkmn]}`)
}
else {
message.channel.send("That is the wrong pokemon")
}
}
what lang?
@agile lance use .find instead of .has
@drifting wedge so the prefix of the bot is nk; but even if I type like $help or any other prefix, it replies too. How tf do I fix this
@sly marten if(!message.content.startsWith(“nk”) return;
@agile lance use
.findinstead of.has
@sudden geyser Thanks
🤷♂️ i am bad at seeing errors without an error message @vale garden
well
im like the 2nd best python person here
@gentle lynx also since you mentioned Java, look up Kotlin
cuz me and shivaco r the only ones lmao
can you just show me what you did which made itwork @solemn latch
@sly marten if(!message.content.startsWith(“nk”) return;
@agile lance and where do I put this in the script?
ill pm you the screenshot of my logs since its a big one(trying not to spam chat)
was my DBL webhook correct?
http://0.0.0.0:8080/dblwebhook'
@drifting wedge I know myself some 🐍
ok 3rd best rn
https://discord.com/api/oauth2/authorize?client_id=741285379188981841&permissions=2147483383&scope=bot&guild_id={g.id}&redirect_uri={server_url}/guild/?edit={g.id} is this a valid redirect url?
ok so how can I find a public ip?
if your on a home network, google.com "whats my ip"
if your on a server, it should be on the control panel somewhere
ipv6 pog
probably should delete that, public ip's although public shouldnt be shared
again, probably shouldnt share your ip
how can I create a flask app for it?
I heard Python
i need webhook.js command
is server.iconURL({ dynamic: true, format: 'png', size: 1024 }) not a thing?
it wont show
var e4 = new Discord.MessageEmbed()
.setColor('GREEN')
.setTitle(Message Sent)
.setDescription(${message.content})
.setFooter(${server.name}, server.iconURL({ dynamic: true, format: 'png', size: 1024 }))
.setTimestamp()
Shiv arrives like I do when I hear C#
@drifting wedge still got that issue?
@solemn latch oh
yo
wuts up
@earnest phoenix
?
so like redirects r like oarth2?
wait toh
how will i do redirects?
the redirect is like the user's server
?
like basically 1 sec
are you inviting a bot in your url?
because discord wont redirect if you dont add a redirect url to your bots page.
so like basically
when u press this
i want it to take u to the invite bot page to the server (which it does)
then after that, it takes u to the dashboard
but the dashboard is like link.com/edit/guildid:guildid
@zenith knoll servers are called guilds in discord development, so it can be hard to tell what your talking about when you name a variable server that contains a guild.
I have a variable named server, but it references a physical server, not a guild
could you redirect your redirect
lmao
ie
redirect to
example.com/redirectedit
and then that redirects to
example.com/edit/guildid:guildid
uh ok....
i dont know what other way to do it if it needs to be a dynamic url.
or just take it to the users overall dashboard
@zenith knoll servers are called guilds in discord development, so it can be hard to tell what your talking about when you name a variable server that contains a guild.
I have a variable named server, but it references a physical server, not a guild
@solemn latch uh well here is what i did const server = client.guilds.cache.get(${config.mainserver});
its a guild
so eh
whats happening
so itll redirect to example.com/redirectedit
yeah
im soooooooooooo dumb
iconURL is optional
ik
reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
"Add a parameter to your app.run(). By default it runs on localhost, change it to app.run(host= '0.0.0.0') to run on all your machine's IP addresses. 0.0.0.0 is a special value, you'll need to navigate to the actual IP address. "
http://0.0.0.0:5000/
cry will probably have a better solution, but tracking the invite(bot just joined x guild)
anyone who visits the /redirectedit path who has the manager_server permission in that guild could be redirected for the next few minutes
how do i global something?
thats my plan
wait it wont work fuckck,ckck
======
ok so basically. how would i redirect it?
How do I write the code, so that I can mute everyone in the server?
it would like link to the /redirectedit redirect
which reidrects to?
the main bot page?
@has_permissions(administrator=True)
@client.command()
async def muteeveryone(ctx):
guild = client.get_guild(764893841068261447)
bruh= await guild.fetch_member(message.author.id)
for role in guild.roles:
if role.id == 764908012048875540:
for member in guild:
await bruh.add_roles(role)
this is my code
it doesn't show any errors
like how can i log from one redirect to another what the guild id is
you cannot directly, which is why my round about way is the only solution i can think of
Somone knows a library or API of NodeJS to enter a Nitrado server (PS4 ARK host)
but how would one thing know what server it was added to?
probably a database with all that info @drifting wedge or ipc
@solemn latch so like when someone adds the bot, it adds them to the db?
im confuisedd
bot joins guild > bot puts that info into a database
anyone from that guild who has manage_server in that guild that visits example.com/redirectedit is redirected to example.com/edit/:guildid
after 30 seconds, or a few minutes delete the entry from the db
but how would redirect edit know the guild id?
it doesnt, it looks at the database
what is that link lol
how do u change the permissions of a channel to sync with the paternt\
thats what i suggested when you mentioned it
i m unable to install better-sqlite3
follow their troubleshooting page
gyp error?
how do u change the permissions of a channel to sync with the paternt
@zenith knoll
js
gyp error?
@pale vessel yep
what libary is that
do you mean python?
it python?
js
python is a lanugage
nvm
@ is typically used in python 🤔 not js
im so sleepy
@client.command()
@has_permissions(administrator=True)
async def muteeveryone(ctx):
guild=ctx.guild
for role in guild.roles:
if role.id == 764908012048875540:
for member in guild.members:
await member.add_roles(role)
this only mutes teh bot itself
its py
why?
seems like api abuse @earnest phoenix
what?
your bot will very quickly get ratelimited by discord doing stuff like that
we need to mute everyone to avoid discussion during a competition
@earnest phoenix just lock the channel
there are like 25 channels
change the permissions of the @everyone role to not be able to talk
ok
or a specific role
but many people have a bunch of roles
so its just one request rather than a ton
🤷♂️ put it above that role, same as the mute role
did you follow the troubleshooting page they offer
does repl.it support better-sqlite3?
anyway, the troubleshooting page is on their github or npm page.
does installing huge amount of packages makes the bot slow?
hey all i have start with boting last day and i dont know why i get a error ( **const commandFils = fs.readdirSync('./commands/').filter(File => file.endWith('.js')); **)
What is the error
by the filter
file is not defined
File is not file
@earnest phoenix not here
file is not defined
@next flax how do un meen that
also it’s client.commands.get not client,commands.get
@cerulean laurel you have File, you tried to use file. They are different
Where is discord tester server
better-sqlite shit
🐹
@earnest phoenix its private
have you looked at the troubleshooting page yet?
because its kinda super important to look at that
official server?
@next flax testers
because its kinda super important to look at that
@solemn latch i didnt understand that
Someone knows how can i access admin command logs using Nitrapi?
@cerulean laurel you have File, you tried to use file. They are different
@misty sigil yes i have create for (prefix)help a file extra in a order names commands
can some tell me, which theme is this?
and file as the action thing
you have to follow the requirements of that library to use it, you cant just use it @next flax
and file as the action thing
@misty sigil okey
@rocky hearth look up material
what is the best library in java
what is the best library in java
@gentle lynx JDA
ok
and file as the action thing
@misty sigil and how a can chnage thatsry if i get right u meen know (file =>....
JAVA DISCORD API
change .filter(File to .filter(file
how can i get admin perms on google cloud
margin-top i guess
@sudden geyser Hey I just tried material. But its too much bluish dark
Are you using VSC
yes
the I pic I shared, is very much similiar to dracula
but I feel dracula a bit faded
hold on
@rocky hearth Go Extensions -> Material Theme -> Set Color Theme
The theme looks like a mix of material theme with Dracula

how can i get admin perms on google cloud
yes then?
how do i move the button down?
The closes I can get is the Ocean theme
try both and see
<button type="button" class="btn btn-default">Save!</button>
ok ok
so like here?
or in css?
doesn't matter
<button type="button" class="btn btn-default" margin-top:10px>Save!</button> something like this?
use the style attribute
No
oh lmao
style="css"
@pale vessel r u the one who made chip?
no, it's kyoso
Just put it as a css rule
don't want to talk about that
o ok
it's cringe
o ok lmao
flaz did you lose a bet
ive dmed so many people about this
alr well i dont care enough lmao
I need to know
how do i make it like default
so like it shows
but when u start typing it disapears
you know wut i mean?
start typing?
why does sshing via root@IP have like a different pm2 than when you ssh via user@IP?
the button disappears when you type in the field?
Someone knows how can i add Authorization header to node-fetch?
Someone knows how can i add Authorization header to node-fetch?
@ember lodge https://dontasktoask.com
?????
pycharm wont open 4 me
i am asking, lol
what's your setup
The second argument to fetch takes an object. In the object, give it headers, which will be another key/value for each header
For example: js fetch("https://example.com/", { headers: { Authorization: "dummy" } })
baka
5head
Guys, who has a python example of on_dbl_vote with getting a user who voted for a bot?
shivaco probably has one

nope, go away
@pale vessel I won’t

nice ping
Yes
XD
data["user"] returns an ID of the voting user in a string
Oh
convert that to integer and get user for that ID
Ok thx, I will try this
:)
Is it allowed though, so if a user votes for my bot, if he is in bot support server he gets a special role
yes
Ok thx 
only not allowed if you give some sort of currency or reward to another bot
so voting octave for dank memer coins is not allowed but voting prism for voter role in support server is allowed?
In prism’s support server yes
yis
What happens when you try opening the app
literally
whats toolbox app
JetBrains Toolbox: https://www.jetbrains.com/toolbox-app/
what computer do you have xd
did you do something? like a windows update
Nah, still doesn’t work
node . does not even work for me anymore lol
My code doesn’t work, I want so when user reacts for a bot, the bot checks if a user is in the bot support server, so it can give the user a special role
discord.py
Is it data.user ???
What program do suggest using to make a bot?
@simple frigate not a program, a programming language
Programs to make bots are really trash
Ok! What programming language do suggest me to use?
hi
js is easy for beginners
Bruh, your choice. The most popular are python and javascript
could i get some help
my code is acting kinda strage
eh arguable
alr so
i have this code
and
it spawns in a pokemon
and if i do !catch <pokemon>
i have an if block which checks if the pokemon is correct
the problem is that
if i type !catch <pokemon>
it first spawns in a new pokemon
the says that the pokemon arg mentioned was wrong cuz it isnt the new pokemon
plzz help
if that code is all inside a message event, then you're generating a new list of pokemon on every single message you receive
hey tim, discord seems to have gotten rid of the api request to get a single role from a guild(while keeping get all roles). any idea why they did that?
just easier to have one endpoint?
Whats the difference between prepared statements and just normally using the query function in mysql ?
In nodejs
@solemn latch whats the difference





