#discord-bots
1 messages Β· Page 356 of 1
What errors do you get
the one that is called "Windows installer - 64-bit"
you still need to install the packages
and select the new python version in Vs code
pip install discord.py
you know where to put it?
what python version did you install
I don't even know where to find it, let alone put it.
install the Python module for VS
Write "cmd" in the Windows search bar, and open it, that's the console
the one on home page and it showed amd64 on the file.
That i surprisingly know and got open
try to run
py -3.12 -m pip install discord.py
Like in the command prompt?
arm64 is most likely the wrong build for your pc
yes
Then, install the Python addon for VS, that should install Pylance too and the highlight should go away
that's not the issue
It finished.
in the bottom right corner in Vs code you can select a python version, select python 3.12
It's not there or any python from the list.
did you select the add to PATH option when installing python 3.12?
It never gave me the option
Or was i not supposed to hit install button?
it's in the advanced options iirc
oh you're hitting the wrong button
guess can download it again and redo it
take a screenshot at the corner and let me see
if you press on python it opens this?
yes
do this then
ctrl + shift + p
type Python select interpreter and press enter
select python 3.12
if python 3.12 is not there you need to add python to PATH following the guide that you sent
It gave me error message, sigh that extremely hard guide
I'm guessing the one that says 3.12 64 bit is the one?
I am still stuck with the attribute error that I got few hours ago so might need help with that again.
@tasks.loop(minutes= 10)
async def timezone_update(self):
guild = self.client.get_guild(<ID HERE>)
argentina = guild.get_channel(<ID HERE>)
us_central = guild.get_channel(<ID HERE>)
us_pacific = guild.get_channel(<ID HERE>)
asia = guild.get_channel(<ID HERE>)
jst = guild.get_channel(<ID HERE>)
await argentina.edit(name= f'π Argentina {ART.strftime(fmt)}')
await us_central.edit(name= f'π US Central {CST.strftime(fmt)}')
await us_pacific.edit(name= f'π US Pacific {PST.strftime(fmt)}')
await asia.edit(name= f'π PH/SG/CN {UTC8.strftime(fmt)}')
await jst.edit(name= f'π Japan {JST.strftime(fmt)}
the said error:
Traceback (most recent call last):
File "G:\pythonProject\discord_bot\.venv\Lib\site-packages\discord\ext\tasks\__init__.py", line 239, in _loop
await self.coro(*args, **kwargs)
File "g:\pythonProject\discord_bot\main.py", line 58, in timezone_update
argentina = guild.get_channel(<ID HERE>)
^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get_channel' ```
I tried doing it with my old code without cogs and it works there but doesn't loop
one above is the new one using cogs for timezone.
PS: I'm getting somewhere.
This as far as I got
Taken from website
Step 4: Add Python Path to User Environmental Variables
There will be two categories namely βUserβ and βSystemβ, we have to add it in Users, click on New button in the User section. Now, add a Variable Name and Path which we copied previously and click OK. Thatβs it, DONE!
retry this then @ebon ocean
refresh vscode too
what intents are you using?
the guild is not cached
The intents I am using is discord.Intents().all()
fetch the guild then
you can do
guild = self.client.get_guild(...) or await self.client.fetch_guild(...)
Oh, that actually work! I got an error with the other variables but also used the same code to fetch the other channels and now they work!
Now it's only the matter of whether the loop works π
if you're starting the task when the cog is loaded then it should work
Still not there and I'm still stuck on number 4 in that geek to geek guide. Had somebody in my own server help me figure out... um i guess path and still stuck on 4 though.
@glad cradle I finally finished that guide and it did absolutely nothing
did you mean by having an on_ready then setup_hook or the other way around?
don't you see python 3.12 following the steps that i said earlier?
you can start the task in the cog's init
I come to the conclusion that those false errors will always be there.
I DON'T KNOW WHAT TO DO!
Never go to that discord py dpy s--t server unless you want this to happen with you.
school computer ahh setup
What did you do π
A jerk pissed me off on another place. It's okay, they are going straight to hell where they belong.
LOL. You have no messages in discord.py... but alright
I deleted them all.
how tf you get so mad you wipe your history in a channel πππ½
I see. I am no health professional and don't know what the conversation there was, but incontrollable fits of rage are never a good sign. You should probably consult a medical professional?
I've always had positive interactions in discord.py so I can't relate to your anger either. Good server
gets good when you get comfortable
like an above your normal temp bath where it stings when you go in or move around but once you adjust it works fine
Just don't be annoying 
the code works but it does not loop even though I had the task on start in the cogs init no errors and all. Quite odd.
I was trying to get help and this jerk dratsab was being so mean and rude. Be kept truely believing that if I just look at some websites that all my problems would be solved despite the last 2 hours working on the same problem. Then what he kept saying it again, that was what did it. You have positive interactions because you're not an extremely stupid idiot like me.
If you don't know 100% about everything about computers or python, then you are worthless piece of s--t over there.
That's quite wrong, there are countless of helpful people over there, the difference is, they won't spoonfeed but try to show you a path towards the solution.
It's basically just assistance in thinking. (besides, one of the rules over there states you are supposed to have a basic understanding of Python, so, that's on you, it's not a beginner lib)
Yes FU-K THOSE PIECES OF S-IT who truely want to learn! It's like people who want to learn math and they try and learn it, and we say FU-K YOU! Like come on, LMAO, you should already know most of all the math even though that is really arbitrary to really know what is considered basic or not. You should know the quadratic formula. Instead of just telling you the quadratic formula, will tell you to use this axΒ²+bx+c=0 and solve for x to get the quadratic formula. I mean, I DID PROVIDE you the information you need to. Not my fault if you're an idiot who can't figure out how to solve for x. That's a "basic" level of math! I'm so f--king superior and better than you and look down upon you for the crime of trying to learn something! Sarcasm.
...Literally not what I said, and not what anyone over there said either, they just don't spoonfeed, they won't give you an instant and obvious solution to your issue, they'll happily tell you why your issue occurs and how you might mitigate it though :)
they did this in discord.py then purged their messages and left
And in your help post you were even told how you can mitigate your issue, I don't see the problem really.
Well I do, but I won't get into it.
You just repeated what I just said. You can be a jerk and call it "spoon feeding" but it still basically saying F U. Like that s--t is stressful enough already and not need to purposely add more stress. But yeah, let's punish people instead.
I mean, you quite literally ignored the help that was given and didn't try researching anything yourself.
Once again, outlined in the same help post π
I spent 2 hours going through that same s--t. I want exact step by step on what to do at the time.
Well, people just aren't going to give you that, regardless of your situation, because you don't learn that way (or shouldn't)
Anyway f--k you, pissing me off!
Seek a therapist.
Anyway, f--k you all except that one person who was always fair to me. I give up on python. I'm too r word and stupid for this. I don't wanna ever see python ever again. And that person I just blocked can go straight to hell with that other jerk. I have no friends and nothing to lose, so f--k all of you mean evil people!
bro π
!timeout 241629325223395329 2d Chill out. You need a better attitude if you want to participate in our community.
:x: The user doesn't appear to be on the server.
ok
lol
lol
r/im14andthisisdeep
lol
lol
lol
lol
okay guys
how do i make a loading message
before the bot send another message?
i need it to my bot don't time out
on response
Use defer
There are no errors in my code, there are no warnings on my terminal. But the slash commands take FOREVER to sync with the server guild. I am unable to diagnose the problem. Please help.
Ive also given a 8 hours gap. The problem still persists
A, C is yes, B is no
is it syncing or not?
am confused
It takes way too long and it is unpredictable when it would sync
syncing is instanteneous afaik
Okay, apparently, I just need to refresh my discord website. It works then :D
just need to restart the discord app that's it
yes, as long as the bot have read message history permission, you can fetch messages
wait why can't we search a specific word?
bots doesn't have endpoint to search, you're forced to go through the entire channel just to filter based on words
ahh yes via api it's not possible
Iβve never created a discord bot In py but Ima learn now, whatβs the best way to create a currency system and give a different amount of /daily currency based on role? Then when they run a / command it charges one credit and runs main.py ?
there's two main topics to tackle at once:
- For the currency system, you'll want to use a database so that you can permanently store each member's currency. SQLite's a good start, since its file-based, supports concurrent reads/writes, and is well suited for organizing data from discord (users, guilds, members, etc.). Python has a built-in sqlite3 module so it's easy to use in most projects.
- discord.py's a popular library for writing discord bots, where your script connects to discord to receive real-time events and make API requests. Commands are defined as functions, and dpy will automatically call them for you when someone wants to use your command.
That's a general overview of it, but when you get into it you'll deal with more specific details like learning SQL, defining a command tree, dealing with async/await syntax, etc.
there are also plenty of python concepts you'll be using as you get more involved with dpy, listed here:
https://gist.github.com/scragly/095b5278a354d46e86f02d643fc3d64b#required-knowledge
:D
Why use SQLITE?! just store everything in a txt file.
Wait no. heheheh individual txt files for each user π
Oh hell naw π
Take it a step further.
Folder named "database"
subfolders for each individual user
txt files named after each column/data thing you need to monitor.
each file holds a single entry
I can figure out the currency part, but my current code generates a tiktok style video. And I need it to generate when they purchase, how would I make the command run main.py and then dm the user the output?
if it helps, here's a glimpse of what dpy code looks like: ```py
import discord
from discord.ext import commands
Ask discord to send us non-privileged events,
like when the bot joins a guild or a message is sent
intents = discord.Intents.default()
bot = commands.Bot(command_prefix="?", intents=intents)
Define a slash command named /daily:
@bot.tree.command()
async def daily(interaction: discord.Interaction):
money = 500
await interaction.response.send_message(f"You received your daily reward of {money}!")
@bot.event
async def setup_hook():
# After the bot first logs in, tell discord about our slash commands:
await bot.tree.sync()
bot.run("your.token.here")```
So basic
discord.py doesn't really have a concept of "running main.py", as commands are written with functions
So would it be easier to integrate the bot into my main.py instead?
Just make the video generating a function
kind of, usually your main.py script would be the one hosting your bot
yeah, once its in a function you can call that in your command every time someone uses it
It's usually encouraged to do the cogs system
Only problem is it doesnβt generate everything in one file it goes all over with all kinds of utils and idk if thatβs a problem
Iβll try to do it
I wish I could do the bot in js Iβd already be done π
All a command is doing is running the code you tell it to run. You don't need to limit yourself to just that function. if you know it'll take a few moments to finish you can defer the response
But my ass gotta be special and learn py π
I can do the bot in js and run a python script on cmd?
literally anything you can do in python you can do in js
Ik but that would mean converting my entire video generator into js
So if I were to do it in js Iβd need to run a python script in a js cmd
theoretically your node.js discord bot could run your python script on demand in a subprocess
this is presumably the API for it: https://nodejs.org/api/child_process.html
but i dont write node.js stuff so i wouldnt know for sure
Pythonbro thru and thru?
o7 you absolute legend
Hm alr
my last ventures into html/css/js have ended in confusion π₯΄
My last ventures into html/css/js ended resulting in a website that looks like its from the 90s lol
I might just hop my ass over on fiverr so I can focus on the course part of it and let someone else do the bot π
Alright. pythons not that hard, but alright.
Welll
Do I reallllllllyyyyyy wanna learn it just for a discord bot????
Or throw my not so hard earned money at it and hope it works
Majority of programming is mostly about learning the syntax and the various methods to achieve a task. Like all those loops and shit.
Once you understand that, you can easily transition from language to language and adjust to the syntax.
Like once you learn that SQL is written the same in most popular languages, your only challenge becomes learning the syntax as it varies slightly.
Do you want to waste hard earned money over a 10 minute job?
It would take me longer to learn py tho
Someone should make the Minecraft language skript a real thing
That might just be typescript tho idk π
Minecraft uses java which is comparatively harder to learn
How do I turn off the visibility of a channel trough code?
I'm using the create_text_channel()
You can't. It's done from the client side
but it says that the "visible" argument doesn't exist
oh
Do you want it to be a private channel?
yep
await create_text_channel(name, *, reason=None, category=None, news=False, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=..., ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel) for the guild.
Note that you must have [`manage_channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_channels) to create the channel.
The `overwrites` parameter can be used to create a βsecretβ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict) of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member) or a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role)) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/latest/api.html#discord.PermissionOverwrite) as the value.
Note
Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel.edit) will be required to update the position of the channel in the channel list...
gotcha, thanks :D
See the documentation of this method
There is an overwrites kwarg you can set. It is detailed within the docs
its hard to cope with not being spoonfed when everywhere else they just hand you the answer upfront πππ½
Wth even happened here but whatever it was funny af even without context π
πππ½
Guys I can't make a discord bot on pythonanywhere.com
It's showing this
No module named discord
And when I give
pip install discord.py
It says this
pip install discord.py syntax error
But what's the complete error
Hey everyone! The problem is I know how to code a discord bot but I'm having trouble connecting my git to github to push code. I did it, however it says that I need to set username and email to push code. I tried doing it, but it says that the git command is not recognized. Can anyone help?
make one on your pc then
need more information and this is probably something for #1035199133436354600 or #python-discussion
this channel is for help with discord bots (like the bots themselves) so i donβt think youβll get much help here
ohh okok I'm sorry I'll head over there rn, thanks sm!
nps, just want you to get help 
windows system?
yes, my problem was solved just now, thank you though!!
ok cool
Don't have.
guys if anyone looking for domains or cloud storage or priavte ip security pls dm me!!
!rule 6
mb
cant really code then π€·π½ββοΈ
best bet is replit atp
Replit has no hosting for free
neither does python anywhere
PA has hosting but its basically the same constraints as replit
the whole company?
$10 will get you an okay VPS
That's more than enough to get a pretty good vps π
I'm broke
My debts: ||100,000,000$||
But I want a hosting for my bot help me
β οΈ
Help me bruh I need smth like a free vps or smth
@spice seal
how tf did you code a discord bot on your phone
Bruh that's the same thing
I used replit by now the keep_alive.py don't work
but
?
Yes
depends on what lib you using
Pls don't refer to pycord indirectly
Correct
π
but yeah discord.bot isn't anything
i wasn't specifically targeting it
Yeah good
Nobody likes pycord π
calling in pycord users
calling in pycord users ...
XD
I can name a few
including pycord, nextcord, disnake
but yes in discord.py it's
from discord.ext import commands
bot = commands.Bot(command_prefix='Your_Prefix', intents = ...)
!d discord.ext.commands.Bot
class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a Discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client) and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client) you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin) to provide the functionality to manage commands.
Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client), this class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree) and is automatically set upon instantiating the class.
async with x Asynchronously initialises the bot and automatically cleans up.
New in version 2.0.
read this again
it's a module inside discord
u need to specifically import it
commands.Bot
yeah there is nothing as bot() in discord.py
you need to first import commands from discord.ext module
then do
bot = commands.Bot()
(with kwargs)
yeah to lazy to type em again as I did them earlier
no it's an open source project
No, it's a community project
build by the discord.py server devs
well i doubt you will get anywhere near editing it for now
yes it's the discord API you can access it here and create your own wrapper if you want to
https://discord.com/developers/docs/intro
yes along with adequate knowledge of the programming language you use
no, use the dpy docs because you want to make a bot with dpy, not remake dpy from scratch
thats api docs which is what you would use for making dpy as an example
to make a bot, they should use dpy docs
I was answering Q3
where the discord.py team got the API
ohh my apologies. i think you replied to the wrong message

