#development
1 messages ยท Page 798 of 1
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 5000 -j REDIRECT --to-port 5000 I just ran that... I don't know if it'll help
that wont do anything on its own
try this iptables -I INPUT -p tcp -m tcp --dport 5000 -j ACCEPT
that should allow port 5000 in iptables
Okie Dokie
although it should be already allowed by default
make sure to allow ssh
How would you do that?
allow port 22
its already allowed, else you wouldnt even be able to connect or use your terminal
I was just making sure since I fucked it up once
Fair enough ๐
I changed my ssh port and ufw/iptables was having none of it
I had to vnc and change it
i tried blocking some weird ip addresses in google compute engine, turns out those were required for some reason and broke all connections
lmao
i had to reset it from the dashboard
I was about to reset mine
but then I realized that for GG that the vnc ip is completely different than the vps ip
so ufw wouldn't block it and shit
nice
How do I change the channel where the invite is created for discord server list
how do i make it so if i say "$help" it shows all commands
like i keep trying
but i keep messing up
btw im using discord.js
Example
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');
where would i put my commands
I think I hit a roadblock, I can't get the bot online.
hello! i made a reaction collector and i'm wondering, is there a way to hmmm... maybe snippet of my code will explain:
var mg = await message.channel.send(feedback);
var mg = await mg.react('๐');
mg.awaitReactions(filter, { max: 2, time: 60000, errors: ['error'] } )```
returns TypeError: mg.awaitReactions is not a function
is there a way to react to and collect reactions from the same message?
i wanted to make it more convenient for the user
how do i use the discord list bot?
with your hands
@knotty fiber message.react() returns a promise for a messageReaction not a message, and mg is being replaced by it
so just remove the second var if you dont need it
var mg = await ...send();
await mg.react();
mg.awaitReactions()
Dumb Question: If i was to get banned from this server, would my bot be taken down from the website?
yes
k thx
Why would you need to ask that 

how do i pull a no. of items out of an array, ie. items 0 to 19?
@sick cloud what language?
node.js
Sorry, don't really know that
but
Perhaps you could make a new array
and make a for loop or something to go through the old array and select the items you need
it's an array of 58 and i just need to split it into groups of 1-20, 21-40 and 41 to 58
I think array.prototype.splice would work for what you're trying to do
js in general
ยฏ_(ใ)_/ยฏ
in theory since splice mutates the list too if you're just looking to make it into groups of 20 you can just run the splice repeatedly
splice(0, 20)
is there a reason why list[-1] would return None when len(list) returns 15 and list has items. (python)
last item of the list is None
I massively overlooked that possibility lmao
thanks
that's probably it unless something weird is going on
>>> l = [1,2,3, None]
>>> l[-1]
>>> l
[1, 2, 3, None]
>>> print(l[-1])
None
>>> l = [1,2,3, None, 5]
>>> print(l[-1])
5
i have a new one here, if i have an object with things like "United States": "US",, can i search for the value and get the key
like search US and get United States
instead of the other way round
get the JSON values and iterate over them ๐ค
I believe so
can anyone tell me why when i start the bot im unable to type in the terminal anymore? like if the bot errors out and doesnt start than i can still type but when it does start i cant
its an easy fix just terminate the terminal and start a new one but its annoying
oh, ok didnt realize
alright i'm having a fat issue
what is wrong with this bit of code
it's only outputting one thing
it's getting both bits of date from my JSON
but only one of them is being logged to the console
your only console logging the nameID?
Yeah I'm using it as a test point
They also have all the other console logs being ignored with //
to see what's going on
It doesn't need to be logged i just have that there so i can monitor one of the values
Ahh far enough
it's only outputting one value for both
I didn't notice they were all running the same args that's my bad
Am I doing the loop wrong?
what I'm trying to do
is for each entry in the JSON
I want it to loop through the code in the for loop
But what seems to be happening is
it's getting both of them from the JSON
making urls for both
but it's just using the channel id from the last one
twice
You could use message.channels.get instead of client
It's not triggered by a message
Defines it under the guild the message is from
Other then that I'm not 100% sure why it's doubling the URLs
Ahh okay
The part that updates the channel names works fine
I can't figure out though
It's getting the urls correctly, parsing the JSON correctly
But it uses the value from the second one tice
is it like
Running the code inside of request twice?
It's like it's running the channel update code twice without currentSvr being updated
I see what you mean now but I can't see anything in the code that would trigger it to do that unless I'm just blind
Lol hypixel nice
I still don't see a issue with that but again I could just be blind right now
I have no clue why it doesn't work
Wait for someone else to answer maybe they can help cause I'm just not seeing the issue ๐๐
Like I understand what's wrong but I don't see why
I wish there was a way i could watch the code work
Like step into
so it's making both requests and parsing the json correctly
it's just reusing the channel id for some fuckin reason
ok this mught be helpful
currentSvr isn't getting updated
huh
it's updating twice
it's almost like running the first part twice
and when it gets to request it runs that block of code twice
tried putting it in a function?
The text "start of request" never appears
why isn't that part of the code running?
How do I change the channel where the invite is created for discord server list
@unique glade create a channel specific invite
I'm on mobile rn but
On desktop I believe there is a invite button beside the channel name
Why is this sending the message but not in an embed?
const { RichEmbed } = require("discord.js");
module.exports = {
name: "say",
aliases: ["bc", "broadcast"],
category: "moderation",
description: "Says your input via the bot",
usage: "<input>",
run: async (client, message, args) => {
if (message.deletable) message.delete();
if (args.length < 1)
return message.reply("Nothing to say?").then(m => m.delete(5000));
const roleColor = message.guild.me.displayHexColor === "#000000" ? "#ffffff" : message.guild.me.displayHexColor;
if (args[0].toLowerCase() === "embed") {
const embed = new RichEmbed()
.setColor(roleColor)
.setDescription(args.slice(1).join(" "))
.setTimestamp()
.setImage(client.user.displayAvatarURL)
.setAuthor(message.author.name, message.author.displayAvatarURL)
.setFooter(client.user.username, client.user.displayAvatarURL)
return message.channel.send(embed);
} else {
message.channel.send(args.join(" "));
}
}
}
Hmm
It's got me Uber confused
It is a say command
Thought so and if they don't specify embed you want it to send it as a normal message
It's honestly no big deal, it does what it's supposed to but wanted to know why it has no embed
If you don't specify that you want to embed it does it send the other message properly? @lavish seal
I'm not understanding, it sends the message like this if that's what your asking
Basically what I'm trying to figure out is how you have the command set like is it
>say embed for example
Or >sayembed
Obviously that prefix is just an example
How do you specify embed is what I'm asking is there a space after say or no
If there is a space then it's args[1] not 0
If that even makes sense to you lol
Basically if your command is s!say embed then the "embed" would be args[1]
s!say is args[0]
It does a little bit, I tried changing it to a 1 from earlier but lemme try one more time to be sure
Alright let me know what it does if you do that
It doesn't change anything, now it just take two words instead of one to send so instead of
s!say Hello
It's
s!say Hello Friend
To actually work
But no embed
Hmm that's odd
HTML & Markdown allowed, minimum 300 characters Huh. i need this code
Hey anybody can help me
Trying to get the bot to post when i'm live but set it up on dashboard but not working
@blissful rain u need dashboard code?
Trying to get the bot to post when i'm live
So what you can do is do
if(args[0].toLowerCase().includes(" embed")) {
//EMBED CODE HERE
} else {
if (!args[0].toLowerCase().includes(" embed")) {
// REST OF CODE HERE
}
}
}``` @lavish seal
Let me know how that works?
There is a space in the " embed"
Im trying to get it to post when im live on twitch in my channel
@blissful rain what language?
English
.... The streamcord bot? I'm pretty sure is Python
wiered
Lol
so i need to remove this bit after else and replace it with
No don't remove it
Just add ^^ that above it
Yeah that might work it might error that there is to many closing curly brackets or whatever they are called
Let me know
That's weired it's completely ignoring the embed part
Ahh the first one put a space
" embed"
Without the space it expects no space
So it's awaiting s!sayembed instead of s!say embed
Hmm Hang un
If that doesn't work then I'm honestly lost
And the answer is probably right infront of our faces lol
But let me know if it changes anything ๐ค
@lavish seal I have one more suggestion if that doesn't work
That actually usually helps for me with commands that are set up like this
Awesome ๐
Although with the avatar thing it was wonky looking
@lavish seal tryjs message.author.AvatatURL
I also didn't realize you had to literally say s!say embed hello
Instead of displayAvatarURL
Yeah
You have to specify that.... (Sometimes)
Coding can be tricky like that sometimes
please someone know html and js ๐
I need help I want to create a txt file with html and js
becouse I creating site and I want to read it file later so I want to write it 1 information
i didnt understand anything you said
like he'd understand what that means
.
Please how can I edit html code with node.js or php ?
i create form I get to it link and I want to that link get to video ๐
How can I amend the description?
I get link out of form with js but I dont know how can I get that link to a video
into
@sick apex i dont understand what you mean, show some code examples
@quartz kindle And then ุ
then change the long description
where is
in long description
OK
<script>
const link = that link of wideo what I send with form
</script>
<video controls="" autoplay="" name="media"><source src="that link" type="video/mp4"></video>
this thik
I want to get ${link} to a video link ๐
src in <source>
link to that img on top.gg web servers ๐
it don't exist ๐คฃ
ups is site of discordapp
๐
Can I exchange it?ุ
@sick apex you need to use javascript to set the src attribute
so const = src ?
<script>
document.querySelector("video").setAttribute("src",link)
</script>```
Does everyone here use sql to keep user data and analytics? I really dislike sql and want to know if anyone is using something else?
For both analytics and user info?
easier to use the same thing for both, than to keep two separate database servers
unless your project deals with millions of transactions per minute, there should be no need to optimize your infrastructure that much
I havent used either before is there any recommendations? Im not storing alot of data. Mostly for an analytics
probably anything you can throw at it will do the job
i personally use sqlite for my api
i have a table that logs timestamps, ip and url, user id
in mongodb you can probably use a document, and store items in it, each containing a timestamp and the data
there are some databases who are specialized for "time series", which is storing data over time, usually used for analytics
but those are usually meant for higher scales
where all optimizations matter
at a small scale, you can use whatever you want, as long as you use it correctly
Thank you
a lewd!
lmao
I wanna make an unban all command in djs.
But before
Are there limits?
like 20 bans per hour or something like this?
can't you change the background of page that shows your bot?
of course you can
Is there any generic reasons as to why messsage.member would be undefined in this case if (!message.member.guild.me.hasPermission('SEND_MESSAGES')) return;, discordjs of course lol.
the command was executed in a dm
That's what I was kind of suspecting, I'll look into it a bit more later
is there any way to get it simpler? https://prnt.sc/r7z5gu
dont want to type every letter
(dont mind me for french name, I have to do it for class)
a command handler (usually) should:
ignore dms
ignore other bots
ignore prefixes that don't belong to it
and avoid sending unknkwn command messages
it's the best way to keep your commands error free
yes I cant
why are you doing that though?
I need to do this for school
count how many times a character is in a text to decode it
Al Kindi
wait a sec
you could just loop through each character
and do
const counts = {}
for (letter in string) {
if(!counts[letter]) counts[letter] = 1
else counts[letter]++
}```
not even sure that'd work
not that it should
hmmm
but thats how I would think about it
since you can iterate by character of a string
@tight plinth what lang?
python :/
anyone know why im getting this error?
I wanna make an unban all command in djs.
But before
Are there limits?
like 20 bans per hour or something like this?
no i dont think
I'd suggest 1.5s delay between the requests
@earnest phoenix ur mysql server is not correctly configured
@slender thistle he needs to loop through every character and store the amount
thats why
I was saying
just iterate through every character
and store it in an object
Oh it's for all characters in the text
yea
dictionary with amount pog
In a way
I just got so annoyed with the Process halting with discord bots
High-level languages are convenient
And threading can be a bitch
@tight plinth what am I missing?
A MySQL server
by the looks of it
@earnest phoenix https://dev.mysql.com/doc/mysql-getting-started/en/
https://prnt.sc/r7zdh6 welp fuck, lets pray I didnt forget one
Create a dict instance
Iterate over the string
if character not in dict, add it and set its value to 1
if yes, get the key and value for that char and increment by 1
@delicate zephyr I did set it up correctly... I followed a tutorial
And now someone will write an รฉ and break Lumap's code ๐
can it be solved by running a command on every server where you can create an invitation link?
@blissful scaffold hopefully teachers says "If you see accents in texts (like รฉ), destroy them"
.replace anything that isn't Latin
const Discord = require('discord.js');
Error: Cannot find module 'discord.js'
help
install the package @grave jacinth
just because it's in package.json doesn't mean it's installed
All that means is that it depends on it
npm i installs all dependencies in package.json I believe
yep
with python I want to append 2 things at once in a list. Can I do that?
like append a number and a letter
do append twice
why not
Use list.extend([itm1, itm2])
or just turn it to an array and get the index then
read the docs
today, if you send a message with <@user-id>, Discord will present this message transforming this in a user mention, there's any syntax to do this without the mention? just transforming the user id in the username?
if you want to send for example @vestal cosmos without triggering the mention you can escape @ with a backslash <\@105770695631319040> (<@105770695631319040>)
I think that I didn't express well. I don't want to send the "fragment" <@user-id> in the message.
For example:
@vestal cosmos ---> @vestal cosmos
???? ---> samuelsimoes
module.exports = member => { let username = member.user.username; member.guild.defaultChannel.send('gel,gel aslan gel'+username+''); }; wellcome code is not working
no error
Please help
Does that every time I try and load my bot thatโs coded in discord.js
@grave jacinth what is your djs version
defaultChannel is deprecated
"discord.js": "^11.5.1"
^
@grave jacinth I send this message through the REST API so I will need to do an extra request to get the username, which isn't a problem, I just wanted to know if there's any easier syntax to do this like the mention syntax
how to get all guild invite link Discord.js
yes
@earnest phoenix https://nmw03.is-inside.me/ezUTHMaS.png
i dont understand
@grave jacinth my problem is because my bot sends this message.
as you can see, it does 10 mentions that can be annoying to certain members. so I want to avoid these mentions just showing the username without the mention. to this bot message I only have the discord user ids, if I want to know the username of this players I will need to do an API request to fetch the usernames, which as I said isn't a big problem, but if I can do this without this extra request, would be interesting
get the user then get their username
idk what lib you use
and most times they'll probably be in cache so you wont need to actually do an api call
got it, @amber fractal
so I will to the path to the extra request
yeah, I will need do a cache logic
anyway, thank you people!
@twilit rapids hey can you help this hoister/dotposter with -dotpost
-dotpost @simple drum
@simple drum
Please do not post dots to clear your messages/get attention. It adds absolutely nothing to the conversation and just causes spam If you need to get attention, then say hello everyone. If you need to clear your messages, then press the Esc key. If you do not follow these instructions you will be muted.
ok i deleted my message sorry@twilit rapids
what library/language?
const reqEvent = (event) => require(../events/${event}); module.exports = client => { client.on('ready', () => reqEvent('ready')(client)); client.on('message', reqEvent('message')); client.on('guildMemberAdd', reqEvent('guildMemberAdd')); client.on('guildMemberRemove', reqEvent('guildMemberRemove')); };
this is true?
eventLoader
you probably want ./ not ../
../ is for previous folder, not current folder
unless you have your events folder outside of your bot folder / main file folder, or you're calling that file from a different folder
Wrong server
@vestal cosmos bit late but you could also just put it in an embed as mentions wont ping a user if theyre inside an embed
@summer torrent that's a very cool domain
I'm about to try out Contabo for VPS hosting, does anyone here have their bot in over 50k servers? Any suggestions on better VPS hosting?
contabo networking and ram speeds have been a bummer
but otherwise
ยฏ_(ใ)_/ยฏ
also I wish I knew who owned that domain
๐ข
@wide ridge Not at 50k servers but Run a large ish site on it using their Dedi and VPS
over all pretty decent havent had any issues
ik @twilit rapids runs Chip which has 20k on contabo
hmmm...why do you say ram speeds are a bummer @tight heath
I'm thinking of going for the 8GB ram option for now, I hope the ping is fine with that too?
unless ur bot is Massive you shouldnt run into an issue
I've tried benchmarking it and the speeds were almost on level with my NVMe lol
as in
the RAM r/w
I doubt you'd notice anything with a bot
I'm not noticing anything that the ram speeds are low
I got both of these on a contabo vps and it works fine
ram operating at 2gbps? wtf
actually, it makes sense
if they're using nvme's as ram, putting all their kvm instances in swap memory
that would also explain their cheap prices
and their cpu cores are shared afaik
client.on('guildMemberAdd', member => { const channel = member.guild.channels.find('name', 'gelen-giden'); const reqEvent = (event) => require(../events/${event}`);
module.exports = client => {
client.on('ready', () => reqEvent('ready')(client));
client.on('message', reqEvent('message'));
client.on('guildMemberAdd', reqEvent('guildMemberAdd'));
client.on('guildMemberRemove', reqEvent('guildMemberRemove'));
};` why its didnt working
?
module.exports = member => { let username = member.user.username; member.guild.defaultChannel.send('gel,gel aslan gel'+username+''); };
glitch
need more information
@late hill both in the same vps?
unexpected token
@grave jacinth the path to the events folder should be in quotes
'eventpathHere'
As far as I know anyways I mean it might work like that never really took a chance at trying it
yes
@quartz kindle good point actually I don't know why I didn't think of that ๐คฆ๐ปโโ๏ธ my bad
Didn't even clue in that he tried to use it and discord said nope
@honest perch can you show the line it's erroring for in the JSON file
DONT POST TOKEN
Oh the watch.json
those are my json files
i do have the latest version of it backed up on github so i can just reset it
Do you know which JSON it is that it's erroring on?
nope
Which one were you editing before the error
just the watch
i took the 0 off and added it back on to reset it
refresh it*
its online but
Oh high ping
Try to ping again in a minute or two glitch is known for high ping on start up
https://jsonlint.com/ go here and paste each one seperately
JSONLint is the free online validator and reformatter tool for JSON, a lightweight data-interchange format.
it will tell you which one errors
Or you could do that ^^ I forgot about that ๐คฆ๐ปโโ๏ธ
hi, im trying to log commands entered and wanted to know the best way to handle date-times (in python), is there any recommendations as to how i should store the date time?
@amber fractal but it is working now just really high ping
then ๐
Yeah I told him to just give it a minute glitch usually has high ping on start up
Idk why ๐คท๐ปโโ๏ธ but
@vagrant tree dates should always be stored as timestamps
unless you need to index them by name of month, day of the week, year, etc
and even then it would be better off as an addition, not a replacement for the timestamp, or simply calculate timestamps for those before getting the values from the db
seems like glitch is having issues
Probably all the Discord bots running it are killing the service so good
@honest perch high ping could also be due to Outdated Modules causing poor performance
made a new project in glitch and imported my backup from github, seems to work fine now so maybe just that one server
any way thanks again for everyones help
@quartz kindle you mean as so:```py
import time
time.time()
1582749915.201843
what r u trying todo
i want to record events so that i can do some data mining/analytics. i want to record the date and time so i can see when events happened and measure against different times etc
use datetime
>>> from datetime import datetime
>>> datetime.now()
datetime.datetime(2020, 2, 26, 22, 41, 18, 969048)```

that is
one way ig
that doesnt print datetime.datetime(2020, 2, 26, 22, 41, 18, 969048) tho
i cant really save that in my db
i mean you can
you str() the datetime object it returns the stamp
then use strptime i think it is to load it back to a datetime object
>>> d = datetime.now()
>>> d
datetime.datetime(2020, 2, 26, 22, 53, 29, 902060)
>>> print(d)
2020-02-26 22:53:29.902060
yh
How can i have a bot google a companyโs stock price and than message it? On discord.py
ig use some sort of API and AIOhttp
@vagrant tree that will make it easier to search for specific dates or times by string or by humans, but it will make it harder to sort, filter or use math on the dates, unless your database supports datetime functions with that format (it will also use a tiny bit more disk/memory/cpu)
you can convert the date time object to seconds total
save that
then build back into object (if you want it readable or compare to another object time)
is there a standard way of doing this?
depends on ur use case
most people use datetime because of the utility to manipulate the times and do comparisons with standard operators
i guess time.time()
.timestamp all the datetime objects
he wants to build a time-series database, so it mostly depends on how the potentially thousands of entries want to be accessed
timestamps are more efficient but less readable
at this point im just recording the timestamp i will use the data externally to my bot
use the datetime module in general
const { RichEmbed } = require("discord.js");
const db = require("quick.db");
module.exports = {
name: "buy",
aliases: ["purchase"],
run: async (bot, message, args) => {
let bal = await db.fetch(`money_${message.author.id}`);
if (!args[0]) return message.reply("Try `p!shop` to browse items then use `p!buy <item_id>` to buy it.");
if (args[0] === "1") {
if (bal < 1000) {
return message.reply("You dont have enough to buy this item.")
}
return message.reply("Are you sure you would like to purchase this item?")
.then(function (message) {
message.react('๐').then(() => message.react('๐'));
const filter = (reaction, user) => {
return ['๐', '๐'].includes(reaction.emoji.name) && user.id === message.author.id;
};
message.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === '๐') {
message.reply('you reacted with a thumbs up.');
} else {
message.reply('you reacted with a thumbs down.');
}
})
.catch(collected => {
message.reply('you reacted with neither a thumbs up, nor a thumbs down.');
});
})
}
}
}
Is there a way to make it get the authors reaction instead of the bots?
ive been trying for hours
it always responds when the bot reacts I want it to respond when the message author reacts.
just... make your filter ignore itself or bots in general?
@earnest phoenix how?
@unborn steeple ```js
if (message.author.bot) return;
no
Was gonna send that before you asked how was just referencing some code I have for a starboard
That's what I use
World fine
Works*
don't spoonfeed code and don't spoonfeed wrong code
@unborn steeple look at your filter code
i don't get what you mean by 'how' lol
&& !message.author.bot @unborn steeple
don't spoonfeed
yes
theres not a rule
do you really think so
can you edit the code block and add js to the top?
@earnest phoenix the rule says do not spoonfeed or attack beginners as in beginners people who aint a bot dev role yet.
tbh im tired and I didnt realize that was the problem eventually i would have fogured it out
does it say that beginners are people who don't have bot dev? no? dont make it up then
@unborn steeple you are replacing the original message with the message your bot sends, thus the author will be the bot
@quartz kindle how would i fix that?
it will
Yes it's defining it as two seperate message (in a way) events/callbacks whatever you want to call it

as long as you change all references to the correct message
love how you deny me but ask tim to make sure
Tim's pfp gives confidence to the new devs
ie: js run: (message) => { dosomething().then(newmessage => { newmessage.doSomething(); newmessage.author !== message.author }) }
@quartz kindle im trying to get the reactions to the bots response instead of mine too
just make sure you are doing things to the correct message
ie: newmessage.react()
you should know which message object is the command, and which message object is the bot's response
also, since you're already using an async function, you could as well switch to await instead of .then()
would make your code easier to understand
lul
I made a config.json file but there's a problem, it says it's expecting a "comma"
{
"prefix": "c!"
"token": "Inserted-token"
}
I don't know to fix it because I tried but it just caused more problems.
Hey guys! I am Asking a very dumb question. I want to code a bot in pycharm. When i run pip install discord.py in terminal (Iโm on Mac) it says there is no command for that! Please help me. Every youtube video i find is on windows!
Please ping me, i am going offline
@pine bear at the end of every line you need to add a comma, except the last item
Kind of like how a list would be formed object 1, object 2
that sort of thing
Thank you.
hello can someon spoonfeed me please
yes
@hushed berry yes
It says symtax error, but I'm like at one of those times when writing JavaScript when I'm so certain the code is correct but it isn't.
here is the error message on the terminal.
client.once('ready', => {
^^
SyntaxError: Unexpected token '=>'
here was the code I used.
const Discord = require('discord.js');
const { prefix, token } = ('/config.json');
const client = Discord.Client();
client.once('ready', () => {
console.log('Bot is now online!');
})
client.login(token);
please help, I've tried and read everything. and I've been stuck on this step for hours.
Why doesn't this work? owner should be a guildMember.
@pine bear the code that the error shows is different than the code you showed, make sure the file is saved
aren't you missing a ;?
^not the problem, javascript does not enforce semicolons
kk
Oh, save the file eh? I'm on it
@mystic violet not all members are cached by default
you hit a guild whose owner is not cached
Hey guys! I am Asking a very dumb question. I want to code a bot in pycharm. When i run pip install discord.py in terminal (Iโm on Mac) it says there is no command for that! Please help me. Every youtube video i find is on windows!
@static trench file > settings > project interpreter
click the little + icon
and grab the packages you need
2 secs i'll send screenshots
Terminal or pycjarm
pycharm
Can I use discord.py?
gimme 2 secs
Kk
im loading pycharm
Ok
Ok...
Ok
do you have a project set up already?
Sry
as i said above
also, with pycharm, if you try to include a module you dont have installed, it'll prompt you to install it
as a quick fix
file. settings.
pip install discord.py is not the same as python3 -m pip install -U discord.py
Let me try
if that doesnt work you dont have python installed
i mean doing it thru pycharm is just a good method as any
๐ฎ
Ok
just type python3 -m etc in a normal terminal
It says the token was invalid, but I used the client.login(supersecrettoken) and was able to get it online
huh
well... now you code
Ok. Where?
wh.
How can I get settings in pycharm?
you dont need settings
not anymore.
why did it say it failed?
It said it didnโt have permissions
dont think so
ftr
Itโs not
try doing python3 -m pip install discord.py --user
@earnest phoenix can u walk me through pycharm?
try what @stable horizon said first, if that doesnt work, ye
good good
What now?
now @stable horizon is that global then? since pycharm does use virtual envs?
Where do I code?
open pycharm, make a new project
A simple bot tutorial for Discord.py. GitHub Gist: instantly share code, notes, and snippets.
you might have to install it in the venv, if you use one
How do i do that?
qjeghdr iuj rljsbfgvkl4
that was aimed at @stable horizon
personally i dont use venvs so i didnt think about it
Do i import discord.py to pycharm?
Ok how?
ok so
i have pycharm set to global interpreter ยฏ_(ใ)_/ยฏ
Yes?
On pycharm?
yup
Done
ok so you can either follow the steps i said above
or
type import discord in the file
hover over the error it gives, and click import discord
https://gist.github.com/4Kaylum/a1e9f31c31b17386c36f017d3c59cdcc and do read this
A simple bot tutorial for Discord.py. GitHub Gist: instantly share code, notes, and snippets.
it'll explain better than i can
Ok
also this
worship this. this is the holy grail of discord.py https://discordpy.readthedocs.io/en/latest/api.html#async-iterator
and then use the shortcut it says
isnt that alt shift enter
i dont use a mac but pretty sure that is alt shift enter
Ok
mac key bindings are a piece of crap
thats the win shortcut too
IKR
alt shift enter - first fix, alt enter - open fix menu
just
look bottom of screen
Got it
does it say anything is running?
Index?
ye, it finds all the important pieces of a file so autocomplete will work
Ok
basically searches thru the file, and is like "hey, this class has these functions, etc"
Ok
so when you trigger autocomplete (ctrl+space, or just any other time( it'll know
How do i run it?
click run
but
A simple bot tutorial for Discord.py. GitHub Gist: instantly share code, notes, and snippets.
read this.
O
Ok
I just put in one of the examples for discord.py and put it into the code w/ my token
ye
I didnt write any of the
do that
Ok
import discord
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send('Hello!')
client.run('your token here')
in particular that
I did that
it run?
errors?
I have 2200 lines of code
use just that code above
hold on
from discord.ext import commands
import logging
import discord
logging.basicConfig(level=logging.WARN)
def get_prefix(bot, message):
prefixes = ['%','>']
if not message.guild:
return '%'
return commands.when_mentioned_or(*prefixes)(bot,message)
bot = commands.Bot(command_prefix=get_prefix)
@bot.event
async def on_ready():
print("Bot ready!")
@bot.event
async def on_message(message: discord.Message):
if message.author.bot:
return
if message.content == "hello":
await message.channel.send("hi")
await bot.process_commands(message)
bot.run("token")
this is a very minimal bot that SHOULD work
just says hi when you say hello
oop
Ok
Ok
It says error for some reason
(node:2712) UnhandledPromiseRejectionWarning: Error: An invalid token was provided.
When I put the token in the config.json file that happened, it also said this along with the warn code.
(node:2712) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:2712) [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.
here is the code again
const Discord = require('discord.js');
const { prefix, token } = ('./config.json');
const client = new Discord.Client();
client.once('ready', () => {
console.log('Bot is now online!');
})
client.login(token);
Yes
about when should i start sharding on my bot
@smoky quartz around 1k guilds, you are forced to at 2.5k
im at 1.3k now
Whats sharding?
and no idea how to do it
@earnest phoenix it didnt work
No, I'm talking about my bot.
basically splitting your bot so it can do more servers
each shard is a given amount of servers
idk how long it takes cos idk how to do it
but pretty sure its not that hard
@smoky quartz What language and library
Good luck!
python with discord.py
Pretty sure it does.
Dan, what should i do?
@static trench send errors
Umm, ahem.
Cuz that code is literally a stripped version of my bot startup. And @pine bear id help if I could but I don't do js
Traceback (most recent call last):
File "/Users/Ben/PycharmProjects/untitled/main.py", line 2, in <module>
from discord.ext import commands
File "/Users/Ben/untitled/lib/python3.8/site-packages/discord/init.py", line 23, in <module>
from .client import Client
File "/Users/Ben/untitled/lib/python3.8/site-packages/discord/client.py", line 34, in <module>
import aiohttp
File "/Users/Ben/untitled/lib/python3.8/site-packages/aiohttp/init.py", line 6, in <module>
from .client import BaseConnector as BaseConnector
File "/Users/Ben/untitled/lib/python3.8/site-packages/aiohttp/client.py", line 69, in <module>
from .connector import BaseConnector as BaseConnector
File "/Users/Ben/untitled/lib/python3.8/site-packages/aiohttp/connector.py", line 3, in <module>
client = discord.Client()
AttributeError: partially initialized module 'discord' has no attribute 'Client' (most likely due to a circular import)
Process finished with exit code 1
@earnest phoenix
running this code
Are you only using the last code I sent?
yes
i regenerated it
Oi. Delete that and regen your token
That's... Odd
ik
Are there any errors in the editor?
Like what
turns out d.py does do it auto you just need to change what type of client it is
welp thats easier than i thought
they are gone
@smoky quartz that code should work. Shouldn't it
never played with the logging lib but seems fine to me
That's a stripped version of my bots startup. And the full code works
btw @static trench delete the message of ur code