#development
1 messages · Page 837 of 1
you're only passing a message object
either pass the client as well, or get it from the message
check the docs and see if eris supports that
it doesn't
then pass the client directly
does Eris not have client attached to a message?
ok
i think it is only d.js
@earnest phoenix not bad
i passed it directly and i get this error (node:15388) UnhandledPromiseRejectionWarning: Error: 401 Unauthorized on POST /channels/686997585541726264/messages
how did you pass it?
does Eris not have client attached to a message?
It does, but starts with an underscore (<Message>._client)
Try to send the message to that user. If you can't, you can't DM the user.
ask staff
what have you tried doing
check if the channel is nsfw
@bitter sundial Somebody said to ask staff
So I also have a giphy commabd
but even if I try to force it to produce nsfw content
it does not
can u explain in details
So I assume the lib I'm using has the filter set to pg
and why are you asking me
Need help
Somebody said to ask
@quartz kindle like this:
const Eris = require('eris');
const { token } = require('..//../config.json');
const client = new Eris.CommandClient(token);```
@robust moth version?
sorry i took ling
@robust moth show code
@zenith terrace 12
MessageEmbed for v12
@digital ibex in your command file?
well it could potentially send an nsfw gif
@digital ibex i know it
oh
@slate oyster can u explain what is it u need help with
he has a giphy command that he allegedly disabled nsfw but bot still got declined
i dont have client, i have args instead of client
passing is this: ```js
// main file
client = new Client()
execute(client)
// command file
execute: client => {
}
oh
Tim tim
how did you disable nsfw, is it an option available on the api?
(is there even an api)
Somebody else's bot was declined
o h
So I was checking
minimodding?
I read the giphy docs
There is a pg option
@quartz kindle like this?
try {
command.execute(message, args, client);
} catch (e) {
console.log(e);
client.createMessage('689557849214418972', e);
client.createMessage(message.channel.id, 'An error occured.');
}```
it's not yours
?
So for my bot
I also have a giphy command
And I dunno wether my api uses the pg field
module.exports = {
name: 'ww',
execute: (message, client) => {
console.log('e');
}
};``` and in the command file
you said you checked the docs
Yes
there is a field for it
then make it pg
looks even better now
But I'm using an API
nice emoji
A library
@quartz kindle client.commands = new discord.Collection(); client.commands.get(command).execute(message, args);
I dunno if my library sets it to pg by default
But I assumed it did
Do anyone know how to check if a role is higher than another?
e.g. I will use Subject A and Subject B
Both Subject A and B has the kick perm, but subject A has a role higher than Subject B but Subject B can still kick Subject A with the bot. So how do you check if a role is higher than the other so that Subject B cannot kick a higher role?
Is that possible?
role.position? 
highest role maybe
@digital ibex
highest role position
Maybe I'll just read the libraey
I tried looking at docs but cannot find it
spource
a r g s
tim im confused on what thats supposed to mean
arguments are passed in order
not by name
you pass message as the first argument, so the first argument in the command file is message
you pass args as the second argument
so in the command file, your client is actually args
not client
and you pass client as the third, and you have no third
rating is optional btw
if you're using the giphy api
or am i getting something wrong
So it looks like the default is 'g'
So I dunno how the one person's got marked as producing nsfw images
But I dunno if my library is setting the rating
I'm assuming it is
role.position? :special_think:
@slender thistle is that what it is or you suggesting
?
what it is
I was assuming your library had position property for roles
perhaps the highest role would do
@earnest phoenix the only way is to try sending a message, and catch the error
member.roles.highest.position >= me.roles.highest.position
Ah ok, I'll try that
doesn't bannable cover that?
Kk
removing roles would be a problem
So v11 would be member.highestRole.position > me.highestRole.position
guys, superagent not working
yes
Aight
console.log it first
Ok
@earnest phoenix thats not how you catch the error
.catch is for asynchronous functions only
and thats not how you dm people
well yes
^ only works if you await
on his case it would be after message.channel.send => message.channel.send("ok boomer").catch(e => { });
Hi?
and do message a person its just <member>.send
What can i use alternative of superagent? Any1?
@flat pelican
Since you were the moderating user on the other person's bot
I wanted to ask you
So my bot has a giphy command too.
I'm using a library, and I'm not 100% certain if it is using the filter option, but I believe it is
So to test I had tested it with multiple sensitive (aka nsfw) searches
And it consistently produced Safe content
So I was wondering if that would pass probably?
DMs preferably
sigh
well it sent content that I judge that are not safe for public channels - you can DM me for more information
i-
Direct Message
ok
me too when i was a beginner
@earnest phoenix there are many alternatives, such as node-fetch, axios, got, bent
w-
axios is best
that ain't dm
just catch the error
use .catch after message.member.send
http is best
and send it
also, make sure that it tells you who the recipient is
otherwise it could be used maliciously
if (target.highestRole.position > member.highestRole.position)```
So I did it this way since I have defined target and member.
`TypeError: Cannot read property 'position' of undefined`
roles.highestRole
oo
@flat pelican ok. I'll dm you. I'm probebly using a different lib then the other person, so mine might apply the filter flags while their's does not
@quartz kindle so which is best?
member.highestRole.positionshould work
@pale vessel Nope it didnt
Ok
@earnest phoenix there is no best, check their npm/github pages and see which one you like more
if(dm) {
member.send(dm);
message.channel.send(':white_check_mark: **DM sent** :e_mail:')
} else {
message.channel.send('error')
}
lmk if there are any errors @earnest phoenix
probably is
wait
ok
that code is just...
yah
i'm still wondering how it worked
@earnest phoenix https://github.com/request/request/issues/3143
@summer torrent nevermind, im now using "got".
axios 
why this dont work?
package Juego;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Dimension;
import javax.swing.JFrame;
public class Juego extends Canvas {
private static final long serialVersionUID = 1L;
private static final int ANCHO = 800;
private static final int ALTO = 600;
private static final String NOMBRE = "Juego";
private static JFrame ventana;
private Juego() {
setPreferredSize(new Dimension(ANCHO, ALTO));
ventana = new JFrame(NOMBRE);
ventana.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ventana.setResizable(false);
ventana.setLayout(new BorderLayout());
ventana.add(this, BorderLayout.CENTER);
ventana.pack();
ventana.setLocationRelativeTo(null);
ventana.setVisible(true);
}
public static void main(String[] args) {
}
}
flazepe i edited it to how i would've doneit
Thats not even for a bot...
i would do```js
if (dm) {
member.send(dm).catch(e => { return message.channel.send('error'); });
message.channel.send(':white_check_mark: DM sent :e_mail:');
} else { whatever }
useless request : how to make a bot online but with mobile indicator
not possible
oof
Presence#clientStatus
The new presence.clientStatus property returns an object with three keys: web, mobile and desktop; their values are a PresenceStatus string. This property allows you to check which client the member or user is using to access Discord.
can someone give me some idea how i can set up a log of channelUpdate event
hm
@finite bough client.on('channelupdate', (channel) => {
guild = channel.guild
...
});
i mean i have to check every thing which can be updated seperately
✅ | Congratulations Lumap!. You have reached level 1
(Please dont ban me I promise am not a self bot)
😂
nani
like?
i have to compare every value?
yes
between the old channel and new channel
yes
ok thats gonna take some time to make
client.user.presence.clientStatus = 'mobile'``` dont work
why do people keep doing that shit
whenever you want to change something on discord
you have to use a method
because you need to make a request
You can't just change the variable like that lol
I mean, the only time I see this documented online is on the "upgrading from v11 to v12" guide from discordjs
because you're not rlly ment to be on mobile for bots
it doesn't matter
discord just dont rlly care if you trick the api
i even sent what cry said
i mean it looks cool
so
i'm pretty sure you can't have a mobile indicator with d.js
nope
it is possible for bots to have it though
technically, within js, code like that is possible
dad bot is eris
using the js setters
It is
it is possible, it won't work
But it's not documented
you need to make a request to update your presence
which, simply setting a variable to a value, doesn't do
yes
a setter in javascript is a function that'll be executed when simply changing the variable
or just like edit the d.js library to include that in the socket handshake
so behind the scenes that could totally work
it wouldn't make sense, and it's not the way it is
What?
huh?
tfw you try to sound smart but you end up looking dumb
Let's keep it a little more friendlier here @earnest phoenix
yehhh bots can very much still using playing
Can anyone help me with updating to v12?
haha it was a pain innit
Yes
bet you reverted back
The .addField to .addFields change made be go crazy 😳
.addField still works
I still use .addField
same
just like how they removed overwritePermissions
it does? I used v12 before they made it stable and there was only addFields 😦
nah
i mean it's major versioning for a reason
they removed addField then they added it back again
devs in dilemma
Oops
i have old master, the master what was before stable v12
Does anyone have time to help me with the move with any chance?
class crona(commands.Cog):
NameError: name 'commands' is not defined``` ```from discord.ext import commands
import discord
class crona(commands.Cog):
def __init__(self, bot):
self.bot = bot
@command.command()
async def donkey1(self, ctx):
await ctx.send("https://imgur.com/MAz9bXR")
def setup(bot: commands.Bot) -> None:
bot.add_cog(crona(bot))```
crona
is it against the rules to make the ads smaller rather than allowing them to take up half of the screen?
@command.command()
👀
so if the ads take up half of the screen i cannot make them smaller at all
@slender thistle thats what u notice?
I got fairly rusty at discord.py after going through my fucking online learning, give me a break 🤣
So what do I need to do to fix it
I know I fixed it
But how do I fix my issue though
command.command() look you rdifferent files
It's commands.command () I know I fixed it
https://i.imgur.com/hEnlE27.png anyone a idea why this does literally nothing? it dont give me a user
have you tried debugging your code
have you tried debugging your code
I tried everything
@sterile minnow .
if you had debugged your code, you would've found where the issue relied
so no, you haven't, proceed to doing so
debugging includes logging your checks, logging your blocks, logging where the code hits and inspecting your variables
obviously you haven't, you'd fine the issue otherwise
which i'm guessing, you did none of that
How many ways do we have to tell you to debug
if you're going to keep on lying about doing it when you don't want to do it, you don't have to be in this channel
you're not getting an user bc args [0] is just this <@id> you gotta fetch an user using that
there
how can i make something like a file handler in js?
fs is your answer
well idk how
i havnt coded in js for 2 months.
try google?
i dont find something regarding to this there
"node.js filehandler"
cause if you search js, most of the results are for angular js.
Search on Google, "Node.js fs module"
(Idk wich channel is most fitting for this)
@tulip wave
Can I ask if my bot has been kicked from this server? Because it’s not here and (afaik) this is the case of him not showing if it’s online or offline on the website. (Also please say wich channel is the most fitting for these questions)
guildKickAdd is avaible in v11? Any1 ??
"Do not @mention people randomly."
They were trying to mention their bot.
I just kidding....
Thank you
Anyway
It’s gone so.... if it has been kicked I would like to know why cause it followed all rules
what's your bot id?
Gimme 5 sec
no guildkick
676849305646268417
Ik
So it didn’t send join messages and the only direct message is if your suggestion gets accepted and you didn’t turn it off
theres no mod-log of it 🤔
DM a mod about your bot.
Also it shouldn’t even send anything as it’s not configured on this server
.....
I mean
I could ping him again
But that doesn’t seem helpful
Eri, help
@flat pelican
I mean, idk why but this dc server did spam my logs so I disabled the bot for this server... but that shouldn’t have been the reason to kick the bot right?
?
im close to finishing my pinbot, a bot that reposts messages when theres a certain emote number reached, but I ran into a problem where it reposts a normal message but if its an image file it just leaves it blank
https://cdn.discordapp.com/attachments/381889950666457088/692444943242887228/unknown.png
this is the code for the reposting
help?
uhh, please move in #memes-and-media and ping me with your bot's ID
Ok
This channel is only for code/dev talking
const entry1 = entry.executor
console.log(entry1.id)```
Why this isnt working?
any error?
@pale vessel it gives me an error because of the "if"
.then ?
oh, i will try.
title: if (!reaction.message.content) return,
^^
SyntaxError: Unexpected token if
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:188:16)
at bootstrap_node.js:609:3
oh.
oh boy
you cant use an if like that lol
thank you tim for handling that pain
im still learning js
it's okay, we understand
so how do i type it?
@sudden geyser Thanks its worked :D
before channel.send, i guess
if you want to do a conditional operation when assigning, for example title: if something, assign something, else assign something else you can use a ternary operator
like this: title: condition ? value1 : value2
<condition> ? <if true> : <if false>
sometimes you need to cover it with brackets
depends on the situation
otherwise if you want to do an if(something) return then you should do it somewhere else, not during value assignment
alright it works, but it isnt sending anything when an image is trying to be reposted
how did you detect same image?
no i meant pinned*
images and embeds are not part of a message content
tim
how do i return the image then
images are found in message.attachments
in channelUpdate event(11v) do i have to compare all the stuff between old channel and new channel
and embeds are found in message.embeds
to repost images, you need to put the original attachment in a files option, outside of the embed
to put an attached file in an embed, you use a special attachment:// url
how do i find the url of the image sent
i can only get the message content
and the message link
message.attachments
it holds a collection of attachments, each with url and data
@finite bough yes
can u tell me an easy way to do so
what do you want to compare?
you could probably make a function to do it for you
client.on('channelUpdate', (oldchannel, newchannel) =>{
prefixes.findOne({
serverID: newchannel.guild.id
}, (err, res) => {
if(err) console.log(err);
if(!res.logchannel){
return console.log('no log channel')
} else {
if(oldchannel.name !== newchannel.name){
let embed = new Discord.RichEmbed()
.setTitle("**A channel has been updated**")
.setColor("#fc3c3c")
.addField('***channel.id***')
.addField('old channel Name', oldchannel.name, true)
.addField('new channel Name', newchannel.name, true)
newchannel.guild.channels.get(res.logchannel).send(embed)
} else
}
});
});
my progress
lel
make an embed first and then if a condition is true, add a field with corresponding information (like old and new name if they're different)
i mean, there isnt much that can change about a channel, you only need title, description, position... what else? permission overwrites? parent category?
hmm
but i guess that's it
i can try fletching them from audit
How can i learn a kick reason?? is that possible?
audit logs
aufit
yes
wait how do u fetch that
i cant see any reason
just user shows infos
its not showing reason.
i specified a reason but same....
Ok, i fixed....
How To make in one embed addfield if a condition is true ???
embed.addField()
embed is the embed object
simple fix: use debug mode or toArray(); ez
ok i give up on trying
client.on('channelUpdate', (oldchannel, newchannel) =>{
prefixes.findOne({
serverID: newchannel.guild.id
}, async (err, res) => {
if(err) console.log(err);
const GuildAuditLogsEntry = {
targetType: 'CHANNEL',
actionType: 'UPDATE',
action: 'CHANNEL_UPDATE',
reason: null,
executor: [Object],
changes: [Object],
id: oldchannel.id,
extra: [Object],
target: [Object]
}
const entry = await oldchannel.guild.fetchAuditLogs({type: 'CHANNEL_UPDATE'}).then(audit => audit.entries.first())
if(!res.logchannel){
return console.log('no log channel')
} else {
if(oldchannel.name !== newchannel.name){
let embed = new Discord.RichEmbed()
.setTitle("**A channel has been updated**")
.setColor("#fc3c3c")
.addField('***channel.id***')
.addField('old channel Name', oldchannel.name, true)
.addField('new channel Name', newchannel.name, true)
newchannel.guild.channels.get(res.logchannel).send(embed)
} else newchannel.guild.channels.get(res.logchannel).send(entry.changes)
}
});
});
pile of shit xD
yes
The const GuildAuditLogsEntry isn't needed
And after ur else u've been Forget }
{*
wdym
The {} is optional for single-line code. <GuildAuditLogsEntry>.entry is an array of changes (Array<AuditLogChange>). The docs point it out: https://discord.js.org/#/docs/main/stable/typedef/AuditLogChange
What exactly do you give up on trying.
If a server has over 1K members, which makes offline people hidden. Can bots still detect them or not
the default "large" threshold is 250 members
meaning guilds with more than 250 members will not have their entire member list cached
it will only cache online/active users
in order to get offline/uncached users, you need to fetch them
@earnest phoenix stop please
banned lol
Nice
Anyway, back to the code
So
Yea I was wondering cause I keep seeing the users logged on my botinto command go up n down and was curious
@quartz kindle also Tim. Im wondering if you know the reason of this
if (target.highestRole.position > member.highestRole.position)```
So I did it this way since I have defined target and member.
`TypeError: Cannot read property 'position' of undefined`
what is target?
let target = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
The user
Want me to resend what this is about?
hi
👀
how would i define something with a type?
js
i've tried googling it but im a bit confused, i need to use a class or smthing which im not good at
@zenith terrace well, you dont need to do that, you can simply do target = message.mentions.members.first() || message.guild.members.get(args[0])
but that isnt the cause of the issue
did you log both target and member?
console.log
O that log. Uh no
So I noticed one of my bots was not working properly, so I logged "client" on ready event, and it is missing, MANY things, even client.user is null
v12?
11.6.2
anyone know a plugin (or eslint) extension in vscode to catch things like
new Promise((resolve)=>{
if(something){
resolve("done")
}else{
//oops i forogt
}
})
Hi I think I accidentally changed my account into a bot. could someone help?
We cant really help you with that <_<
could someone change it back?
erm no?
We. Cant. Do. That
cries
CF8prefix
A snowflake is a string right?
I think the devs got the command wrong. I said prefix instead of ping +_+
Butt jeez that ping
<_<
Butt
xD
I'm trying to make a new bot that checks my main bots presence, and if it comes offline, it's supposed to dm me.
However, a few minutes after starting it, I get this error.
at Timeout._onTimeout (C:\Users\Cools\statusbot\src\index.js:22:16)
at listOnTimeout (internal/timers.js:536:17)
at processTimers (internal/timers.js:480:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fyre@1.0.0 start: `node src/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fyre@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Cools\AppData\Roaming\npm-cache\_logs\2020-03-25T22_39_02_089Z-debug.log
C:\Users\Cools\statusbot>```
Code:
const logger = require("../utils/logger"); //better console logging
const { Client, Collection } = require("discord.js");
const bot = new Client(); //creates the Discord Client
const data = require("./loaders/reader"); //this returns data user entered in botconfig file
const Discord = require('discord.js');
const client = new Discord.Client();
["aliases", "commands"].forEach(x => bot[x] = new Collection()); //bot.aliases, bot.commands = Discord Collections
["console", "command", "event"].forEach(x => require(`../handlers/${x}`)(bot)); //run all of these files with param bot
logger.log("Successfully loaded other files.");
bot.login(data.token); //login with the bot token defined in botconfig file
const owner = client.users.get("279116778246766593"); // Your user ID
const dogbot = client.users.get("679211740202008596"); // Your bot's ID
setInterval(function(){
if (dogbot.presence.status != "online") owner.send("DogBot has crashed or is offline."); // If DogBot is not online, send the owner this message
}, 60000); // Checks every minute```
how would I define it? It should already be due to it being associated with the stuff.
@astral yoke your bot might not be cached, make sure the id is correct, and use fetch instead if its not cached
in v11 would be await client.users.fetchUser(id) but requires an async function
So sorta like this?
const dogbot = client.users.fetchUser(679211740202008596); // Your bot's ID```
?
await
how would I make an async function into that? @quartz kindle
I checked the Discord.js v11 to v12 guide and it doesn't mention anything related to this. I decided to update to v12.0.2 on one of my bots. In v11, my bot was working perfectly fine. Now, it seems as if the message event only fires once during the bot's lifetime. I verified the issue on a server of mine. I created another bot using the sample code provided and found the same issue, even on another computer. I tried this in different servers. It seems as if the issue is on v12. I am on Node.js runtime version v12. Is this an actual issue? Can anyone else replicate or observe it?
Oh sorry I was talking about my issue
well, if you really think v12 is best for the error you didn't have in v11 then go with it
not my decision for sure
true but I still want to know as I will eventually have to upgrade to 12
and if it is an actual issue I want to actually put something on their repo about it
yeah
@astral yoke await client.fetchUser
So I should take out the users between that?
in v11 would be
await client.users.fetchUser(id)but requires an async function
@quartz kindle client.users.fetchUser()
Cause I have client.users.fetchUsers();
just type await for make it async function
Im confused
i mixed up v12 and v11 lmao
how would i make it one tho? it's error is that it's only valid in async function
v12 is client.users.fetch
v11 is client.fetchUser
make your function async
@astral yoke you have two options
or use .then
either make your timeout async, and fetch the user inside it
or fetch the user first and use .then()
So fetch the user,
making your timeout async would be better
setTimeout(async () => {
let user = await client.fetchUser(id);
// continue
},60000)```
am I able two put to there?
like,
let user = await client.fetchUser(id);
let user = await client.fetchUser(id);
// continue
},60000)```
wait
different variable names
i already have someone that tho
cause with the second part of the code
i have it there
if (dogbot.presence.status != "online") owner.send("DogBot has crashed or is offline."); // If DogBot is not online, send the owner this message
}, 60000); // Checks every minute```
am I able to just put the setInterval(function(){ higher above the fetchUser?
just put everything inside a single interval
the code i showed uses a timeout, but just change it to interval instead
i works the same
const
express = require("express"),
discord = require("discord.js"),
bodyParser = require("body-parser"),
nice_json = require("json-beautify"),
chalk = require("chalk"),
fetch = require("node-fetch"),
pretty = require('express-prettify');
cors = require("cors"),
url = require("url"),
db = require("quick.db"),
app = express(),
client = new discord.Client();
require("dotenv").config();
// LOAD OF EXPRESS CODE
client.on("ready", () => {
console.log(client)
})
client.login(process.env.TOKEN);
D.js 11.6.3
When client is logged, client.user is null, and readyAt is also null, along with few others things
I have another error.
at APIRequest.getAuth (C:\Users\Cools\statusbot\node_modules\discord.js\src\client\rest\APIRequest.js:33:11)
at APIRequest.gen (C:\Users\Cools\statusbot\node_modules\discord.js\src\client\rest\APIRequest.js:39:54)
at C:\Users\Cools\statusbot\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:59:20
at new Promise (<anonymous>)
at SequentialRequestHandler.execute (C:\Users\Cools\statusbot\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:58:12)
at SequentialRequestHandler.handle (C:\Users\Cools\statusbot\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:125:10)
at SequentialRequestHandler.push (C:\Users\Cools\statusbot\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:48:10)
at C:\Users\Cools\statusbot\node_modules\discord.js\src\client\rest\RESTManager.js:27:15
at new Promise (<anonymous>)
at RESTManager.push (C:\Users\Cools\statusbot\node_modules\discord.js\src\client\rest\RESTManager.js:26:12)
(node:7072) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:7072) [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.
you need to wait for the ready event
@snow urchin is that the console.log from your ready event?
yes
you dont have any other console.log anywhere?
nop
do you use client anywhere in your express code?
yup, but I tried removing all other code, except for wat you see above ^, still did not work
weird
do you get any error? try catching the login function
client.login().catch(console.log)
Full client log output:
https://hasteb.in/ofomojik.css
No error is logged with the .catch
-.-
is that all your code?
that hastebin?
the code you posted before
i have no idea why that would be happening, but the client you are logging is indeed a non-logged-in client
makes no sense :/
@snow urchin any error?
I only get errors in the express code for things like client.users.get... etc
you can try logging raw events
client.on("raw", r => console.log(r)) // this will massively flood your console lol```
i will have it go into a haste so my console dont be like HELLLOOO
Okay, So I cleared up everything. But how would you properly @ a role? I attempt to do @radiant compass but it dosen't actualy ping it. I also tried @Role name, and it dosen't work. What would I do to have the bot ping a role when I use a command?
afaik role pings are like this <@&id>
@quartz kindle
https://hasteb.in/afozomug.js
may take a bit to load :/
love how each guild is "unavailable"
this one laggy hastebin
how about js client.on("debug", console.log)
its that laggy I can barely scroll
Authenticated using token TOKEN
The API is listening on port 3000
The API is listening on port 3001
Using gateway wss://gateway.discord.gg/?v=6&encoding=json
[ws] [connection] Connecting to wss://gateway.discord.gg/?v=6&encoding=json
[ws] [connection] Connected to gateway wss://gateway.discord.gg/?v=6&encoding=json
[ws] [connection] Identifying as a new session
[ws] [connection] Setting a heartbeat interval for 41250ms
[ws] [connection] Sending a heartbeat
READY 46771e61bda5af5c701e9d9f8949c24f
[ws] [connection] Heartbeat acknowledged, latency of 297ms
these all look fine
how about this js setTimeout(() => { console.log(client.user) },10000)
at load (C:\Users\Cools\statusbot\handlers\command.js:15:36)
at C:\Users\Cools\statusbot\handlers\command.js:29:27
at Array.forEach (<anonymous>)
at C:\Users\Cools\statusbot\handlers\command.js:29:14
at FSReqCallback.oncomplete (fs.js:152:23)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fyre@1.0.0 start: `node src/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fyre@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Cools\AppData\Roaming\npm-cache\_logs\2020-03-25T23_59_38_205Z-debug.log
C:\Users\Cools\statusbot>```
If you want a specific code shown in the bot, I'll show it.
I believe it's due to this one so I'm going to put it.
const { ownerid } = require("../../loaders/reader"); //get ownerid from botconfig file
const { RichEmbed } = require("discord.js");
const errors = require("../../../utils/errors.js"); //better errors
const usage = require("../../../utils/usage.js"); //better help-messages
const { prefix } = require("../../loaders/reader") //get prefix from botconfig
const { Client, Collection } = require("discord.js");
const bot = new Client();
bot.on("ready", () => {
module.exports = {
config: {
name: "botstatus",
aliases: ["status", "dogbotstatus"],
usage: "sb!botstatus",
description: "Put the status.",
},
run: async (bot, message, args) => {
if (message.author.id !== ownerid) return;
message.delete()
if (message.author.id === ownerid) {
let args = message.content.split(" ").slice(1).join(" ");
let split = args.split("-");
let url = args[2];
const channel = member.guild.channels.find(channel => channel.name === "status");
if(channel) channel.send("<@&692499448089280552>", {
embed: {
color: 0xFFFF00,
author: {
name: message.author.username,
icon_url: message.author.avatarURL
},
title: ":information_source: :Dogbot: Bot Status",
description: split[0],
timestamp: new Date(),
footer: {
icon_url: message.author.avatarURL,
text: message.author.username
}
}
});
}
}
}
})```
null @quartz kindle
@astral yoke is that perhaps one of your command files
are you making a new client
@quartz kindle Any other ideas of what I could do, it is important that I get this fixed -.-
no idea
try reinstalling discord.js
try testing a new file with only the basic discord.js code
then slowly add your code back in
omg, this whole time... it was a typo
where? lol
const
express = require("express"),
discord = require("discord.js"),
bodyParser = require("body-parser"),
chalk = require("chalk"),
fetch = require("node-fetch"),
pretty = require('express-prettify'); // <<<<<<
cors = require("cors"),
url = require("url"),
db = require("quick.db"),
app = express(),
client = new discord.Client();
ah yes
oh lmao
very annoying HAH
sometimes cleaner looks make it harder to find those things
anyone know how to get rid of this permissions issue?
0|index | 25-03 20:19:23.718: at RequestHandler.execute (/root
/node_modules/discord.js/src/rest/RequestHandler.js:170:25)
0|index | 25-03 20:19:23.718: at runMicrotasks (<anonymous>)
0|index | 25-03 20:19:23.718: at processTicksAndRejections (internal/process/task_queues.js:97:5) {
0|index | 25-03 20:19:23.718: name: 'DiscordAPIError',
0|index | 25-03 20:19:23.718: message: 'Missing Permissions',
0|index | 25-03 20:19:23.718: method: 'post',
0|index | 25-03 20:19:23.718: path: '/channels/692488724008927333/messages',
0|index | 25-03 20:19:23.718: code: 50013,
0|index | 25-03 20:19:23.718: httpStatus: 403
0|index | 25-03 20:19:23.718: }
I already do a check for send messages permissions, but for some reason it still keeps returning that
client.users.cache.get(msg.author.id).send(`:no_entry_sign: [**Missing Permissions**]: I don\'t have the **Send Messages** permission!\n`);
return;
}```
check for embed/image/links permissions
check for embed/image/links permissions
@quartz kindle That did it. I didn't have the "ATTACH FILES" permissions. Thanks!
Ok
How to make a command different for each server the bot is in for example !twitter sends A different link for each server?
you could make an object, something like:
let links = {
"SERVER_ID", "LINK",
"SERVER_ID", "LINK",
...
};
and then do
if (command == "twitter") {
if (links[message.guild.id]) {
message.channel.send(links[message.guild.id])
}
}
Thanks for your help and sorry for the dumb questions but would it be harder to make it so the server can program the command themselves and I don’t have to do it?
You would need a database to do that
Okay is there like A video tutorial you recommend?
im not a JS dev so I can't really help you with any details
I’ve done a lot of HTML/CSS and not much JavaScript
can your bot use an emoji from another shard?
yes
Are snowflakes from https://top.gg/api/docs a String object?
They're strings most of the time to support languages like JavaScript etc that don't exactly work well with integers like snowflakes
how about for user property in the vote event of the webhook?
my code is in #topgg-api
Try outputting it somewhere and see if it's actually accessing it properly
I don't speak d.js
alr thx
do you speak dblapi.js though?
I speak typescript
Is there a way in discord.js that I can make it so only I can run a certain command in any server but the server staff can’t?
@willow sparrow check if the message.author.id matches your ID
i'm still kinda new to c++ but can anyone tell me the best use case for std::int_fast16_t?
been readin docs and i am confusion
std::cout << "silence peruvian" << std::endln;
i'm still kinda new to c++ but can anyone tell me the best use case for std::int_fast16_t?
probably int that is written and read faster than just normal std::int_16_t
Hello.
Trying to make a seperate status bot where I can announce the status of my main bot for when I restart it or something like that.
I have this announcement command.
const errors = require("../../../utils/errors.js"); //better errors
const usage = require("../../../utils/usage.js"); //better help-messages
const { prefix } = require("../../loaders/reader") //get prefix from botconfig
module.exports = {
config: {
name: "status",
usage: "db!status",
description: "Announce about the status of DogBot."
},
run: async (bot, message, args) => {
message.delete()
if (message.member.hasPermission("ADMINISTRATOR")) {
let args = message.content.split(" ").slice(1).join(" ");
let split = args.split("-");
let url = args[2];
message.channel.send("<@&692499448089280552>", {
embed: {
color: 0xFFFF00,
author: {
name: message.author.username,
icon_url: message.author.avatarURL
},
title: ":information_source: Announcement",
description: split[0],
timestamp: new Date(),
footer: {
icon_url: message.author.avatarURL,
text: message.author.username
}
}
});
}
}
}```
How would I make it so it would find a channel, named "bot-status", then send it?
I've tried something but I got an error so I removed it.
guild#channels#cache.find
Then?
the function can be c => c.name === "bot-status"
then use .send
Okay okay
didn't notice that :v
how what
then use that?
discord.js error help
make sure d.js is installed?
that's an awful lot of dependencies
cleverbot.io is dead
why do you still have that
why do you have eris
you're using discord.js
xd
npm i
npm i am so sorry for what this guy have done
vague
ok thankyou
at IncomingMessage.<anonymous> (C:\Users\solan\Desktop\bots\cad bot\node_modules\dblapi.js\src\index.js:118:25)
at IncomingMessage.emit (events.js:228:7)
at endReadableNT (_stream_readable.js:1185:12)
at processTicksAndRejections (internal/process/task_queues.js:81:21)
(node:16992) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:16992) [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.
``` can someone help me with this?
with the discord bot list api
if you could show where the code where the error is happening it would help ngl
const DBL = require("dblapi.js");
const dbl = new DBL('token', bot);
dbl.on('posted', () => {
console.log('Server count posted!');
});
bot.on('ready', () => {
setInterval(() => {
dbl.postStats(bot.guilds.size);
}, 3600000);
});
i updated to the new discord.js v 12 and this happens
why do you have eris
@pale vessel because her bot is copycat
That returns the amount cached users on v11 yes
Just ask your question and if people can help they will
eh tru
async def ping(url: str):
ping_var = "-n" if platform.system() == "Windows" else "-c"
try:
proc = await asyncio.create_subprocess_shell(
f"ping {url} {ping_var} 1",
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE
)
stdout, stderr = await proc.communicate()
print(stdout.decode())
print(stderr.decode())
s = stdout.decode()
try:
#s = str(subprocess.check_output(["ping", url, "-c", "2"]), "utf-8")
if platform.system() != "Windows":
ar = s.strip("\n\r").split("\r\n")[-1].split(" ")[-2].split("/")
return f"{ar[0]} ms", f"{ar[2]} ms"
else:
#s = str(subprocess.check_output(["ping", url, "-n", "2"]), "utf-8")
ar = s.strip("\n\r").split("\r\n")[-1].split(" ")
return ar[-7].strip(","), ar[-4].strip(",")
except Exception as e:
print(e)
except Exception as e:
print(e)
return "ERR", "ERR"
this
doesnt work
no output
it was working fine before i added the asyncio but it was blocking so no bueno
@commands.command()
async def lolping(self, ctx: discord.ext.commands.Context):
embed = discord.Embed()
lol_ips = {
"North America (NA)": "104.160.131.3",
"Europe (EUW)": "104.160.141.3",
"Europe (EUNE)": "104.160.142.3",
"Australia (OCE)": "104.160.156.1",
"Latin America (LAN)": "104.160.136.3"
}
m: discord.Message = await ctx.send("Pinging...")
c = 1
embed.description = "Note: These pings are from Canada, yours may vary"
for i in lol_ips.keys():
p = await ping(lol_ips[i])
embed.add_field(
name=i,
value=f"{p[0]}, {p[1]}",
inline=False
)
await m.edit(content=f"Pinging {c} of 5...", embed=embed)
c += 1
await m.edit(content="", embed=embed)
and there's how it's used
@twilit rapids but it says undefined in statuse
bot.users.size
allso i am full new with js
What version of d.js are you using
^12.0.2
If you're on v12, use bot.users.cache.size
thanks
is making a db call every time something occurs (e.g. .daily gives you economy) super inefficient after?
it is recommended to store it in a cache and then update db every once in awhile
If your bot is big I'd suggest going with the latter
how big is considered big to do that
It depends
the thing I'm worried abt is the bot sometimes cutting off, and it wouldn't update the db
if it's just in the cache
i mean update every min or so
I also have to check if the user updated it's info don't I?
its
since I don't want to update every single user every minute
true
You can do a combination of both, prioritize certain queries, and run cached updates in a seperate process or something
bot.guilds.cache.forEach(guild => {
message.channel.send(`${guild.name}`);
message.channel.send(`Total ${bot.users.cache.size} members, Total ${bot.guilds.cache.size} Servers `)
})
})```
don't leak it
ok?
delete the screenshot
its sending that total mems, total servers message in every mssgh
i want that
it should send this total mssg once
not with all server names
guild.members.cache.size
u didnt get it
nope
message.channel.send(`Total ${bot.users.cache.size} members, Total ${bot.guilds.cache.size} Servers `)```
then put it outside forEach smh
i am new bruh
hey anyone can explain how can we get a list of users reacted on a particular message? [im using discord.py async :/ kinda outdated]
try upgrading
^
:c
heyyyy you're a python peep
message.reactions? 
@slender thistle Thats not async branch
does anyone have any idea abt this https://ptb.discordapp.com/channels/264445053596991498/272764566411149314/692662805593063494
@wooden bear upgrade but also https://discordpy.readthedocs.io/en/v0.16.12/api.html?highlight=react#discord.Client.get_reaction_users thats for async
and i'm pretty sure that's what you're looking for, but you're much better off updating
I mean an easier way todo a ping command is to use run_in_executor() and the Python Ping module
or
use Sub process in the threadpool rather than a future cuz im pretty sure that might be whats fucking you
thanks, it helped!
how?
like - threads and stuff is all new to me
import asyncio
async def run(cmd):
proc = await asyncio.create_subprocess_shell(
cmd,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE)
stdout, stderr = await proc.communicate()
print(f'[{cmd!r} exited with {proc.returncode}]')
if stdout:
print(f'[stdout]\n{stdout.decode()}')
if stderr:
print(f'[stderr]\n{stderr.decode()}')
asyncio.run(run('ls /zzz'))
and this is right from asyncio's docs
import concurrent.futures
with concurrent.futures.Threadpoolexecutor() as pool:
result = await loop.run_in_executor(pool, func, args1, arg2, etc...)
also im pretty sure you're pings will be invalid as it'll bounce of the DNS
alot of times pinging stuff without any other cookies / headers will just mean it gets Pinged off a DNS but meh if it works it works ig
if you mean did i forget to pass pool in the first param yes
but no loop is the event loop
so where do you get loop?
easy way to get it if you havent got client / bot object is asyncio.get_event_loop()
if you have the bot object getting passed just use bot.loop.run_in...
yh
oki
bot.on("guildCreate", guild => {
guild.owner.send(`Thanks for adding me in ${guild.name}! You can use .help to discover commands. here is our support server link: \n h `);
const logChannel = bot.channels.resolve("692393527908368394")
logChannel.send(`Bot was added in ${guild.name}`);
});```
will it dm if the owner adds the bot?
i think yes
with concurrent.futures.Threadpoolexecutor() as pool:
result = await asyncio.get_event_loop().run_in_executor(pool, "ping", url, ping_var, "1")
print(result)
``` prints nothing
you didnt give it the function
import concurrent.futures
with concurrent.futures.Threadpoolexecutor() as pool:
result = await loop.run_in_executor(pool, func, args1, arg2, etc...)```
and what if the owner dont add the bot? if his admins add it. still owner gets this dm?
so..what would i put for func?
also remove it being async if you're running threadpool
oki
yes
oki
@edgy heron Please refrain posting invites 
ok so
async def ping(url: str):
ping_var = "-n" if platform.system() == "Windows" else "-c"
def pshell(url: str):
return str(subprocess.check_output(["ping", url, "-c", "2"]), "utf-8")
try:
with concurrent.futures.ThreadPoolExecutor as pool:
s = await asyncio.get_event_loop().run_in_executor(pool, pshell, url)
print(s)
try:
#s = str(subprocess.check_output(["ping", url, "-c", "2"]), "utf-8")
if platform.system() != "Windows":
ar = s.strip("\n\r").split("\r\n")[-1].split(" ")[-2].split("/")
return f"{ar[0]} ms", f"{ar[2]} ms"
else:
#s = str(subprocess.check_output(["ping", url, "-n", "2"]), "utf-8")
ar = s.strip("\n\r").split("\r\n")[-1].split(" ")
return ar[-7].strip(","), ar[-4].strip(",")
except Exception as e:
print(e)
except Exception as e:
print(e)
return "ERR", "ERR"
this is my code
and one of the excepts is printing __enter__
nvm
forgot the () on ThreadPoolExecutor
oh xD
np
I need some help, on glitch there's an error. Can't seem to find it. Any way I can find it?
show error
i think a better question would be
what's happening
:p
anyone know how to upload a file in node js using the http module and formidable?
or can link me to an article?
i can't find any tutorials that aren't using express.js
@earnest phoenix every code is fine.
no
i mean
what is happening
that you say theres an error
why do you think there's an error
like.
It says it also can't find ("discord.js")
the full stack trace maybe?
did you to npm install discord.js?
and show full stack trace
show. the. entire. stack. trace. tho
How.
copy and paste?
no.
not your code
the stack trace
your error
also when you paste code
do this
The stack Trace is the logs right?
no. its the error you just showed me
Basically yes
F
It just basically says that it also can't find discord.js tho
Can't find module discord.js
why are so many people using glitch. on. mobile
XD
GAH
Mine can't either @charred jetty
@raven urchin ok
glitch bad mobile bad xD
It's Glitch problem
My bot has been down for a couple of days
honestly, if it's a glitch problem, then thats an instance of "you get what you pay for"
Mine Happened 3-4 days ago :/ idk if it's the code or glitch
Not everyone can afford a pc.
what does that have to do with glitch?
and try uninstalling and reinstalling djs?
if you have issues with "cannot find X" on glitch, run enable-pnpm in the console
@quartz kindle how to run that
he literally said in the console
try running your bot again
why on phone
Oop
Glitch is the worst to use on phone, if you need to make one lil adjustment then sure, understandable..but a whole bot together
people are sometimes just morons
Im making a warn cmd rn
if you have autopunish
Nope
ok
lol
manage messages is a perm about any staff would have
Np
for warns i personally require manage messages yeah
i just know nadeko requires ban , cuz autopupnish
Is glitch secure ?
If you put your project on private then yes
But probably VSC is the best (in my opinion)
https://github.com/cryy/quiccban/blob/master/quiccban/quiccban/Services/Discord/Commands/Modules/ModerationModule.cs#L55 old code but you can see perms i require for each cmd
Then who's better heroku vs glitch?