well i'd just use discord.py to create my own wrapper tbh
instead of going after the raw API

learn step by step instead jumping into the ocean
it's great that you are trying to learn but there are levels to everything
which you should follow in sequence instead of jumping from level 1 to 50
mfs writing a book
XD
still going?
π
learn python till you are at advanced level first
what dpy classes?
class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a Discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client) and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client) you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin) to provide the functionality to manage commands.
Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client), this class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree) and is automatically set upon instantiating the class.
async with x Asynchronously initialises the bot and automatically cleans up.
New in version 2.0.
wdym by modify
you cant rename or rewrite stuff
thats how the lib was made and it was made for a purpose
π€ Um, aktuall-
tbh you can but not at the level where by writing py print('Hello World')
you can write developer on your resume
and the class names are only so long because it's basically going from py import discord so for this it'll be py discord.ext.commands.Bot(...)
but you can use imports to make it easier, ie. py from discord.ext import commands commands.Bot(...) # much smaller
||(which for pretty much all cases, especially this one, means you cant rewrite stuff)||
Bot is a class
The worst insult someone can get yet π
commands is a module
so we need an insult_cord now
It's a folder
i'm gonna see if i can pull up a file tree for it
didnt even know that was there
yep
heres the file tree for commands.Bot ```
.
βββ discord
βββ ext
βββ commands
βββ bot.py
βββ Bot() class
you can use commands.Bot instead of commands.bot.Bot because in the commands folder, it has an __init__.py which is basically a setup file, that says py from bot import *
!e py f = print f('hi')
@viscid hornet :white_check_mark: Your 3.12 eval job has completed with return code 0.
hi
you can have classes with the same name as files, yk
this exists (idk if its a file, class or wtv) py datetime.datetime
yes, you see it a lot in libraries online
classes also have an __init__ which defines the class properties upon initialisation, eg.
!e ```py
class A:
def init(self):
self.var = 9
a = A()
print(a.var)```
@viscid hornet :white_check_mark: Your 3.12 eval job has completed with return code 0.
9
this is like snippets of advanced knowledge, dont worry
2 separate things 
yes, because __init__.py is used for installing libraries and modules and whatnot
wdym?
do you know about classes?
thats functions
i asked if you know classes
loads more
ok, how do you make a class
like i said, much more
i asked, do you know what a class is?
have you seen this before? py class SomeClass: def some_func(self): something = ... return something
i use them to centralise data, but you can do some cool stuff like inheritance
i feel like you need to be more specific
# this is a function
def func():
return 5
class A:
# this is a method
def func(self):
return 5
# both use def
if you have a method, call it a method
if you have a function, call it a function
clarity is key 
hi link
Your wording here leaves a lot to be desired.
The __init__ of the class doesn't have anything to do with properties, it merely defines how the Object is constructed from the class
Property != Attribute, if that's what you meant, and even then, you don't need an __init__ to have attributes nor properties
oh yeah i forgot you can do this py class A: var = 5
That's a class level attribute
A.var will work
thanks link π
also another question, can i define my own "magic methods"? (idk that they're called): ```py
class A:
def axo(self):
return 5
how do I give `__axo__` utility?
You can define them sure, you can't add special functionality to them
fr? 
What would you want to add to it?
mess about with it
A single python file isn't exactly special
You can add one class or a billion classes in one file no issue, when it comes to importing from it is when you may face difficulty but that's rather unrelated
You can define your own dunder methods sure, you can't make your own magic methods, not without some cursed knowledge I won't share here
def __foo__() -> str:
return "foo"
__foo__()
will work as you expect
"with some cursed knowledge i wont share here" 
i'll let it slide, thanks for the help π
whats your question
also use "function" and "method" to define what you mean. both use def which creates ambiguity for what you generally mean
(as someone new to Python, it's on you to try and figure out the difference until they're able to make the distinction themselves, it's a little non-trivial at first)
to create ur own magic methods you would need to extend the python internals right mostly with some c interop
you can do some trickery outwidth it but it wouldn't be seamless nor good
see: forbiddenfruit and the like
can u rephrase that
this is the wrong channel for these questions
theres a traceback there
are u on some vpn?
are you on macos?
try to change ur net connection to a hotspot once and try
where are you from btw
thats a command
me fr
nobody said that π
alr hold on
thats fine
use that instead
iβll delete the other one
i have told u before also lol thats just a log
its not an error
wdym solve it? that will always print
its not an issue
its a message or information
yes
how is that an error
thats for the 443 ssl error
lmao
when you have no idea what you are doing
its not a bot issue
maybe try switching to your mobile hotspot
??
sure
why not
maybe also rebuild discord while we are at it
maybe not today i am kind of tired
Nah, theres a plugin called skript which most people use. It allows for coding for shi like this ```on first join:
command /start:
trigger:
give player wooden pickaxe named "<##BB8054>&lStarter Pickaxe" with lore "&f" and "&fα΄‘α΄Κα΄ α΄α΄ α΄Κα΄ &e&l/α΄ΙͺΙ΄α΄&f α΄α΄ Ι’α΄α΄" and "&fΚα΄κ±α΄α΄Κα΄α΄κ±" and "&f" and "&f&cκ±ΚΙͺκ°α΄ &f+ &cΚ α΄ΚΙͺα΄α΄&f α΄α΄" and "&fα΄α΄Ι’Κα΄α΄
α΄" and "&f" and "&7&lCOMMON" with all flags hidden
set {EnchantLvl::%uuid of player%} to 0```
I coded my entire factory server in it
Yes, reset to get the token
I mean where i can test my commands of that like where to host bot
(for absolutely no reason)
π€£π€£π€£
β

U can't talk either π€£
Wdym
On live chat
Where you host your bot?
Say how you test your codes either it's working or naut
Idk
Idk python things in discord
Lol
U need to host
To make it online
Gonna see discord.py help wiki
Pay
There are free hosting providers too
Like repl.it
usually have big drawbacks
Like?
not replit ππ π½ββοΈ
cpu limit, ram limit, etc
there are quite a few constraints, including network constraints
Then what? I want when my codes are finished then I will start paying to any host
Until test my codes on free host
test code on your own pc and keep your main code on your host
Well
Mobile user (ikik too much pain these days)

the "static token" isnt the error
Areee you on PC?
no... I'm saying that the "static token" line isnt the error, its an information log
yes token of the bot
No, it uses a cloud computer
I'm not understanding you, sorry
What would be the best way to upload a file (to big for discords messages) through a bot?
I was thinking upload it to a host with api or smth but idk
What's the file type?
mp4
first explore discord then decide to make stuffs
Not sure if GDrive has an API but if so you can just do that
Otherwise blob storage is the way to go
@wide plaza can you tell us more about the problem?
What quest u completed and got that badge?
I have a powerful vm I could upload it to but idk how complicated it would be to have it upload then a link to an api to download it
Do you know Python well?
This isnt makeawish
import discord
# Create a client instance
client = discord.Client()
# Event: When the bot is ready
@client.event
async def on_ready():
print('Bot is ready.')
# Event: When a message is received
@client.event
async def on_message(message):
# Check if the message is from the bot itself
if message.author == client.user:
return
# Check if the message is a command
if message.content.startswith('!embed'):
embed = discord.Embed(
title="Embedded Message",
description="This is a simple embedded message.",
color=discord.Color.blue()
)
embed.set_author(name="ChatGPT")
embed.add_field(name="Field 1", value="Value 1", inline=False)
embed.add_field(name="Field 2", value="Value 2", inline=True)
embed.set_footer(text="Footer text")
await message.channel.send(embed=embed)
# Run the bot with your token
client.run('YOUR_DISCORD_BOT_TOKEN')```
This is to build simple embed
You cant learn to use dpy just by looking at code you don't even understand
You should try it with your bot
What problem
Yes but this is off-topic. Go to #1035199133436354600
You can't do that
Not rly, I defined my codes function and now Im importing it into my bot
Maybe
Do I need to define where from?
Like import function from ...
I dont think so right
Pls read the whole message
Ask in discord.gg/dpy
oh no π
import discord
client = discord.Client(intents=discord.Intents.all())
@client.event
async def on_message(message):
await message.channel.send("I will ban you")
client.run(token)```
understandable reaction
client.run*
don't ever use a client my bad
πlearn js
Or cpp
you will hve a fine time trying to make a bot
Why not python?
cuz it's the easiest
Can't we make bots with it?
People say python is easy
Also python is my first open source language which i am learning
client.run
python is good enough if u only wanna make bots
ok I don't wanna explain simple humour any further
but ash was just being sarcastic, since CPP's syntax is comparatively harder
π wdym
Well yes
nothing I'm sorry for initiating a convo about this π
yes thank you
No i want to know what you were telling
πβ οΈ.
.
Seriously comparing python and cpp's syntax
Idk what is cpp syntax
should I compare Python, and Brainfuck's syntax then?
Then you are good
π
It's fine
π€£
Forgot about that
Does anyone know if it is possible (if yes then how) to put multiple attachements (images) inside of 1 embed?
using the embed.set_image() func
you can't set more than one I'm pretty sure
I feel like there was indeed a way but can't remember it
@restive perch any ideas, magic box? 
you can't
ah man
no
there is a reason it is named image and not images
that would be enough images
yeah but they're pretty small then π
do you know how to implement that?
Nah, they arent shown properly. Like it already does if you send 4 attachments in chat
They get big if you click on them
# For this to work correctly, both embeds need the same `url` in the constructor. The URLs in `set_image` can be different.
embed = discord.Embed(url="some custom url")
embed.set_image(url="image 1")
embed2 = embed.copy()
embed2.set_image(url="image 2")
await send(embeds=[embed, embed2])
# Better code was suggested by Maya [455289384187592704]
wouldn't that just send 2 separate embeds?

time to do some testings
nevermind, it could work after reading the docs
TIL embeds get deduplicated by url, thats neat
when you open the bot tab in the developer portal, you can scroll down to see the privileged intents that you have to enable before your code can use them
as per the above text, you don't have to worry about verification for small bots
but what did you actually achieve
you don't know python and you just copy pasted the code and you understand none of it. not being rude but it's of no use
Go to your gift inventory in settings and it will give you one
I am on Android
It only works on PC sadly
They are not giving badge for genishi impact
They are giving a bundle
Hey there, im making a bot and im using the requests library but i need to send the request with a different ip then the one where the bot is hosted. How could i achieve that?
O.o
you could use a proxy maybe? also don't use requests library in a discord bot environment. aiohttp is the way to go.
yo long time.
yusssss come #ot2-never-nesterβs-nightmare
would it be like ```from main import make_final_video, main
I tried but it always use my ip and it doesnt use the proxy
its in a feedback loop
dont use events, use commands (as a beginner)
on_message is called when a message gets sent, but after a message is sent, the bot also sends a message, creating an endless loop
no thats not related to dpy
thats general #async-and-concurrency which is not dpy
it says the basics about how coroutines work by the looks of it. nothing to do with dpy
yes
lemme show two examples rq
it is though, since dpy is an asynchronous wrapper
yes, but its general #async-and-concurrency. it doesnt fix their problem
yes
π
# this is an event
@bot.event
async def on_message(message):
if message.content.startswith('thumbsup'):
await message.add_reaction('π')
# this is a command
@bot.command()
async def thumbs_up(ctx):
await ctx.message.add_reaction('π')```
yes it does not, though @wide plaza I'd suggest you do watch some tutorials to learn concepts like basic python, Object Oriented Programming, and Async Programming
once you learn them, dpy is easy
can you rephrase? im not getting your question.
also use the terms "function" and "method"
nope. you just made a feedback loop because its responding to itself
what language is "details and roots"?
no like the language you speak
no you cannot
nope
you're adding a reaction, so you need an emoji
does the python bot even run dpy?
!e py import discord embed = discord.Embed() embed.description = 'hi' print(embed.description)
@viscid hornet :x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | import discord
004 | ModuleNotFoundError: No module named 'discord'
exactly a copy of my example
no the two functions have the same name, that wont work
oh wait im stupid, i forgot to change the name
yours is correct
oh wait no i did change the name
but @wide plaza isn't
yes
cool 
this is almost correct, you just need to change the function name of the command
which is after async def
too much help β
no
they're two different things
because they are?
you can do that but its not a good practice.
is it too difficult to learn python basics first and then use discord.py?
Β―_(γ)_/Β―
thats how you're supposed to learn dpy - with python first. says in the dpy faq if you wanna take a look
you're not hearing me. they are:
TWO
SEPARATE
THINGS.
@wide plaza ill just say its difficult to teach basic python, espceially in a #discord-bots channel. You should really consider learning python first
learn python first, learn the terminology so communicating your problems is easier, and then learn dpy
good opinion but tbh people have their reasons, and besides its a good gateway for them to learn the rest of python if they're interested. discord bots can do almost anything databases , ai and wtv else
you should still know basic python
otherwise its hell trying to learn dpy
very true
ah the good old days
bot.run(token) π¦Ύ
yes. quite important
i dont send 1000 lines of code and expect you to find one line. where'd you get that from? 
for point 3, the differences are due to how dpy implemented their decorators, but knowing the technical details about it isn't too important
Would this work for a button?
@bot.command(name="test_buttons")
async def test_buttons(ctx):
view = discord.ui.View()
style = discord.ButtonStyle.green
embed = discord.Embed(title="Button Testing", description="This is a test")
item = discord.ui.Button(style=style, label="Test")
view.add_item(item=item)
await ctx.send("Test", view=view)
Cuz im hella new to buttons
Sure
oh fr?
You'd need a callback to make the button remotely useful though
I see
yes, but it's better to have a view with buttons or have your own subclassed button. not advisable just to make then in commands
mm. I see
like this, if you want an example: ```py
class MyButton(ui.Button):
def init(self):
super().init(your_qualities)
async def callback(self, interaction: ...):
# whatever you want to happen when the button
# gets clicked. uses interaction```
Okay! Thank you, I appreciate it
- Because otherwise the name of the function will reference the lastly defined function and the former definitions would lose reference. On another note, discord.py registers
async def on_messagefunctions decorated witheventas event handlers for the event of newly received messages. - Can, but this isn't meaningful in the same way. What you have will error because the name
ctxis not a thing in the.. context of the command function. - It's an arbitrary choice on two accounts
ik, it was a rethoric question given the state of this channel in the last 2 days
typehinting interaction as Ellipsis :kappa:
so you could have a green button that says "Click Me!" and when you click it, it responds saying "You clicked me!": ```py
class MyButton(ui.Button):
def init(self):
super().init(
label = "Click me!",
style = ButtonStyle.green
)
async def callback(self, interaction: ...):
await interaction.response.send_message("You clicked me!", ephemeral = True) # ephemerals make it so only you can see the message```
me fr
ohh. agreed honestly
Ok, I'm somewhat confused. I'm also new to making bots. What do I put for my qualities?
and ui.Button is also giving me an error
OHH
Didn't see this! Thanks lol
from discord import ui```
π
!d discord.ui.Button | here's everything about buttons
class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.
New in version 2.0.
all those arguments are your_qualities

Thanks again!
hold on, lemme bike and grab my pizza

(technically the command could shadow the event handler's name here, since dpy maintains separate references to the event and command callback, but either way on_message would be a weird name for a command)
Oh, one more thing
How would I refrence the button to use it?
would it just be MyButton.Super()?
Just, button = MyButton()
ok! Thanks!
Depends on the terms of service
AttributeError: module 'discord' has no attribute 'Intents'``` wsp with this? Python 3.10
Did you name some folder discord
for the send, would this work:
@bot.command(name="buttontest")
async def buttontest(ctx):
button = MyButton()
embed = discord.Embed(title="test", description="testing")
await ctx.send(embed=embed, view=button)
me?
nope, you need to add the button to a view like u were doing before
I see
Yes, you
nah I didnt name anything discord
Im trynna learn py and got the example from here https://discordpy.readthedocs.io/en/stable/quickstart.html
I was about to ask what do you work with
have you used "pip install discord"
yes
hm
ill redo it
Have you ever installed pycord?
The problem is you installed that and not discord.py then
This line worked 1st try for me:
bot = commands.Bot(command_prefix='-', intents=discord.Intents.all())
I just had to reinstall py ima make sure discords installed
Better uninstall whatever discord is and install discord.py
Ok I installed both and it worked
π
Isn't discord a mirror package of discord.py?
In the cmd here how could I call a function? if message.content.startswith('$hello'): await message.channel.send('Hello!')
!pypi discord
A mirror package for discord.py. Please install that instead.
Released on <t:1691703907:D>.
would I need to keep the await or just main()
the await is only needed if you're calling an asynchronous function, if its a regular function then you don't need it
in other words, the difference is: ```py
def my_normal_func(): ...
async def my_async_func(): ...
@bot.event
async def on_message(message):
my_normal_func()
await my_async_func()```
final question I hope lol
would this work?
@bot.command(name="buttontest")
async def buttontest(ctx):
button = MyButton()
view = discord.ui.View()
embed = discord.Embed(title="Button Testing", description="This is a test")
view.add_item(item=button)
await ctx.send(embed=embed, view=view)
Probably, show your MyButton class as well
Kk! Thank you for the help
import it from main.py
Are you calling the function in your command callback?
whats the best way to do that?
the main() function starts the video generation then the make_final_video(number_of_comments, length, reddit_object, bg_config) function ends it
why not send the message from the main function?
your functions should have one responsibility, as a matter of good design principle
one would not expect a function named "make_final_video` to send a discord DM
main just generates everything from the config then the other function starts the generation
once the generation is finished I need to dm the user the result
If I were to use a ephemeral to message a user thats not the command user, is that possible?
Nope
no
dang. alr
you could make a view with a button that tells them that information π€·π½ββοΈ
thats as close to your goal as i can think of
True, although ion want them to click a button
I want it to be forced tbh
as a joke lol
I settled for this
XD
just DMs them, which is somewhat more annoying
anyone know how I would use a website (in html) to send a value to a discordpy bot
my ideas would be:
- use a db and check up when something changed
- use a webhook and send data that way
- run your backend with a bot attr for your discord bot
π
the backend one only works if your backend is python
and you'd probably need a way to start something with your db
or occasionally loop and check the db
kk
How can I create a db to make a currency ?
And how do I check it, like if currency >= 1 ...
Idk python π
learn python first then
i dont think >= even works
anddd. what do you think im trynna do rn? π
I dont doubt it, I got that from js
!e py x = 5 if x >= 3: print("yes")
@viscid hornet :white_check_mark: Your 3.12 eval job has completed with return code 0.
yes
oh it does
so how would I make a variable for that assigned to each user id?
idk if a variable or a db would be best
Im assuming a ram variable wouldnt be good since those clear on restart
what, make a db for currencies?
thats pretty easy
Yea
I just need a way to give, store, and take a currency from people
oh thats easy. you just want 3 columns: user_id, wallet and bank
Nah I dont need a wallet and bank just need tokens
make user_id either a PRIMARY KEY or a UNIQUE integer
you said "store currency"
yes store as in save it
ohh okk
Yea I just need to know how to add remove and save currency
do you know SQL?
No not really
https://sqlbolt.com - go learn SQL then
SQLBolt provides a set of interactive lessons and exercises to help you learn SQL
the basics are fine
Its telling me how to write data, not create a database π
what?
creating a database is as easy as creating a file 
so create tokens.sql
its knowing how to use and work with it thats by far more important
yeah
I tried sql once for a website and gave up
you'll need it if you wanna make an effective database
For the collums just user id and token count right?
pretty much, yeah
I see here CREATE TABLE movies ( id INTEGER PRIMARY KEY, title TEXT, director TEXT, year INTEGER, length_minutes INTEGER ); when should I run this code tho?
make a seperate file and run it once? Run it on bot startup?
run it in a python file using sqlite3 or just run it on the db itself
im guessing you use sqlite?
idfk
β
ok, what db do you use?
I dont use a db Im trynna create one rn π

get sqlite if you want something easy and small.
get postgres if you have a relatively big project or something.
fuck the rest of them
Create an SQL file and consider using an asyncio sqlite wrapper like this https://github.com/Rapptz/asqlite
yes
by downloading it
thats for a later stage. let them get comfortable with using sqlite3 first and then get them to move onto asqlite
asqlite is basically the exact same as sqlite3 but asynchronous
Like is it a thing like python to download or is it a python package?
it's a python library, yes
!d sqlite3
Source code: Lib/sqlite3/
SQLite is a C library that provides a lightweight disk-based database that doesnβt require a separate server process and allows accessing the database using a nonstandard variant of the SQL query language. Some applications can use SQLite for internal data storage. Itβs also possible to prototype an application using SQLite and then port the code to a larger database such as PostgreSQL or Oracle.
The sqlite3 module was written by Gerhard HΓ€ring. It provides an SQL interface compliant with the DB-API 2.0 specification described by PEP 249, and requires SQLite 3.7.15 or newer.
This document includes four main sections:
yes. like i said, it's for a later stage when they start implementing it in their bot
let them learn sqlite first and then they can move onto asqlite
one step after the other, otherwise they'll fall over 
So pip install sqlite3 ?
yep
alr
I tried pip install sqlite but aint work so ig that why π
ERROR: No matching distribution found for sqlite3```
tf wrong with bros pc π π
Python 3.10 could be reason
you aint gonna believe what Im boutta say
ERROR: No matching distribution found for sqlite
WARNING: You are using pip version 21.2.3; however, version 24.0 is available.
You should consider upgrading via the 'C:\Program Files\Python310\python.exe -m pip install --upgrade pip' command.```
wait wtf
Im using python 3.10 and aint upgrading π
apparently its in the stdlib 
try just importing sqlite3
import sqlite3```
lmk if it comes up with missing module errors
wouldnt that upgrade python?
i have updated pip and it has the same error
nope. it upgrades pip. like it says in the name
what am I running tho?
wdym?
I dont got any code to run
start with this and we'll go from there
I got this CREATE TABLE movies ( id INTEGER PRIMARY KEY, title TEXT, director TEXT, year INTEGER, length_minutes INTEGER ); but thats not python
just make a file with that and run it? π
start with importing the library so we know if its there or not
just type it in and tell me if your editor raises any issues about missing imports
nah it worked
damn π
I ran it and outputted nothin so I assume it did
alr good start
!d sqlite3.connect
sqlite3.connect(database, timeout=5.0, detect_types=0, isolation_level='DEFERRED', check_same_thread=True, factory=sqlite3.Connection, cached_statements=128, uri=False, *, ...)```
Open a connection to an SQLite database.
(this makes a new db btw if one isnt found)
idk what this meanshttps://file.coffee/u/WjIMZlRVW9GpCDP5HQpm4.png
means its not accessed, ie. its not used
ah alr
accessing a module and importing it are two different things
yep
would this be easier for you to help to do over vc?
thats alotta errors
import sqlite3
conn = sqlite3.connect('whatever.db') # this makes your connection
conn.execute("whatever SQL statement") # this executes your SQL
conn.commit() # this saves your changes```
wdym?
β
this gave like 3 errors in the py file
stick to here
also did you know you can send screenshots here? 
both are literally the same thing

3 errors
.sqlite
whats the difference between a .sqlite file and a .sql file?
π€· I use sqlite
isnt sql a language and sqlite a software?
cursor.execute(
"CREATE TABLE IF NOT EXISTS data (user_id INTEGER, coins INTEGER)")
connection.commit()
This will work too
sqlite is a database
Well tried that File "C:\Users\liama\Downloads\RedditGen\bot\db.py", line 3, in <module> cursor.execute( NameError: name 'cursor' is not defined
Try this:
connection = sqlite3.connect("database2.sqlite")
print(connection.total_changes)
cursor = connection.cursor()
cursor.execute(
"CREATE TABLE IF NOT EXISTS data (user_id INTEGER, coins INTEGER)")
connection.commit()
U needa define cursor
.sql file. sqlite is a way to interpret sql files
just use the connection

that generated a sqlite file
fr
Yes, as it should
nice try buddy 
I use replit
Thats prob why lol
Alr. now how to I add things to it? I needa import userid and tokens
just execute your create statement
like how to use bot commands, like !help
which one π
the one to create the table with user ids and tokens? 
Yea
nope
If the prefix is "!", then doing !help would trigger the help command
!help β¬
οΈ always has a prefix
dis one?
id INTEGER PRIMARY KEY,
title TEXT,
director TEXT,
year INTEGER,
length_minutes INTEGER
);```??
Prefix here is just something that you will need to put before the command name for it to execute
in this case !command_name
does that have user ids and tokens 
@wide plaza If for example you have "-" as the prefix, then -help would be the command
instead of !help
yes, although / is a slash command
without nothing, it should work, ? and ! aswell
yes
"CREATE TABLE IF NOT EXISTS data (user_id INTEGER, coins INTEGER)")
connection.commit()```? this? theres alotta code with user ids and tokens π
Although, nothing is quite annoying to work with
Thats a custom variable lol
/ should work probably too but there are slash commands for that and im unsure if something could error because of that
but you could try it
creating one is:
cursor.execute("CREATE TABLE IF NOT EXSISTS <name> (<var> <type>)
true
For an embed
Yea thats already in the code
connection = sqlite3.connect("bot/database.sqlite")
print(connection.total_changes)
cursor = connection.cursor()
cursor.execute(
"CREATE TABLE IF NOT EXISTS data (user_id INTEGER, tokens INTEGER)")
connection.commit()```
No, that you customize in dev portal
brother just read it π
How do I now add a userid to this and give the user id tokens?
INSERT INTO 
this feels like #databases topic
Im deaf in my left hair follicle so I cant : /
its for a discord bot thooo
cursor.execute(f"INSERT INTO data WHERE user_id = {user id var}
yeah but we're talking about databases primarily
most of the stuff are still related to sql and databases
sorta β
you should use sanitisation for your inputs. dont just use f strings
little bobby tables will explain why
why is there an f? π
it's called an f string
F string, a way of formatting your average string
ohh those thingys
so like cursor.execute(f"INSERT INTO data WHERE user_id = userid") ?
and please for the love of god, dont call your .Bot client π
no
damn
#databases i'll explain there
ye
you would most likely go for the second one
most of people do because of "Cogs" that are supported by commands.Bot but not by discord.Client
also more functionality
It also inherits Client so no reason not to use it
yep
yeah you need to import commands from d.py's extensions
from discord.ext import commands
whoopsies
!d discord.ext.commands.Bot
class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a Discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client) and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client) you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin) to provide the functionality to manage commands.
Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client), this class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree) and is automatically set upon instantiating the class.
async with x Asynchronously initialises the bot and automatically cleans up.
New in version 2.0.
yep
the description is just an optional text you can put on the default help command
nah itβs just a general description that you can show on the default help command
read the docs: https://discordpy.readthedocs.io/en/latest/intents.html
Yeah those are intents
sort of
I would just describe intents as stuff that your bot can see/do if something is enabled
you need to pass your intents as an keyword argument to the Bot class, also yeah thats how you set intents, for example
intents = discord.Intents()
intents.emojis = True
it means that the intents defined by you should be passed to your Bot class as an keyword argument intents
Ok Ima come back to my economy system later, how do I add a / command?
I dont think thats how that works
also how do you do a prefix var is it like if message.content.startswith(command_prefix + 'test'): ?
what docs u reading?
whys this mf reading the intents docs π
you're just controlling what you want your bot to be checking
ngl, .typing i havent seen
!d discord.Intents.typing
Whether guild and direct message typing related events are enabled.
This is a shortcut to set or get both guild_typing and dm_typing.
This corresponds to the following events:
β’ on_typing() (both guilds and DMs)
This does not correspond to any attributes or classes in the library in terms of cache.
import main from main?
wait no
from main import main maybe?
nope
it didnt work
from ..main import main gave this Traceback (most recent call last): File "C:\Users\liama\Downloads\folder\code\bot\bot.py", line 2, in <module> from ..main import main ImportError: attempted relative import with no known parent package
the bot is in bot/main.py and im importing from ../main.py
so I need the 2 dots since importing from outside the bot folder
My files are like this
β
βββ main.py
βββ bot/
βββ bot.py
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape wtf
from proj_root.main import β¦
last two arenβt necessarily related
yeah pretty much
from ..main import main
ImportError: attempted relative import with no known parent package```









