#development
1 messages · Page 797 of 1
😓 ```py
def check(m):
try:
return m.author == ctx.message.author and m.channel == ctx.message.channel and int(m.content) > 0 and int(m.content) < 11
except:
print('failed...',m.content)
return False
try:
message = bot.wait_for('message', timeout=300.0, check=check)
print('completed check!!!',message)
message, user = pending_tasks[ctx.message.author]
except asyncio.TimeoutError:
await ctx.send('Timeout')
else:
await ctx.send('Cool, thanks!')
print('im not sure whats going on...',message, user)
selection_message = await bot.wait_for('message',check=check)
i really thought there would be a better way of cancelling old commands 🤔
hey guys im using discord.js
so?
whats yours
Mines a pikachu
whats yours
@grave jacinth same
ok xd
@vagrant tree you dont need
message, user = pending_tasks[ctx.message.author]```
at all
you need to await wait_for
that gives you your message object
what you think about glitch
that check will ignore any events that are not acting within the time frame of X user in X channel
i would lower your time out
i understand you're trying to limit how many of those checks you have going at once
i would keep a standard dict with userId and a Bool if its really needed
set bool to false when the task is done
if its not its set to true
if when we check the userId in the dict its true we just return or do something there
@grave jacinth It works fine for small bots but if you plan to do anything intensive get a VPS if possible
i switched from python to js...Translate the code is kinda aids 
yep
and one handles alot more
ok i need host or vps
Im working with modules to get it a bit better 🙂
y did u even switch from py to js
yes, thanks for the help. half understood code from stackoverflow is a trap
i dont suppose its possible on a new command to kill any existing commands from the same author?
not rlly easily
you start getting into rather advanced areas of asyncio at that point
ok. im just gonna let this thing execute twice. i dont see any easy solution to this right now... maybe ill try again another time
i mean that code will only trigger once
once that check is true itll fire
and thats it
wont fire again
how its meant to work is: ```
?command select A
<options 1-10 A embed shown>
10
<show option 10>
my issue:
?command select A
<options 1-10 A embed shown>
?command select B
<options 1-10 B embed shown>
5
<show option 5A>
<show option 5B>
one way is to somehow disable/cancel existing waiters, another way is to track states in memory
since select A and select B are separate commands, they will be treated separately. if you want one of them to override the other, you could have some variable tracking the current state, and have both commands read/write to the same variable to figure out which page is being shown right now
i am really surprised this is not a common issue
its not a common issue because people rarely use separate commands that await for options
and when they do, its because they want people to open both options at once
and also, users will rarely ever type both commands, they will answer the first commend before attempting to open the second one
await ctx.send(embed=embeded,content='Search details')
def check(m):
try:
return m.author == ctx.message.author and m.channel == ctx.message.channel and int(m.content) > 0 and int(m.content) < 11
except:
print('failed...',m.content)
return False
try:
selection_message = await bot.wait_for('message',check=check)
except asyncio.TimeoutError:
await ctx.send('Timeout')
else:
await ctx.send('Cool, thanks!')
print('selection message = ',selection_message)
selection = selection_message.content
you know that will never time out now right?
that js?
well since i dont actually know how to cancel a previous im going to just get the timeout working and move on from there
yes i need to work on that
@modest maple thanks for all the help. much appreciated
np
Hey CF you know what RuntimeError: Timeout context manager should be used inside a task means?
it's from discord.py on a command
okay so would it be better for times mutes to set a timeout if it's within 5 minutes or something like that to more accurately mute at a specific time rather than being on the minute or several? like accuracy > scalability idk
I always went with checking the mute database (or whatever) every 5 minutes and checking the times
I think setting a timeout for every mute just wouldnt be a good idea (on a bigger bot)
well a setTimeout for anything within small time
i would use a timeout and also store the timers in the db, to resume the timeouts on process restarts
shouldnt be much of a problem to have a few thousand timeouts running
const moment = require('moment');
const Discord = require('discord.js');
const ayarlar = require('../ayarlar.json');
const snekfetch = require('snekfetch');
var prefix = ayarlar.prefix;
module.exports = async client => {
client.appInfo = await client.fetchApplication();
setInterval( async () => {
client.appInfo = await client.fetchApplication();
}, 60000);
require("../util/dashboard.js")(client);
console.log('>>Playing updated.');
console.log('Bot joined.');
console.log(`[${moment().format('YYYY-MM-DD HH:mm:ss')}] BOT: ` + client.channels.size + ` channel, ` + client.guilds.size + ` server ` + client.guilds.reduce((a, b) => a + b.memberCount, 0).toLocaleString() + ` Online!`);
var Games = [
`🚀 ${client.guilds.size} Server | 🚀 ${client.users.size} User`
];
setInterval(function() {
var random = Math.floor(Math.random()*(Games.length-0+1)+0);
client.user.setActivity(Games[random], { type: "STREAMING", url: "STREAMLINK" } );
}, 2 * 2000);
};```
😥 Old bot
if your bot is that big that requires tens of thousands of timeouts, you could split and group them in batches of 1 second or 5 seconds or something like that and round the timers to that
another option would be to combine the best of both worlds. have an interval running every minute or 5 minutes or so, and fire a timeout for each mute that will expire in less than the interval minute(s)
I'd just use a Cron system
Just set time events so when it's X time Tigger the event with a payload of users etc...
Yeah they recommend using node-fetch now instead
how 2 watch for redis expire event
ie i set the value like so, how do i watch for its expirey
I've never been an avid linux user but im looking into moving from windows server.
I do need some help (and if anyone is good with it and willing to help hmu)
but i do have a question, what are the replacements for exe's in terms of actual running applications? Like right now I run my mongodb.exe and it's like a legitimate application in the task bar. Instead is it going to be like a service? Or what alternative etc. I've no idea at this point
i know that but how does that work, im just making an example out of it
most have a linux counterpart
...
}```
```client.expire(id, idYouPicked)``` should work from what the docs say @earnest phoenix
https://redis.io/commands/expire
like rn i can login to my vps and there's a mongodb.exe app running on the taskbar what's the replacement
you can set it up to boot with the server
ah so like a background service
yeah
interesting okay. thnx for that
np
@slim heart also, if there are programs that don't typically run as daemons, you can create service files to make it run as one
okay, ill have to lookup how to do that, sounds great tho
ye
Oh my bad
🤦🏻♂️
Misread what you said
For that try https://redis.io/topics/notifications
That's what currently holds their "watch or notification on whatever " events
All the commands affecting a given key.
All the keys receiving an LPUSH operation.
All the keys expiring in the database 0.
This is what is currently possible with it
If that doesn't help then I'm sure what you are looking for exists but I can't find it at the moment and don't know it off the top of my head
Does anyone know why this doesn't work?
newMember.roles.every(function (value) {
if (oldMember.roles.find(r => r.id == value.id) == null) {```
I'm trying to list the roles that are changed. This is indeed under guildMemberUpdate.
Actually, I have a feeling it was working. Lol
hmm
Maybe not, okay here ya go
//...
var Changes = {
unknown: 0,
addedRole: 1,
removedRole: 2,
username: 3,
nickname: 4,
avatar: 5
}
var change = Changes.unknown
//...
var addedRole = ''
newMember.roles.every(function (value) {
if (oldMember.roles.find(r => r.id == value.id)) {
change = Changes.addedRole
addedRole = value.id
console.log(addedRole)
}
})
//...
case Changes.addedRole:
log.send({embed: {
color: 0x0099ff,
title: 'Role Added',
thumbnail: {
url: `${newMember.user.displayAvatarURL}`,
},
author: {
name: "FrogBot",
icon_url: `${config.avatar}`,
url: "https://www.patreon.com/HephBot",
},
fields: [
{
name: 'User',
value: oldMember.displayName,
inline: true,
},
{
name: 'Old Roles',
value: oldMember.roles.map(r => `${r}`).filter(r => r !== `@everyone`).join(' '),
inline: true,
},
{
name: 'Role Added',
value: `<@${addedRole}>`,
inline: true,
},
],
timestamp: new Date(),
}})
///...```
And honestly, I don't know if I'm on stable or master, is there a way to check?
Package.json what version of discord.js
11.5.1
So you're using stable
Good to know 😛
I believe anyways, as far as I know 11.5.1 is stable 12 is master but I could be wrong lol
Works for me
newMember.roles.every(function (value) {
if (oldMember.roles.find(r => r.id == value.id)) {
change = Changes.addedRole
addedRole = value.name
//console.log(addedRole)
}
})```
This returns @earnest phoenix
I personally don't think it should, anyone know why it does?
Please @ me if you know what's up. I'm still confused but I'm taking a break. I can use any help anyone will provide.
Is <!DOCTYPE html> really required in HTML
🤔
@slender thistle no
but most browsers put it in when you inspect element if its not included
ty
you their API
when i do the command s!say it deletes the command but doesnt echo it, what did i do wrong
also ive decided to rewrite the entire bot i did yesterday on my pc rather than that glitch site
nevermind lol
let not = /no(o+)t/i;
console.log(not.test("nnoott"));
// -> true
i don't get why this returns true, to my understanding "+" only lets the "o" repeat not the "n" or "t"
have you tried not copypasting code
answer here @earnest phoenix https://support.glitch.com/t/how-to-fix-referenceerror-applytext-is-not-defined/12694
Is there any plugin to Discord.js for easy bot management and statistics monitoring?
Id like to get stats, charts over installs/usage, server directory etc for the bot, and Id hope someone made something standardised plug-and-play for discord.js
how would i iterate over all guilds in which my bot to find guilds from which i have ids?
forEach
client.channels.get('channelid').then(channel.delete())
.then is not a function?
i need to wait for this output though
how can i make a anti invite command?
for some reason when i tag my bot on my phone it responds, but through my laptop it doesn't, and I've no idea why :')
Does anyone know which permission is needed to check audit logs
I think it was manage guild but I have forgotten
VIEW_AUDIT_LOG
Really
That became a perm
lmao
Oh no sry
I asked it wrong
I meant the invites my bad
MANAGE_GUILD
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
I didn't find it on that link
I think it requires a combination of create invite and manage guild
They really need to make a perm just to read invites
I dont think so
but they need to add hierarchy to channel overrides and add a permission for modifying slowmode separately
@lament tusk use <@id> and <@!id> i think this is the problem ;)
!@
@slender thistle
Oh on Phone this is without
@earnest phoenix #502193464054644737
nvm it's @!
i was doing it wrong for a long time too lol
self ping lol
it used to be to differentiate members with nicknames
if the member had a nickname set, your bot would receive !id instead of id
but now its not like that anymore, your bot pretty much always receives !id
anyways if you want your bot to handle mentions, it needs to handle both versions because you never know
¯\_(ツ)_/¯
how can i make a ping for help command in d.js latest stable?
client.ping
:|
what do you mean?
when i mention the bot i get an embed
Thank you
Linking back to this post because I still need help
https://discordapp.com/channels/264445053596991498/272764566411149314/681685893529993339
||bump||
It currently returns @everyone whenever a role is updated, therefore posting the user roles, and then @everyone is the one added, no matter if I add or remove anything.
addedRole = newMember.roles.find(r => !oldMember.roles.has(r.id));
removedRole = oldMember.roles.find(r => !newMember.roles.has(r.id))```
these should work better
I need a shard if my bot is in this server?
Bot has started, with 20703 users, in 108 channels of 4 guilds.
Ni
No
You need to shard when you get close to 2.5k guilds
At 2.5k guilds discord won't let you login unless you shard
Thank you
@earnest phoenix thanks a lot!
@lament tusk np
What's a shard?
a shard is a discord connection
once a bot reaches 2500 guilds, sharding becomes required, which means splitting your bot into multiple connections
so a single connection doesnt get overloaded
do you do that in programming or there's support for that, in Discord .NET for example
i know there is a property of shards, i just need to add more of those?
is D# the same as discord.net?
No they're not the same but using them can be quite similair depending on what you're trying to do.
DSharpPlus and Discord.Net both have really easy sharding anyway ¯_(ツ)_/¯
An unofficial .Net wrapper for the Discord API (http://discordapp.com) - discord-net/Discord.Net
It seems there's a dedicated class for it, just DiscordShardedClient
no.yardım
seems so, yeah
(and yes ik pm2 i'm just doing this for a specific program that can manage the pm2 so obv i cant host it on there lol) also that's what i do on bat but i'm turning into linux
ah alr thnx
what's like the standard directory for all the files to be held for a server in linux?
i remember like something but idk
for user files? it depends, could be /root or /home or /username
or even /home/username
most likely when you connect via ssh, it should default to the correct folder
for things that the server should be hosting, not like for personal use
so like the place where id put all my bot files and applications to be ran
like rn in windows i just have all my files in C:/Workspace
also where would things like database data go?
I ran npm init -y on node.js but it didn't really work.
what didnt work
npm init -y
@slim heart i put them in the default folders
/root/bot1 or /home/bot1
whatever the ssh opens by default
same with databases, if a db is only used by one project, put it in its folder as well
if the db is used by many projects, put it in a dedicated folder
yeah should be fine
i basically use whatever ssh defaults to as my workspace
since i dont use the server for anything other than the things im hosting
right
@pine bear explain what you mean by "didnt work". what didnt work? what did you want to happen and what did happen?
Uhh, it either says that you shouldn't jive the npm without the reply or that the token is uncertain or undefined.
That doesn't help much

@modern sable
random emotes in #memes-and-media please @earnest phoenix
Still doesn't help my question
he mentioned you, it's you, stop
y e s
Ahem
at item.request.gen.end (/rbd/pnpm-volume/7662943d-6ec2-4cd3-8f5f-911407c3e786/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15)
at then (/rbd/pnpm-volume/7662943d-6ec2-4cd3-8f5f-911407c3e786/node_modules/.registry.npmjs.org/snekfetch/3.6.4/node_modules/snekfetch/src/index.js:215:21)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)
(node:325) 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:325) [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.```
help
i am trying to make webhook sand when bot ready
and code
@pine bear what you said makes no sense and gives us 0 information about the actual problem. what are you actually trying to achieve?
const hook = new Discord.WebhookClient('675984258011234304', process.env.webhooktoken);
hook.send(" ", {username: 'Spidey Bot', avatarURL: '', embeds: ["hii"]});
});```
a method not allowed is a strange error to get when using a built in djs function. try doing npm i discord.js to update it?
do hook.send(...).catch(console.log)
I'm trying to achieve the download of discord.js
@pine bear master or stable?
Of discord.js?
yes
@pine bear do you have node.js installed?
Yes
did you do npm init and follow the instructions?
at item.request.gen.end (/rbd/pnpm-volume/7662943d-6ec2-4cd3-8f5f-911407c3e786/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15)
at then (/rbd/pnpm-volume/7662943d-6ec2-4cd3-8f5f-911407c3e786/node_modules/.registry.npmjs.org/snekfetch/3.6.4/node_modules/snekfetch/src/index.js:215:21)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)
name: 'DiscordAPIError',
message: '405: Method Not Allowed',
path: '/api/v7/webhooks/675984258011234304?wait=true',
code: 0,
method: 'POST' }```
@quartz kindle
it will ask you for things like package name, description, author, etc... you have to fill them out
also dont forget to use the cd command to make sure you're in the right folder, ie, the folder where you want to install discord.js and begin your bot project
yeah method not allowed
it's strange i don't know how that happen other than being out of date or djs is error
cd command?
oh so you have never worked with a cmd/terminal
actually unless the webhook is invalid
Yes
@storm bluff are you sure you have the webhooks id instead of something like the channel id?
yes
@pine bear are you using windows?
try and copy it in again
Yes, but it's a really old version of it.
@storm bluff the only way i can reproduce is by putting in a bad ID, where are you copying it from to make sure?
did you follow this? https://discordjs.guide/popular-topics/webhooks.html#using-webhooks
where did you copy it from not asking for confirmation lol
yes
Idk, but the last update was made some 5 years ago.
you dont know if its windows XP, windows vista, windows 7, windows 8, windows 10?
Windows 10
then its not a problem
you have your cmd open right?
the command window
type node -v
what does it say?
i copied the id you gave me @storm bluff and it's indeed an invalid id
Run it on Node.js?
in your command window
and for reference this would happen if the id is right and token is wrong
👌
command window?
yes in cmd catra
Sorry, somethings I don't know sometimes.
Er. . . how do I figure out how to open that window?
start menu -> type cmd
win+r, type "cmd", press enter or this ^
http://prntscr.com/r7hfss how do you change the color of these buttons on the site?
css in your long description
Idk, I found command prompt
yes open that
that is it
now type node -v and press enter
I'm not very good with css but I know how to change objects that I created, in the case of dblsite I don't know what the name of the css is
right click -> inspect element
It says 'node' is not recognized as a internal or external command, operable program or batch file.
then node is not installed correctly. if you installed it, you need to restart your pc after installing
Also if it is installed verify that it's in your PATH
the installer does that, but updated path is not applied until restart
I forgot how you restart one of these things
Hold down power button?
16

Are you trolling?
No lmao
what
Why is someone trying to get into programming when they can't even computer

honestly you might be better off using something like discord bot maker
DBM dev: you got the money?
I think have to pay for that, you honestly think I didn't try that yet.
Yep,
try running node -v again
Tried, same results
download version 12.16.1 LTS
install again
when the install finishes, restart your computer again
make sure it shows this part like this
add to PATH must be enabled, like in the image above
alright
now where do you want to have your bot? which folder do you want to install it in?
Uhh, is it optional where I want it in?
yes
alright, so make it, then open it, then do this:
hold the SHIFT key in your keyboard, and right click anywhere inside the folder
and chose "open command window here"
wait that's a thing
I didn't actually know that 
i've been cding all these years
^
hue
eh I use windows terminal so
I used windows PowerShell because there was no other option
once the command window opens, it should show the full path of your folder right before the blinking line, ie: C:/users/myuser/desktop/mybotfolder>_ or whatever location you put your folder in
Yes
now type npm init
it will ask you a few questions, like the project name, description, author, etc
just follow the instructions
you can skip any question by pressing the enter key, it will just use the default value
It says test command.
just skip it
So that's done
That's neat.
how go back to the command prompt, open it again if you closed it (by using the shift-rightclick method)
and type npm install discord.js
now you need to create a file called index.js or yourbotname.js whatever you prefer
but the file needs to have a .js extension
you need to enable extensions in order to see it
you enable extensions like this
Quick question : how to webhook in djs
send a webhook to discord?
(this is for creating and sending a discord webhook to discord, it has nothing to do with top.gg webhooks or any other)
just to make sure we're on the same page
I think I did it.
It only says
-node_modules
-package.json
-package-lock.json
Uhh? Something went wrong.
I think the file package-lock.json was supposed to be yourbotname
Mhm, I see
now you need a code editor, a program to help you code
there are many out there, like notepad++, sublime text, visual studio code, brackets, atom...
just chose one, download it and install it
they're all free
ok
now open myfile.js in your code editor
this file is where you will program your bot
now since you're using discord.js, you should check the discord.js documentation and guides for how to use it
you can skip the parts about installing and setting up linters and whatever
now you're just teaching them nodejs at this point
Lmao
@pine bear anyways, read up those links, study it in detail, its not a easy subject, programming can be quite hard to get into, and you need lots of logical thinking. for example, the basic example is this: ```js
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
console.log(Logged in as ${client.user.tag}!);
});
client.on('message', msg => {
if (msg.content === 'ping') {
msg.reply('pong');
}
});
client.login('token');```
the first lines setup discord.js in your code, then you add some functions for what the bot should do, then you login to discord with your bot token
this is a barebones setup
you can copy and paste this into your myfile.js if you want to start with that
then save the file
and you can run your bot by going back to your command window and typing node myfile.js
then its just a matter of coding, saving, running, etc
Tim
@native jay about 2 weeks
and all this time the bot should be online?
yes
preferably yes
Visual studio code doesn't seem to be making my file show
just right-click myfile.js and go to open with -> vistual studio code
okay... github is giving me trouble... let me make some changes
github is down for now
It doesn't show that option for some reason.
Nvm, I know it was a folder, and I forgot to move the file to that folder.
Tim, I respect you.
@warm marsh @_@
can a single js websocket server handle the stress of about 100-400 users inputting something in the span of 3-5 seconds, if yes, would it have any significant memory/cpu usage complications
depends on what the server has to do with each request
if it just some mild in-memory text processing, it should be easily able to handle thousands per second
as the complexity of the request increases, so will the cpu usage
memory wont be affected much, unless you're working on large payloads
most complexity would be incrementing a counter i think
rest of it can be processed elsewhere without handling input
then you should be fine
aight thanks
Does client.login('token'); does token have to be the bots actual token?
yes
guess
Who tf keeps pinging me?
Is there any js api for instagram
for get user data?
Post in a channel when a specific user posts
there's no such thing as lang secific api
Ok, I have the first few code down
How do I get the JavaScript code into the bot now?
make sure you have your bots token in the code, must likely under client.login('token'), and then you want to run node myfile.js
U just put the js code in index.js
the bot IS the file you created earlier, remember?
all code should be inside that file
Ok
If you think your bot is ready to run launch a terminal, use the CD command to go to ur bot folder and then do npm start
Wait no
U should do npm index.js
he named his file something else
so it should be node myfile.js or whatever he named the file
Mmm,
hey guys i upload my all documents glitch but doesnt working
what?
i make bot on atom
yea
and i upload all documents glitch
How can I queue Playlist in ytdl-core
@grave jacinth what type of documents?
js
so, do u using command handler?
for now yes
is there any sort of way to set like a globally accessible variable for any node program without have to add anything to the code like no requiring or anything like that especially since i want it accessible from programs that are in all sorts of different locations so i'd have to write it purposeful for each different one (and no absolute paths)
I'm stuck on actually getting the bot online
you've been here all day mate, it's safe to assume you expect someone to write it for you at this point. watch some guides, stop wasting people's times when you can very easily figure it out for yourself.
Mmm
what are the ```js
Error: Client network socket disconnected before secure TLS connection was established
/* and also... */
Error: socket hang up
errors?
because
my bot keeps getting them
oof
@twilit rapids
Might want to use Contabo
the next one is
4 GB RAM / 2 CPU Cores for 4 Euro a month
@twilit rapids we just got contabo's biggest Dedi which is <333
bruhh what should i do 
BRUH
should i restart my bot
@grizzled raven what is your problem?
restart
@modest maple do you have it with /56 IPv6 subnet
are you sure?
@grizzled raven try restart
timo has that ever happened to you?
i'd have to ask Zotz
me?
@modest maple also, do you have 10 or 20 CPU cores
we have 10
ok ill take that as a yes
for now
@grizzled raven just try an restart
Chip is 74 servers away from 20k now
and the bot still works, it just triggers events multiple times

