#development
1 messages · Page 747 of 1
it basically works like this:
what about tatsumaki's reminder
If youre looping a command
isnt the same action
aa
now I understood
its not okay because the command is automated and not actioned manually
ok
its not okay cuz it loops an API call
i hate having to make this cake bot
too much work because a random api for images of cake doesnt exist yet
console.log('Jirobo Kinder ')
});
client.on('message', message => {
if (message.content === prefix + 'jirobo') {
const jirembed = new RichEmbed()
.setColor('679ec5')
.setImage('https://imgur.com/gallery/XKuNlFc')
.setTitle('Kinder Bueno')
message.channel.send(jirembed)
}})
Why the image doens't appear ?
you need the direct link to the image
Thank u ^^ It works ^^
I have a question
Can I put my bot's website, but the website is still in development. Will it still be accepted, or will it be denied? It has the invite link in there tho.
™️
If no answers here go discord.gg/python at #discord-py channel, or discord.gg/dpy
possible to make a gitbook on android?
hi sorry im a dumbass how do i upload a file in a message with eris
need to upload image for command
actually can you use an image on your local machine on an embed how would you do that
mm provide the path to the image
thats what ive been doing
for an hour
do i have to do a complete path
do i require
def speak(speech):
global num
num += 1
print("Pink_Guy : ", speech)
Speak = gTTS(text = output, lang ='en', slow = False)
file = str(num)+".mp3"
Speak.save(file)
ctx.voice_client.play(discord.FFmpegPCMAudio(file), True)
os.remove(file)
def takeAudio():
input = sr.Recognizer()
audio = ''
with sr.Microphone() as source:
print("Say Fag...")
audio = input.listen(source, phrase_time_limit = 5)
try:
text = input.recognize_google(audio, language ='en-US')
print(f"{user.name} ", text)
return text
except:
print("Fag dont even know how to speak")
return 0
class Music(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command(aliases=["j"])
async def join(self, ctx):
hour = int(datetime.datetime.now().hour)
if hour>=0 and hour<12:
speak(f"Good Morning {user.name}")
elif hour>=12 and hour<18:
speak(f"Good Afternoon {user.name}")
else:
speak(f"Good Evening {user.name}")
speak("Its Pink Guy here, how may i help you?")```
wtf is wrong with this thing? lmao
fish heres the code
do Python at the start of ur code so it does the python syntax
makes things cleaner
and like i said
error
or no eroror
ctx.voice_client.play(discord.FFmpegPCMAudio(file), True)
have u acttually parsed it context
not sure, I don't use Eris
cuz doing ctx means nothing if you dont give it what it needs
bear this in mind ctx is just an object in reality
well i say that
but for simplicity sake we'll call it that
you cant call on somthing that it hasnt got
i have
it should be createMessage(content: string | object, file?: { name: string, file: Buffer })
so it should use the 2nd paramater
after the content
okie dokie so shall it be something like this ?
ctx.voice_client.play(discord.FFmpegPCMAudio(file), True)
thanks discord
msg.channel.createMessage("hello", {file: {file: require("./some/file/directory")}})
file needs to be a buffer
don't think they can resolve files
@grizzled valley urhm? how much python and discord.py experience have u got

they can resolve files but not by a path
what in god's name is ctx.typing() got to do with playing an audio file - just like logically thinking
google r u talking about the python code or Sammy's issue
Sammy
ah kk
note that you need to provide an absolute path to your file because fs tries to find it from your root project folder (where package.json is)
const foile = files[Math.floor(Math.random() * files.length)] fs.readFile(`${__dirname}/../src/CakeAPI/images/${foile}`, (err, f) => {
if (err) {
msg.channel.createMessage("oopsies an error has occured!")
bakery.loggr.error(err)
}
msg.channel.createMessage("hell", {file: {file: f, name: "cakeimage"}})
})
does this really not work
no
the object after the content just needs name (String) and file (Buffer)
also the name needs to end with the file extension .jpg as an example
great
ok then
so just msg.channel.createMessage("hell", {file: f, name: "cakeimage"})
yea
look at the docs, if the function for setting images accepts buffer, then yes
anyone know how to find the bot's highest role in a guild? (discord.js)
What version?
stable
find which one gives the most perms ig
Just go through the roles the bot has and get the highest?
Some libs also have a heiracy number too
ok, do you know how to get the client's member?
<Guild>.me
thank you! :D
Can anyone say how I can prevent the 500 error notification on the site https://top.gg/servers
it's a server error
you can't do anything about it
oh ok
so no promotion for my server 😦
at most it could be a csrf mismatch so a refresh might help but other than that there's really nothing else except waiting
ok, thanks for the help 😄
@pliant gorge was down for a bit and is now booting again. Shouldn't take much longer and it should be fixed
nice
how do I track who invited my bot
theres and event guildCreate but i dont think theres a way to track who exactly invited it
yea
@empty owl you could do that with the oauth redirect
When users invite your bot you can redirect them to your own website e.g top.gg/logthispath
You can choose where they are redirected
ok
That isn't always reliable
Yea not really reliable since you would have to update your botlist pages with the new invite too
so is it fine just to do guild.owner
Other users with manage server perms can invite your bot so not really
ah
The user could also just remove the redirect_uri part
but I can just do owner
This isn't 100% related to Discord bot development (it kind of is part of it), but how do you send a TCP request with (node)js?
I found this: https://gist.github.com/sid24rane/2b10b8f4b2f814bd0851d861d3515a10
and im trying it
node.js documentation: A simple TCP client
working..
doesnt have to be bot development btw
you guys know how some websites have an image next to the website title
how would i do that
a favicon?
You need to convert a png/jpg to an ico file which you can do online then put a "favicon.ico" in your website root
most browsers will pull it
.ico is not necessary it is not 2007 anymore
lol
thanks
modern browsers will accept today's standard image formats
Better to support that standard and it has less file size so it will load faster
it is a favicon
load speed is generally irrelevant
since it is such a small file it will get downloaded on a microwave within a second
plus caching
you risk quality with .ico s
You don't really need it to be HD if it's just a small icon
Hey guys having an annoying issue with my bot was wondering if you guys know the issue
it seems you're trying to require a module that doesn't exist
Hey dream thanks for replying and yeah i just can't wrap my head around the issue it's been awhile since hosting my own bot and now i am having this issue.
So you would think loader.js doesn't exist?
No, loader.js is an internal file nodejs runs
I actually don't know where the problem is exactly
you can verify you have all the packages you need in package.json
do node .
delete your node modules directory I guess and run npm i
might fix it?
looks like an issue inside a module
I'll try that again
make sure your package versions up-to-date also
ugh it's just such a mess tired updating and tried running npm i
would hate to trash this bot
12.5.0 i was on 12.13.1 earlier and it was doing the same thing from what i can remember
worth a shot tho
can you try using LTS
Sure thing! I'll give that a try right now 😛
alright cool
no problem
do you have windows-build-tools installed globally
don't think so let me do that totally forgot
did it in administrator didn't seem to help god dammit boys idk anymore ahaha i feel bad taking your guys' time as well
it's no big deal
@west raptor it was no use to pass it to a function, it always gave me the same number. :c
Already try different ways and none works
I just try to put the code inside the module so you don't have to do more work
Can i Filter Guild Regions? and when yes how?
library/language?
Discord.js v12-dev
client.guilds.filter(guild => guild.region /** Check region here*/)

ok zoomer
How do I get the array from this?
[ '626159042896723968': [Array] ]```
array["626159042896723968"]
assuming this is an object and not an array
{
'626159042896723968': [Array]
}```

Giving code without explaining
http://pls-fuck.me/7Xh539r.png any ideea what I can do?
https://npmjs.com/mysql 's .query() isn't asynchronous
make an asynchronous library then
would this work? js catch (err) { if(err === "RangeError: RichEmbed field values may not exceed 1024 characters.") { message.channel.send('\n' + evaled + '') } const embed = new Discord.RichEmbed() .setTitle('ERROR') .setAuthor('EVAL Warning', 'https://i.ibb.co/XpScxNQ/warning.png') .setColor('#ff4500') .setDescription('' + err + '') message.channel.send(embed) }
@wheat jolt is mariadb async
huh?
use mariadb instead
how can i catch permission error?
my music bot comes to the audio channel when I command to play music, then comes out without playing the music
and i just saw what you can do with owner property
its just message.author
almost then
cuz js message.guild.owner.send('') works
msg.guild.owner returns the guild owner
duh
not sure if the user of the guild member
In DiscordJS atleast message.guild.owner returns the guild owner (of course) as an GuildMember type. To get the guild owner as User type you need message.guild.owner.user.
well message.guild.owner(thing to do) works at the most things
but thats not why im here
how to catch the missing perms error?
uhmmmm
I know it has to do with the APIError type (https://discord.js.org/#/docs/main/stable/typedef/APIError) and that APIError has an error called MISSING_PERMISSIONS.
uhmmm
well... the source code of Discord.JS shows it's APIErrors are actually just numbers so....
so if i do: if(err.includes === "MISSING_PERMISSIONS") {} works?
I don't know....
try
if (err.code === 50013) { // 50013 represents the MISSING_PERMISSIONS error.
// Some code here.
}
I'm not even sure if that'll work tho
pls help me
internal/modules/cjs/loader.js:584
throw err;
^
Error: Cannot find module './resources'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/app/dist/app.js:3:21)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
Its cant find a file
- Glitch bad dont use
- It cant find the file so ig u gonna have to go look for it and give it the right file path
- Either no2 OR you dont actually have the module installed properly
./resources is referring to a local file
@modest maple why is glitch so bad? It works fine and i never has issues
How can add Numbers on enmap?
Glitch was not created for bot hosting
It still does what it should
Glitch is a collaborative programming environment that lives in your browser and deploys code as you type.
It does things other than what it's supposed to do
That, however, does not mean that it was created exactly for that purpose
its testing environment that means, you can test there your apps etc.
because look ram and memory ram only 128mb and memory 500mb
Its enough for me. Heroku is not good also. It has 550h of Hosting Time what id 22 Days
Unless they fixed it, that doesn't matter
hold up
Those "550 hours" ran for a month just alright for me
both of those sites are pretty useless if the bot gets bigger
or you want to add any decent new features
I think about buying a VPS cause Glitch does not Support Image Manipulation. What is cheap and good?
Contabo
Their VPS plans start at 4 euro per month
SkySilk have cheap prices
What of them is Good?
Depends on how much you are willing to pay. I suggest going through each website and comparing the specs and prices
Ok
Now uhm, anyone knows how to add Numbers in Enmap?
but not rlly worth unless u need big specs
Yeah
You store it like you store anything else in enmap
in quick.db is it .add(..) but what is it in enmap?
Read their docs...?
I can't find something there @twilit rapids
@slender thistle the worker dyno would continue to work forever, but yes they did fix that a while back
Like
You could have 5 apps all using worker dyno
And they would be on for the entire month without any issues
lol
lmao
What does “Discord.RichEmbed is not a constructor” mean. It didn’t use to say that.
would appreciate if someone could help please ty
what's your code, lib and lib version
are you sure you are requiring discord.js through "Discord"?
how to do secondary links like .setURL('url') but for regular text in like a field or so (richembed)
@surreal sage you mean hyperlinks?
y
i tried but it didnt work
that
discord.js
not in ' -<
works
👍
Mine still isn’t working
let server = client.guilds.get("589214763242750048");
server.members.array().forEach(m => {
...
});
``` Can someone tell me if I did something wrong here? Because it keeps saying "Cannot find "members" of undefined".
isnt it client.get_guild()
wait is it?
no it isn't
this is discord.js
@ocean rampart Maybe try using " instead of '
What?
that's irrelevant
the bot isn't in the guild or you're doing it before the guild data was downloaded @earnest phoenix
my bet is you're doing the latter
everything that interacts with discord and you want it to happen on boot, do it on your client's ready event
no
@flat pelican // @west raptor
the bot is in the server and i am trying to do like a list of servers with their members counted
no ads here
are you doing it in a command
or
command
recheck your id
otherwise check if the guild is availabe or not https://discord.js.org/#/docs/main/stable/class/Guild?scrollTo=available
Can anyone answer my question on why it continues to say Discord.RichEmbed is not a constructor please?
check the official example and compare it to yours
i checked the ID
@ocean rampart I dont find any problems. The only thing I can say i try reinstalling discord.js or change const to let.
that won't do anything
ik lol just to be sure
the difference between const and let is just scoping rules
ik
and immutability
i just know that const cant be changed while let can
thats kinda the idea
It says client is not defined now
are you sure you passed it down and its not mispelled?
Wdym

you dont need to import discord.js on every command usage or log in again per command
you defined discord after using it, you defined client after passing client through a parameter
you defined Discord under wherever you used it
or just trying to understand what the code actually means
wait really?
yes lol
nvm then
discord.js does it for you
if the content parameter is an object, it makes the options parameter the content
So everything in it is wrong?
not everything
Why does this
{
"server": {
"bans": {},
"mutes": {},
"kicks": {},
"warns": {},
"lockChans": {},
"configs": {
"punishLogs": "false",
"punishLogsChannel": "none",
"actionLogs": "false",
"actionsLogsChannel": "none",
"appLogs": "false",
"appLogsChannel": "none",
"xprate": 1,
"levelRewards": {},
"levelMsgs": "false",
"levelChannel": "none",
"levelMsg": "Congrats {member}! You've just hit level {level}!",
"premium": {
"enabled": "false",
"user": "none"
},
"prefix": "%",
"customItems": {
"customReplies": {},
"customCMDS": {}
},
"joinWelcome": {
"enabled": "false",
"channel": "",
"msg": "Welcome {member} to {guildname}! You are member {joinpos}!",
"embed": "false"
},
"serverBotBans": {},
"disabledCMDS": [],
"joinRole": {
"enabled": "false",
"role": ""
},
"levelOn": "true",
"rolePers": {},
"tempRoles": {
"add": {},
"remove": {}
}
},
"levels": {}
}
}
give the error
SyntaxError: databases/642304841170812939.json: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at /rbd/pnpm-volume/5e67cf9e-ab38-4576-ac99-0726c5933577/node_modules/.registry.npmjs.org/jsonfile/4.0.0/node_modules/jsonfile/index.js:33:18
at /rbd/pnpm-volume/5e67cf9e-ab38-4576-ac99-0726c5933577/node_modules/.registry.npmjs.org/graceful-fs/4.2.3/node_modules/graceful-fs/graceful-fs.js:115:16
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
I think u should put that in a hastebin
stop using json files as a database
Oh, I didn't do anything to the file, the temp role feature did.
json is fine as a database as long as its not a project too big
it's not fine lol
no it's not

ok i've been tought fake news
any moment you write it can go bye bye
you're doing IO operations which are sync and there's a high risk of having data corruption
would this work? https://hastebin.com/ufinediyol.coffeescript
oh yeah i've just never had that issue with my old bot since nobody uses them
json databases are fine if you want to have issues later on and literally want to break your keyboard
try it out and see
thanks bill
what
Embed = new .setColor('#ffff00') .setTitle('Invite Me To Your Dimension!')
Pls help fast i get this error:
at Object._errnoException (util.js:1022:11)
at _exceptionWithHostPort (util.js:1044:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1198:14)```
When i start my bot i get that error
i use phpmyadmin
Pls help 🙂
I actually don't know how to work any other database than JSON
good time to learn
star off with somehting simple and easy to use lol
And everything works fine in my databases, except for the temprole
zApex, learn sql first
idk start with quick.db at this point
then pick any database you think will work
like a basic sqlite if your app's small
I've tried learning sqlite, but I just can't understand it.
it said the same thing again
like sequelize?
yeah
How can you use something, without a clue how to use it?
BY LEARNING

instructions unclear
ORM frameworks basically write the sql for you
you won't just learn sql and know everything automatically
you'll get used to it as time goes on
oh yeah definitely, thats basically what coding is hahaha
over time you just know what to use
Well, yeah I know, but I've tried learning it in the past, and I just couldn't work it out.
i guess handling files is easier than using SQL commands if you know how to work with strings and things
how to change database name in mongoDB (cloud) ?
The only way I know how to get what I need is with this db.server.configs.tempRoles.add[member.user.id][i].role
Pls help fast i get this error:
at Object._errnoException (util.js:1022:11)
at _exceptionWithHostPort (util.js:1044:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1198:14)```
When i start my bot i get that error
i use phpmyadmin
Full error: https://hastebin.com/eyigijijun.rb
I did start and restart mysql server
sorry i don't use phpmyadmin and idk what's that
let finfo = await db.collection("factions").findOne({_id: "info"});
let list = "";
let members = 0;
for(var i = 0; i < finfo.count; i++){
db.collection("factions").findOne({_id: i}).then(fsinfo => {
let fserver = client.guilds.get(fsinfo.serverID);
fserver.members.array().forEach(m => {
if(m.user.bot) return;
members = members + 1;
});
list += `**[${parseInt(i)+1}]:** \`${fsinfo.name}\` (${members} members)\n`;
});
}
let embed = new Discord.RichEmbed()
.setTitle("List of factions.")
.setDescription(list)
.setColor("#ffa500");
message.channel.send(embed);
``` I use discord.js and MongoDB (not mongoose). The only thing I get in the embed is the title and no description about the factions. The console didn't upload anything so.. any idea of what's going on?
it might be due to the promise being resolved "later"
any clue on how to fix that?
@summer torrent I don't think its possible after researching on the legendary Google but here's a solution I found to "rename" a database. https://jira.mongodb.org/browse/SERVER-701
How to add Roles on v12-dev?
Can i make it so you need to have voted for the bot in order to use a command before the bot is approved and listed?
la dev, to a member?
well you probably can't do that without an api key
but without a lot of features being vote locked a ton yeah
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});``` how to use that webhook thingy
nvm
continue
People can't vote for your bot when it isn't accepted on the bot list yet
its accepted..
That was meant for @deft bobcat ^^
How to add Roles on v12-dev? please
oh
go read the docs @earnest phoenix
cant find something there.
everything you need is there
hook is a variable but what to enter there?
what
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});``` how to use that from the webhook?
use what
you need to have a webserver with an open port
webhooks are reverse api requests
is a discord webhook ok?
ah.....
but do i need that dbl.webhook
well
what is the value of it
nothing...
as i was saying, webhooks are reverse api requests, instead of you making the requests to the api, the api makes requests to you
so i dont have to do anything if i want to log that a user has voted?
pretty much
you just have to match the data
your api keys, add a webhook url on the api site etc
execute(message, args) {
async function execute(){
if (message.author.id !== '305771483865546752') return;
let evaled;
try {
evaled = await eval(args.join(' '));
message.channel.send(inspect(evaled));
console.log(inspect(evaled));
} catch (error) {
console.error(error);
message.reply('there was an error during evaluation.');
}
}
execute();
};```
the last line is giving "unexpected token ;"
even tough everything seems to be working
why do you have execute(message, args){ at the top @rugged minnow
because i'm separating each command in a separated file
execute takes no parameters
i always used it, but it shouldn't be the cause of the error
Well your error is the fact that you're missing a }
god i need a new monitor and a new pair of glasses
@safe jungle defBase and defIV are strings, so the + operator concatenates them
Also, execute(message, args){ will cause an error
It inst a function definition
your { isnt needed
i defined it in my main script
so why do you have an opening bracket when calling it?
try removing the ";" at the very bottom
I don't remember if it plays a role or not
tried that, it still gives an error, but it turns out that @amber fractal was right
i forgot to close a }
const DBL = require("dblapi.js");
const dbl = new DBL(tokenf.dbl, client);``` i got these and how to setup on vote event
One message removed from a suspended account.
One message removed from a suspended account.
i am
One message removed from a suspended account.
One message removed from a suspended account.
but i dont fully understand
const DBL = require('dblapi.js');
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});```
that with webhookport etc
and wheres the "client" at the "db" var?
One message removed from a suspended account.
hat
i dont fully understand
hat
dbl webhooks are unrelated to discord
ik
One message removed from a suspended account.
^
One message removed from a suspended account.
One message removed from a suspended account.
this is my code. I get this error ```js
TypeError: Cannot read property 'channelID' of null
res isnt defined
no
Yes
literally that's what that means.
You have if(res) return
if it got there res isn't defined
and it got there
and just the fact that that's what that error means.
you probably meant if(!res)
how to set the Extension of an iconURL?
what
that the iconURL ends with .gif
not with .webp or .png
yes and
by checking the hash?
discord will automatically return the correct format even without the extension
even if it's a gif
message.guild.iconURL({extension: ".gif"})?
i remember updating cdn methods for discord.net
is that above right?
uh no
you can't make up your own methods
consult with the docs
@modest maple here is dbl's icon without an extension https://cdn.discordapp.com/icons/264445053596991498/a_eadf00405ab375668c76da10ee95f646
got it
and here is someone's animated avatar without an extension https://cdn.discordapp.com/avatars/181875147148361728/a_19f12060b7338f1a5808e0682ca7a2b4
ah the client doesn't render it
discord does return the correct format though

click on the link and open it in a browser
how do i add the a_ between the url?
wasnt exactly a hard fix to just check if a_ is before it
it won't render as animated because discord's dev team is incompetent and they depend on the extension of the url lol
yup
the api//cdn returns the correct format 🤷♂️
Any better solutions (discord.js-v12.0.0-dev). At rn it rounds into 1 min if secs is > 30
let up = client.uptime;
let secs = Math.round(up / 1000)
let mins = Math.round(secs / 60) let hours = Math.round(mins / 60)
let days = Math.round( hours/24 )```
help?
cannot find module
read the error
i read
and what does it tell you
cannot find module
@earnest phoenix time to mute
now recheck the folder name and the name in the code
ok
lol
-m @charred loom Help vampire, constantly asking about questions that can be easily solved by learning the language they were coding in. They were warned not to ask those similar types of questions, but failed to heed the warning. | 1 week
🤐 Muted zZCipricaZz#1442 (@charred loom)
can i have help
you dont need to ask, what is your question?
what am i looking at exactly?
well
im so confused it makes zeros sense
i just copy pasted it from the visual code
We cant help something we cant read
a sec
hehe
wot
well
um
lol
it makes zero sense
no
format it
lol
u doing it in visual studio or?
ye
like anyone would
take a screenshot
then post the screenshot
if your gonna be annoying im not gonna help

so dont be like heHEHhHEHEE
i cant read that shit
i dont think anyone could

ehm
:/
Anyone know any open source JS bot that use Eris library and is splited to multiple files (like 1 or more commands in one file)? I just want to see how to split...
Have you read the docs
thanks
illegal
@unique nimbus Yes, I already readed docs, but I can't find nothing
you know splitting stuff up into files is the basics of the programming language right?
Depends... I know this on Python, but in JS... I'm new in JS. I switched to JS due performance issues.
So how would I cancel a task? I want to make it so if I reload the extension, the tasks themselves will also be restarted.
Here's my code:
def cog_unload(self):
#what would I need to put here?
async def activity(self):
await asyncio.sleep(2)
while not self.bot.is_closed():
with open("playing.txt", "r") as file:
playing = file.readlines()
await self.bot.change_presence(activity=discord.Game(name=choice(playing)))
print("ACTIVITY UPDATED")
await asyncio.sleep(10800)
async def topggstats(self):
await asyncio.sleep(2)
while not self.bot.is_closed():
await self.dblpy.post_guild_count()
print("DBL STATS UPDATED")
await asyncio.sleep(1800)
@commands.Cog.listener()
async def on_ready(self):
self.bot.loop.create_task(self.activity())
self.bot.loop.create_task(self.topggstats())
if you reload the extension they should auto close anyway
Which is faster? sql or nosql?
oh
I didn't realize
Previously when I was using the tasks decorator they wouldn't, so I assumed it would be the same
thx chillfish
you cant measure database performance from that alone, it depends on many other factors and there are dozens of different databases, both sql type and nosql type
either way if on_ready() reloads it will create new tasks with the subrutines
typically nosql databases are capable of reaching faster speeds, depending on platform, implementation, disk speed, etc... because most nosql databases implement BASE instead of ACID
i mean you can always find out by doing await client (or bot).all_tasks(loop=none)
not sure if client will work with that or not
but asyncio.all_tasks(loop=none) should return a list of all tasks
But anyone, can anyone help me...?
the question is how df did u get performance issues with python
Eris bots are similar to discord.js bots @broken jay
xD
The code is very similar... you can follow any guide written for discord.js, but swap the discord.js methods (like message.channel.send()) for their Eris equivalents (like message.channel.createMessage())
hey does anyone know why there is some inconsistency in tagging users/bots on mobile vs desktop
sometimes the raw message will be <@! or <@
begin with*
Yup
how add bot to this server (my bot approved)?
it should already be added
how
i can tag any bot here without a nickname and it's the same issue
@prime cliff i can't @mention it
Theres tons if tutorials on internet..
they sucks
for each guild, store the guilds specific prefix in a database
tip: then learn sql/nosql
typically guilds won't set a custom prefix so you should only donit if they get added
also opinion but if you're using js id recommend mongodb
use orm if u dont know sql/nosql
lol
or a querybuilder like knex for javascript
mariadb >>
const { MessageEmbed } = require("discord.js");
class Ban extends Command {
constructor(client) {
super({
name: "ban"
});
this.client = client;
}
async exec(message, args) {
let user = message.mentions.members.first() || message.guild.members.fetch(args[0])
let reason = args.slice(1).join(' ')
let Case = this.client.db.get(`cases_${message.guild.id}`)
if(Case === null) Case = 1
let e = new MessageEmbed()
.setAuthor("Ban | Case #" + Case)
.setColor(this.client.COLOR_RED)
.addField("User", user.user.tag)
.addField("Moderator", message.author.tag)
.addField("Reason", reason)
let ch = this.client.db.get(`modLog_${message.guild.id}`)
let channel = message.guild.channels.find(c => c.id === ch.id)
channel.send(e)
user.ban({reason: reason})
}
}
module.exports = Ban;```
Error
why
ch is undefined
how?
what is output of db.get(`modLog_${message.guild.id}`)?
There's no entry called modLog_${message.guild.id} in the database...
There is.
well discord says otherwise
remove .id
oh fu
just learn sql, takes like 30 mins tops to get the basics
You're trying to get id of id
¯_(ツ)_/¯
Is Discord Dead?
no
yes
discord pings seems little bit higher than normal.
Welcome to Discord's home for real-time and historical data on system performance.
Thats why my site is semi broken
seems a bit higher than normal
Only 900ms xd
basic ping
hmm maybe time to check google cloud status
wait what was it
kk pings just higher
thanks discord .bots wont go up : P
client.on("message", message => {
if (message.author.bot) return;
if (!db[message.author.id]) db[message.author.id] = {
xp: 0,
level: 0
};
db[message.author.id].xp++;
let userInfo = db[message.author.id];
if (userInfo.xp > 100) {
userInfo.level++
userInfo.xp = 0
message.channel.send("lvl up!")
}
const args = message.content.slice(config.prefix.length).trim().split(/ +/g)
const cmd = args.shift().toLowerCase();
if (cmd === "level") {
let userInfo = db[message.author.id];
let embed = new Discord.RichEmbed()
.setColor(0x4286f4)
.addField("Level", userInfo.level)
.addField("XP", userInfo.xp + "/100")
message.channel.send(embed)
}
fs.writeFile("./database.json", JSON.stringify(db), (x) => {
if (x) console.error(x)
});
})```
heelllp
It is sending the same message repeatedly each time I execute the command
writing to that file on every single message (- bot messages) seems like a bad idea
what do you mean "the same message repeatedly each time I execute the command"
Does it start looping
Or does it just always give you the same output when you use it
hmm
You should also at least be consistent about your use of semicolons 
json files aren't supposed to be used as a database
and you're constantly updating values on every message
Don't use json
migrate to an actual database otherwise you're going to experience a lot of data corruption
use sql or mongodb
hmm okay
how would you fix a bot responding to any other 2 character prefixes besides the prefix the bot is set to?
by actually checking for the prefix
As for the multiple replies, I don't see anything in there that would cause that so I'd guess it's
A) you have multiple instances of the bot running
B) you registered the listener more than once
I have in this line (discord.js) https://prnt.sc/qb6w6j
yes but you aren't actually checking for the prefix
you're just checking for the length of it
ah, ok
if (!msg.content.startsWith(prefix)) return
Please write my bot for me ty
pay me
I’m a cheap stingy person and refuse
I want hours of your hard work given for free plz
"do all the work for me for free" essentially
Hello, I am trying to make an unban all command for a game. I cannot figure out a way to do it, though I'm thinking it would have to do with a for loop to loop through each banned member and unban them. A friend suggested I do bannedUsers.forEach(m=>message.guild.unban(m.id)), but that did not work. Below is my code. If you have any other questions, feel free to ask.
if(msg === `${prefix}restart` || msg === `${prefix}unbanall`) {
if(message.author.id !== '242425064631435264') {
message.reply('no.')
}
else {
guild.fetchBans()
.then(bans => message.channel.send(`${bans.size} users have been resurrected.`))
.catch(console.error);
}
}```
This is the unfinished code without a way to unban all.
well the first thing is that you will be rate limited and that is api abuse
that's fair, though there will not be much people to be unbanned
also forgot to include but guild is defined as message.guild
the max that are going to be unbanned is around 10-12 and the command is only going to be run every couple of hours or days
@restive furnace omfg THaNk y0u
still api abuse
may i please have the definition of api abuse then? i'd like to make sure i don't accidently do it then, because i usually consider something like rainbow role change api abuse, or something like 60 things every minute
@opal halo np
Discord's API rate limits requests in order to prevent abuse and overload of our services. Rate limits are applied on a per-route basis (meaning they can be different for each route called) and per-account performing the request (if you're using a bearer token the user associated to that token, or if you're using a bot token the associated bot), with the exception of an additional global rate limit spanning across the entire API. Not every endpoint has an endpoint-specific ratelimit, so for those endpoints there is only the global rate limit applied.
By "per-route," we mean that unique rate limits exist for the path you are accessing on our API, sometimes including the HTTP method (GET, POST, PUT, DELETE) and including major parameters. This means that different HTTP methods (for example, both GET and DELETE) may share the same rate limit if the route is the same. Additionally, rate limits take into account major parameters in the URL. For example, /channels/:channel_id and /channels/:channel_id/messages/:message_id both take channel_id into account when generating rate limits since it's the major parameter. Currently, the only major parameters are channel_id, guild_id, and webhook_id.```
warn There is currently a single exception to the above rule regarding different HTTP methods sharing the same rate limit, and that is for the deletion of messages. Deleting messages falls under a separate, higher rate limit so that bots are able to more quickly delete content from channels (which is useful for moderation bots).
Because we may change rate limits at any time and rate limits can be different per application, rate limits should not be hard coded into your bot/application. In order to properly support our dynamic rate limits, your bot/application should parse for our rate limits in response headers and locally prevent exceeding the limits as they change.
warn Routes for controlling emojis do not follow the normal rate limit conventions. These routes are specifically limited on a per-guild basis to prevent abuse. This means that the quota returned by our APIs may be inaccurate, and you may encounter 429s.
For every API request made, we return optional HTTP response headers containing the rate limit encountered during your request.
Rate Limit Header Examples
X-RateLimit-Limit: 5
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1470173023
X-RateLimit-Bucket: abcd1234
X-RateLimit-Global - Returned only on a HTTP 429 response if the rate limit headers returned are of the global rate limit (not per-route)
X-RateLimit-Limit - The number of requests that can be made
X-RateLimit-Remaining - The number of remaining requests that can be made
X-RateLimit-Reset - Epoch time (seconds since 00:00:00 UTC on January 1, 1970) at which the rate limit resets
X-RateLimit-Reset-After - Total time (in seconds) of when the current rate limit bucket will reset.
X-RateLimit-Bucket - A unique string denoting the rate limit being encountered (non-inclusive of major parameters in the route path)
or a more simple version
Bot Rate Limits are as follows:
A global 50/10 rate limit (meaning, this is the maximum # of messages a bot can send currently across all of discord).
A 5/5 per server rate limit.
A 5/5 global DM rate limit.
The rate limit applies to message creation and editing.
If your bot is big enough and is hitting the global rate limit legitimately, reach out to us and we'll increase it.```
at that point you could've just linked to the section in the docs
i read the docs but was still a bit confused, the 50/10 rate limit means 50 requests every 10 minutes?
so it could be classified as fine but also not be classified as fine for what i'm trying to do
not really no
cuz diffrent requests have diffrent limits
send messages and deleting messages have higher rate limits then editing messages for example
rip me
what's wrong?
also, "Clients are allowed 120 events every 60 seconds"
i know that bulk deletion events limits are higher, but i can't find anything for getting banned users and unbanning them
im also not sure whether to continue this in here even though it somewhat pertains to bot development
ratelimits are dynamic
const Discord = require("discord.js");
const client = new Discord.Client();
const Net = require('net');
const client1 = new Net.Socket();
client.on('ready', () => {
console.log('Bot is ready!');
client.user.setActivity('people chat.', { type: 'WATCHING'});
})
client.on("message", message => {
try {
if (message.channel.id == channelid) {
message.delete();
client1.write('Discord | ' + client.username.substring(0,5) + " | " + message.content);
}
} catch(err) {
console.log(err)
}
});
client1.connect({ port: port, host: host }, function() {
try {
client1.write('Discord has joined the server.');
} catch(err) {
console.log(err)
}
});
client1.on('data', function(chunk) {
try {
client.channels.get(channelid).send(chunk.toString())
} catch(err) {
console.log(err)
}
});
client1.on('end', function() {
process.exit();
});
// Request an end to the connection after the data has been received.
//client1.end();
client.login(token)
that's why there is no official "this is x ratelimit, this is y ratelimit"
token, channelid, port and host exists
but client and client1 dont work in each others functions'
though its still a max of 12 members and its not being run every minute or so, im not getting how thats pushing it
i mean ig u can find out if ur accounts get banned or not? xD
uh yea will do
i personally dont get why ur banning then unbanning everyone
instead of kicking or somthing
but okii
so they can't join back and it makes it easier for the rest of the game
what's even easier is creating a role that disables access to the game channel
^^
ill try that
and it is also a less aggressive approach
what about removing a role, is that still pushing it?
you can delete the role
delete then readd
its actually worse deleting and creating roles
or permission overwrites?
oh
they have a rlly rlly Heavy Rate limit with making roles
but just changing channel perms would work
would it not?
they won't be creating a role every 10 seconds lmao
create role
add role to people who are supposed to get kicked/banned
once game is done delete the role
rinse and repeat
couldnt you just have the same role
and just add and remove it from the members
rather than delete and remake etc..
yes, but you then again come back to the same thing as bulk ban/unban
ig but making the role and deleting it you still gonna have to add it to everyone
gradually, and it's still ratelimit minimalization
if u do it gradually might as welll keep the role
and just remove it from members etc..
especially if its happing per member as they go along the game
would be 'bulk'
but wouldnt require you to delete, add role to everyone then delete the role
add role to a member who lost + 2 requests for creation and deletion
vs
add role to a member who lost + n requests for every member
the goal is to minimize the chance to get a ratelimit
yes but u can still have the role existing
no
at the end of the game you still have to remove the role for every member
instead of just deleting the role
you keep missing that point
1 request vs n requests for every player
i don't think there is a way for the bot to delete the role, is there? im looking at the docs and can't see anything about deleting a role
discord.js
the closest thing i can find is .delete but that deletes the guild itself
everything is a class
the createRole method on the guild should return the role object iirc

someone help me at #topgg-api
if someone knows the answer or can help they'll respond
hi today the discord bot om i dont know why but don't want to start
it only does it on the server machine
on my own machine Visual studio code working perfectly
but when i use it on a server machine node index.js command
then I get an error and it doesn't start
I haven't run into such a mistake yet and have no idea what anyone can help me
ERROR CODE⬇️
(node:11818) UnhandledPromiseRejectionWarning: Error: getaddrinfo ENOTFOUND discordapp.com discordapp.com:443
at errnoException (dns.js:50:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26)
(node:11818) 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:11818) [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.
server machine running an ubuntu
so far no problem has ever occurred
it's saying that
you can't connect to the WS server
because it wasn't found
there is nothing you can do and just wait for Discord
but if the discord itself is bad, then why is your computer running

One message removed from a suspended account.
maybe it's discord or youself
as I remember it being when your internet dies (I think)
weird
canary has this interesting new mention that happens for bot users that should only be happening to nicknames
it's using <@! in place of <@ now
@valid frigate that is normal for Discord when a user has a nickname their mention will be <@!
literally it's also happening to users without a nickname
Not sure why Discord made it that way but you will have to parse that format too
the inconsistency is really confusing and idk why they made that silent update to canary
It's not an update that has always been in Discord in all clients
no? i was able to mention my bot fine here on mobile, desktop and canary fine since around the end of last month
cant have a nickname
Discord does weird shit
does your bot's widget link thing automatically update itself? https://prnt.sc/qbb7gv
and I did the server count thing but it still says no server count: https://prnt.sc/qbb9wc https://prnt.sc/qbb9p9
dblapi.js updates every 15 minutes if you're auto posting
ah, thanks