i guess ill risk it
and yes it was to you TheNoob
@twilit rapids we have /64 IPV6
what IPV6 do?
Uh, a bit hard to explain
ok
0.5 core / 2 GB RAM
ok its back nevermind
would you be willing to support DMV as a trade off @twilit rapids xD
ill ask Zotz how much the site is using atm
and how much we have spare
should be enough tho xD
You probably have a Discord server for it
Send it to me in DMs
And @wide ridge, take a look at: https://contabo.com/?show=vps
Powerful VPS hosting – SSD storage, snapshots, virtual machines equipped with brand new hardware, 100 mbit/s unlimited traffic, starting at just 3,99 EUR/month.
Starting at 4 euro a month
you have to buy a domain seperate, right?
Yeah
huh
with free https
free cpanel aswell
i wasnt smart enough to be able to process how you would set that stuff up so i passed on contabo
@grizzled raven you restarted the bot?
yes
it works?
yes
@twilit rapids Ill Dm you when Zotz gets back to me
alright
i dont wanna say yes until we know its not gonna affect anything
hey rules bot offline ?
Does anyone have any idea why guild.name returned undefined with the guildCreate event? This happened only once, I just tested it twice and it did work then.
@twilit rapids
what?
He asked a question about a bot that has nothing to do with this server
hey rules bot offline ?
-wrongserver @earnest phoenix
@earnest phoenix
Hey! We think you have our server mistaken. We do not provide support, help, or advice for any bot. You need to click on the "Support Server" button on the bot's page, not the "Join Discord" button at the top of our website. If there isn't a button that says Join Support Server, then we can't help you. Sorry :(
What's a shard
You can login using e.g. FileZilla and upload your files via your computer
you can use git if its on github
Then via console you can also login and run your code
git pull origin master
@twilit rapids The big sad, Zotz said he'd have to politely decline
That's fine
Does anyone have any idea why
guild.namereturnedundefinedwith theguildCreateevent, whileguild.idreturned like expected? This happened only once, I just tested it twice and it did work then.
anyone has a reason for this?
So I have been trying to code a bot to just send random messages to a specific channel every minute or so. The problem I run into is that when trying to use client.run(TOKEN) which is defined as my bot's token, I am met with an error "AttributeError: 'set' object has no attribute 'strip'"
What's your discord.py version
but guildJoin isn't listed on discord.js.org, are you certain that is a thing?
oh btw, I'm using discordjs
how would I check my discord.py version?
import discord
print(discord.__version__)```
@west spoke should I do something with the bug? Thank you btw
@elfin jasper send your code
@nocturne grove if it's working fine now, then it is not needed. If it happens again, I'd ask the d.js server.
What's the TOKEN variable looking like
its a dict looking at what hes got
It's a fucking set
i cant see the () properly
line?
where you define DISCORD_TOKEN
you have it surounded in either {} or () i cant make it out
remove that
Do you know what type {'something'} will be?
also
btw
your like
a year out of date in d.py version
using async rather than 1.3
@west spoke thank you! 👍
from dotprint(...)??? 
Yeah, that's not exactly recommended
i've been getting that feeling
I recommend getting the hang of Python itself first before getting to complex libraries like discord.py
https://www.learnpython.org this looks somewhat promising
apprecitated
@slender thistle not like its the offical docs or anything
:^)
Would you say that a one-hour delay between a repeated piece of code is long enough for it not to be API spam?
Does it only send one request?
It's three
I can make the delay longer if necessary but 1 hour is a nice number
Wait I assume bot.guilds.size is an API request?
Yep
Yeah so three requests every x time
I don't really mind what x is
That's what I'm asking
What should x be ideally
Oh so that wouldn't be anything to do with the API?
The library will fetch guilds for you and store them in bot.guilds
You're not even able to retrieve your bot's guilds via the api
Stuff like bot.fetchGuilds() would make sense to send HTTP requests
Basically I want to log the values of bot.guilds.size to a csv file
So in that case I wouldn't be sending any requests to the API?
No
Okay cool thank you
im stuck on how to add a user count to the bots activity status?
hey guys i cant made setStatus
What library @honest perch
@grave jacinth More details could help
js
ha ok
wait a sacond
client.on('ready', () => {
console.log(Botun hazır ve aktif ${client.user.tag} );
client.user.setActivity('!medet')
client.user.setStatus('idle')
setstatus dont working
My bot is supposed to have the code it needs to be online, but it isn't.
bana sormadı onu
Niye js diye cevap verdin?
:D neyse fark etmedin galiba
ya nebilm bana sordu sandım yeni sayılırım
I dunno, I have the token variable set up and client.login(token) it's supposed to work.
whistles violently
More code could help
Well, lets just say, I've done what I've done to make the bot appear online.
any errors
Yup, not helpful at all
Not that I can see
Yup, Chili is just as violently angry
Relax
this guys been in here all day trying to get someone to feed him code pretty much, don't give him any mind
const Discord = require('discord.js');
const client = new Discord.Client();
const prefix = "c!";
const token = "Token";
client,login(token);
OOF that's why
client,login(token);
ChillFish isn't chill 
Thx
lullllllllll
@true ravine 300mb sounds a bit too much, what does your bot do?
Lmao it looks like periods not commas
i assume so but does ubuntu come preinstalled with git?
nvm, your bot is not approved yet
did your IDE not even notice the fact that hell just got yeeted at that object?
its probably this server
Nah I'm not in this one because I'm not approved yet - only like 39 cached users
so yeah, the normal ram usage for that amount of caching should be about 70-80mb
not 300
It's just a basic aws vps so there could be all kinds of demons lurking on the machine I haven't discovered
what lib do you use? discord.js?
Yup
are you using pm2?
Yeah
and pm2 shows 300mb for your bot?
No I've only ever seen the ram usage when I restart the bot at like 18mb
On pm2 I mean
run pm2 ls or pm2 monit
Oof says 16 mb
well, 16mb is also not normal lmao
the node process itself should use about 40-50mb
alright that sounds more normal
The 300mb is total system usage so I was assuming most of that was taken up by the bot
But no
try running top
@slender thistle discord.js
assuming your system is linux based
Yeah ubuntu
Getting size of bot.users sounds like an idea
top should show you a list of processes, you can see what is using so much ram
Which is actual mem usage because I can only see percentage use
Things keep popping up and disappearing and some of them have very high res numbers
take a print and post it here
It says, SyntaxError: Unexpected token '=>' when I ran it on the terminal.
var removedRole = ''
if(oldMember.roles.map(r => `${r}`).join(' ') !== newMember.roles.map(r => `${r}`).join(' ')){
removedRole = oldMember.roles.find(r => !newMember.roles.has(r.id))
change = Changes.removedRole
if(!removedRole){
// check if roles were added
var addedRole = ''
addedRole = newMember.roles.find(r => !oldMember.roles.has(r.id));
change = Changes.addedRole
}
}```
Hey Tim, thanks for the advise, it's working really well now. A new issue that is occurring is it always defaults to added role, even if I remove a role. This is the code that is checking it.
you dont need to do that comparison
the removedRole line is enough by it self, you just need to check if it exists
@slender thistle would i put this ${bot.users} into the status?
removedRole = oldMember.roles.find(...)
if(removedRole) { change = Changes.removedRole; }
may i ask how to get its size
just add .size to it
var removedRole = ''
var addedRole = ''
// check if roles were removed
removedRole = oldMember.roles.find(r => !newMember.roles.has(r.id))
if(removedRole) change = Changes.removedRole
// check if roles were added
addedRole = newMember.roles.find(r => !oldMember.roles.has(r.id));
if(addedRole) change = Changes.addedRole```
I'll give that a gander
Or should I set removedRole and whatnot to null first?
yes, maybe add an if else if you dont want both changes, but most likely 2 role updates will never happen at once
Okay 🙂
no need to be null
no need to be a string either
it can be just var removedRole;
Ahh, good point
Okay
Any reason to use any over the others? I kind of use them all in my code.
Removing still throws this ->
4|bot | name: 'DiscordAPIError',
4|bot | message:
4|bot | 'Invalid Form Body\nembed.fields[2].value: Could not interpret "{\'guild\': {\'members\': {}, \'channels\': {}, \'roles\': {}, \'presences\': {}, \'deleted\': False, \'available\': True, \'id\': \'665790892539510804\', \'name\': "Frog\'s Gucci Land", \'icon\': \'0cb6ec6fc645716abb06832f25caae68\', \'splash\': None, \'region\': \'us-east\', \'memberCount\': 35, \'large\': False, \'features\': [], \'applicationID\': None, \'afkTimeout\': 300, \'afkChannelID\': None, \'systemChannelID\': \'665790892539510807\', \'verificationLevel\': 0, \'explicitContentFilter\': 0, \'mfaLevel\': 0, \'joinedTimestamp\': 1579214403013, \'defaultMessageNotifications\': \'ALL\', \'ownerID\': \'177188299943837696\', \'_rawVoiceStates\': {}, \'emojis\': {}}, \'deleted\': False, \'id\': \'676434165356560397\', \'name\': \'Voter\', \'color\': 193800, \'hoist\': True, \'position\': 16, \'permissions\': 104193601, \'managed\': False, \'mentionable\': False}" as string.',
4|bot | path: '/api/v7/channels/674548631461691393/messages',
4|bot | code: 50035,
4|bot | method: 'POST' }```
It throws it twice.
Adding does it successfully.
i love those errors
ngl theyre my favourite sort
just have a spazz out then works
let and const have a few differences, one of them is that they are strictly locked to the current scope, while var can bleed outside the scope.
another difference is that const will not let you change it after its defined, so its good for not accidentally modifying some data that should not be modified, while let will not let you create another variable with the same name, to prevent you from accidentally overwriting it
the error says you are trying to put and entire object in a field
it appears to be a guild object
ok that seemed to work, thanks!
I'm going to try something, if it does work, I'll laugh and tell you why.
hahahaha
It worked
case Changes.removedRole:
log.send({embed: {
color: 0x0099ff,
title: 'Role Removed',
thumbnail: {
url: `${newMember.user.displayAvatarURL}`,
},
author: {
name: "FrogBot",
icon_url: `${config.avatar}`,
url: "https://www.patreon.com/HephBot",
},
fields: [
{
name: 'User',
value: oldMember.displayName,
inline: true,
},
{
name: 'Old Roles',
value: oldMember.roles.map(r => `${r}`).filter(r => r !== `@everyone`).join(' '),
inline: true,
},
{
name: 'Role Removed',
value: `${removedRole}`,
inline: true,
},
],
timestamp: new Date(),
}})```
All I changed was value from
removedRole to ${removedRole}
lol
Thanks for being touchy JS
ah yes, that will invoke its internal role.toString() method
.toString all things
The high ram usage seems to be because of amazon related stuff, mysql and ubuntu. The reason it was displaying 300mb was because that reading was an average taken over a couple of seconds. I shall leave you to help everyone else now xd
@true ravine still seems like a lot, but makes more sense
mysql can use quite a bit as well
Yeah I use it for quite a few features so I guess it's understandable
Can someone explain how watching for votes works in JS?
My current script is...
dbl.webhook.on('vote', async vote => {
console.log(`User <@${vote.user}> (${vote.user}) just voted!`);
let a = await client.voted.get(vote.user)
if(!a) {await client.voted.set(vote.user, '1')}
else{
let b = +a + 1
await client.voted.set(vote.user, b)
}
await client.guilds.get('665790892539510804').channels.get('676434014759813150')
.send({embed: {
color: 0x0099ff,
title: `New Vote!`,
url: 'https://top.gg/bot/665786935251304468/vote',
author: {
name: 'FrogBot',
icon_url: `${client.user.displayAvatarURL}`,
url: `${client.user.displayAvatarURL}`,
},
fields: [
{
name: 'User',
value: `<@${vote.user}> (${vote.user})`,
},
{
name: 'User Vote Count',
value: `${client.voted.get(vote.user)}`,
},
{
name: 'Total Bot Vote Count',
value: `${dbl.getstats('665786935251304468').points}`,
},
],
}})
});```
The bot doesn't even respond when someone votes. I'm fairly certain I'm logging in correctly because if I do...
```js
await dbl.hasVoted(msg.author.id).then(async voted => {
if (!voted) return```
That check works just fine.
well
are you running the webhook webserver
and did you put the correct ip and port on dbl's website
webhooks are reverse APIs, instead of you making a request to the API, the API instead makes a request to you
const DBL = require('dblapi.js');
const dbl = new DBL("TOKEN", { webhookPort: 5000, webhookAuth: 'PASSWORD' });
I have that in my code as well.
you dont need to put await everywhere
.get and .set are not promises nor async functions
I started throwing that in because I wasn't sure why it wasn't seeing it. 😛
does the console log User just voted?
No
then your webhook settings are wrong
Okay, how should I go about fixing it?
what did you put in the webhook settings in the website?
check if your vps requires opening ports
it depends on the host
I have OVH
for example, google compute engine requires you to open ports in their control panel
check the ovh admin panel
Source ip i think 0.0.0.0/0
It doesn't like that 😛
tcp
ports 5000 in both
yeah that should do it
Now how do I test that? Should I restart my bot, and try voting? Or would the 'test' work?
the test should work
the 0's are ok
it means that it is listening on every IP address that the server has
hmm
I'm running Debian if that helps.
if ufw is not pre-installed, then all ports should be opened by default
not sure about debian
Maybe I'm doing something wrong with signing in then? However the check for if a user has voted works fine...
yeah because the check is a post request
its outgoing
you could try setting up a simple webserver and see if you can open it in your browser
is your website running on express?
ads
I don't think so.

I know I'm using apache2
actix-web
ok, so one thing you could do is set up a reverse proxy
basically the idea is
to create a second configuration in your website's config file, and apply it for a subdomain for example
ie: votes.mywebsite.xyz
and in that configuration, use the proxyPass options as above
the proxy should point to 127.0.0.1:5000
which is a localhost address
so votes.mywebsite.com gets internally redirected to localhost:5000 which is where your webhook is running
then in the webhook config in top.gg you can use http://votes.mywebsite.xyz/dblwebhook
i dont use apache so i dont have much experience with it, but you should be able to find solutions and guides
what is the best way to keep information about specific users e.g. if they select something in your bot, maintain that information for subsequent commands?
if you need it to last through bot restarts and crashes, a database
else, an object/array/map/collection in your code
Okay, thanks Tim, I'll give it a try
thanks
to keep track of a specific users info is it best to use message.author? then compare that to every new command to see if the author is there?
so i managed to get a prefix cmd working but when trying to make the embed to show the new prefix it says this
this is the code .setDescription('Set to ${args[0]}');
replace ' with `
Thank you
Hey @quartz kindle, I think I broke it all. You wouldn't know how to undo the proxy would you?
If I am trying to get a good bot to google and message the answer, what would the python code be?
iptables > ufw
@dense drift just remove the lines you added
I ran sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000, but then I did sudo iptables -t nat -D PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
It restarts just fine, I just can't get to the site anymore.
oh you did it through iptables
so you didnt change anything in your apache config?
you basically added an iptables rule to redirect ALL traffic from port 80 to 3000
which includes requests to your website
Right, however -D should've removed that
yeah it should
Has anyone got any previous Experience with Datomic Databases?
@dense drift run this sudo iptables -t nat -v -L PREROUTING -n --line-number
post the result
num pkts bytes target prot opt in out source destination
1 130 6600 REDIRECT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 redir ports 3000
2 0 0 REDIRECT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 redir ports 80
now run sudo iptables -t nat -D PREROUTING 1








