#discord-bots
1 messages · Page 856 of 1
from datetime import datetime, timezone
datetime.now(timezone(timedelta(hours=-5), 'EST'))
hi again , im making a discord game that has multiple people with different accounts, im unsuure on how to set up a data base which basically gets rid of the whole games idea, is there anyone that could help with setting up a data base? Thanks
o, ty srrry
2 seperate errors, it works tho
not a discord issue either 
socket error
i have a command that looks up minecraft servers i just a random word as the hostname so the error came
its nothing bad lmao
prob down yes
its for a minecraft server dude
..
it sais basicly unknown host, and u passing in a discordid
its nothing bad
its not even a hostname
the discordid is so i can have the author id
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
bro ur overcomplicaing this
show ur code ?
oh ok
holy hell
then why u post it?
because
im making an error logger
that logs the error message and the user who caused the error
and the command used to cause it
i mean what is it for anyone else here ?
The shard ping is in seconds
@merry charmthanks for clearing up tho, i thought u needed help 😛
i had the idea, @slate swan said to do it, so i did.
i will its just so i can see how it changes
it changes between commands
different commands cause more or less ping
might round it when i find a better way
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
8. Do not help with ongoing exams. When helping with homework, help people learn how to do the assignment without doing it for them.
this
Sorry : /
hello
It's caeden, most likely hasn't even read the rules.
🙃
Sometimes this channel is a mess and sometimes its dead asf
Same
say whattt
im reformed
you made too many requests to the API and now you are temp-banned from using it
what name should I use to make an error handler for my API i am using pycord
on_error/on_command_error events ofc
or try/except everywhere
i tried those its just its an api and I cannot find any name like on_api_error i am thinking it might have some other name for it
why would that be a thing, you api is nothing related to the discord.py module
pycord
yes i tried using on_error and on_command_error doesnt works so i thought for api error handlers it has something else which pycord has cuz @bot.event is handled by pycord
yea whatever the fork is, its still not related to an errror cause by your API so there would be no event for that
ohh so like cant make error handlers for api?

ahh shit, thanks for the warn though, I really needed to get in line with my texts but wasnt able to 😭
ah you went afk, no problem :) thanks for responding
I feel you
welp, I deeply apologize again and of course I won't ignore you you're too cool to be ignored anyways, no flattering
lol, ty ty, and np
well, you shouldnt know
How I can fetch all users id in server/guild
👀 that is why just playing skribbl to ignore that thing
on_command_error
allmembers = 0
for guild in bot.guilds:
for member in guild.members:
allmembers += 1
He wanna ask something else but cannot explain
👀 why spoonfeed
sry
i just hate having to explain something with so little detail
everyone hates that
🥄 feed 😔
Lmao
i am trying this i tried printing 'error' as well as error to see if the event is getting triggered
@bot.event
async def on_command_error(error):
print(error)
print('error')
if isinstance(error, saucenao_api.UnknownClientError):
print('yes')
just do
@bot.event
async def on_command_error(ctx, error):
await ctx.send(f"ey bub u triggered an error\n`{error}`")
not working its printing the entire error
you said to print the error
no like the red error
and the event isnt trigger as well cuz its not printing error in string as well
thats why
does it makes difference or anything?
ohhh
slash commands have different error handlers
Another cool way you could do this, idk if it's faster/slower though maybe the map pulls through with some performance same with attrgetter ```py
import operator; *ids, _ = map(operator.attrgetter("id"), Guild.members)
How we can message someone from bot through id
i dont know what you're using
you can first get the user then use the send method on the member object
like if error handlers for slash command is different where can I know how to make it?
Could've use a lambda instead of operator.attrgetter but I'm pretty sure the lambda would be slower than operator.attrgetter
!d discord.Guild.get_member returns a Member object
get_member(user_id, /)```
Returns a member with the given ID.
Still not even sure if what I did was faster than a regular list comp
Probably micro-optimisation
depends what api you're using for said slash commands
no
hey! just woke up went to run my bot! and realized it doesnt print when i run it but it works?
anyone know why
i had it working before then i went to make a music command and now it doesnt
yess so i gotta learn docs of pycord or the api of error?
yeah
pycord or api?
ohh alright
thanks
my ban doesnt work
I wonder why...
lol
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
you're trying to catch a shark with a stick and a spider web

what is this supposed to be about im so confused
nvm forget it, ill just stop trying to code 😭
worst option
error?
HUH
can someone help me with a json problem on my bot
sure
@commands.command()
async def dict(self, ctx, value, item):
file = {
str(ctx.author.id):[
{
str(value):str(item)
}
]
}
with open('json/out.json', 'w') as f:
json.dump(file, f, indent=2)
``` how can i make a new dict and then add stuff to it
json != db
i tried asking in #python-discussion but i couldnt get a clear answer
databases i dont need for now
this will only hold like 5 dicts max with about 10 - 20 values each
json base is a nice api to store stuffs ngl
👁️ 👁️
someone pls help me with my ban command 😿 im so confused
just ask
ill recommend a db json is quite for storing data
i already have
more like formatting data
the indents are put up wrong?
!indents
oh

how do i fix them then
ill recommend learning basic python
not sure if making bots and not knowing pasic python is a good idea
!resources to get you started
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
it was my friends idea
well, discord bot comes under the category of intermediate-advanced so....
well the person is wrong.
You're going to struggle basically every step of the way and not understand why if you don't know any python
youll just learn syntax and not actual python or oop
👀
Yerlikaya has a point
Can u please refer to people as their nicks? Lmao it feels weird opening their profiles only to read their user names
You do know that people tend to ignore things like these, right? 
Eh, I can understand them. I also started coding with discord.py when I didn't know what is asyncio, module or something like classes even exist
Mmhm can you share a roadmap from basics to programming a bot?
a lot of people even don't know how to code but start making bot
Sequential Programming > Functions > Async Functions > Asyncio > Classes > Decos > Whatever you wanna do
does programmers
#discord-bots message
literally from the pins
sorry, if it will be pinned, it has to look professional
Thanks
yeah
what we know eachother right yerlikaya🏃
O 👀

Smh
@final iron background screams
Rip everybody wants me to leave
You are not even doing anything in the command, it'll always error out, user isnt defined either
Lmao
Rip my time has ended, i'll lurk in some other servers for a while
just check out the resource page
Lmao okay
just make him set a default value to username
its also embed=userfail
Welp
eevee is back
🤣
oh then I'm gone
anyone got command ideas? added the weird.. ones last night but i need some more
I was wondering if you learn to develop discord bots etc then will you be considered a good dev? Or a bot project counts as just a small project 🤔 .. Idk if my question makes any sense tho but I think u do learn to use APIs and SQL etc so will you be actually able to survive in the world with that skillset? Or it makes it easier?
username=None in your async def
Probably only helps generally with OOP & concurrent programming, you'd still probably need to learn algos or other things
Hmm DSA etc
True
And things such as time-complexity which is crucial in real life, you don't really learn that via discord bots
discord.py might as well cause some misconceptions with typehinting
low level stuff too like cpu and os
Now I think about it.. I was looking for where to begin learning those stuff like do you guys recommend a course for it or start by building some specific project?
I mean DSA and time complexity etc
Perhaps codewars, leetcode etc
Time complexity could probably be covered with some articles or the alike
Algorithms will have their own wiki pages most often
Hmm
They teach time complexity in data structures, do some course or whatever on them
Also a wiki on sequence objects time complexity here https://wiki.python.org/moin/TimeComplexity
Thx
is it possible that a bot can write a command on its own in discord?
sb can help me real quick?
for ex if command for a bot is !play.....so is it possible for me to make a bot which can write !play on its own without calling it like ...its done automatically
a global check
You can use the on_command event to check if the command invoker is a bot or not
!d discord.ext.commands.check oopsie wrong one
ok thanks
Specifies if the user is a bot account.
i dont know much about discord bots i just want to know if its possible
so like if ctx.author == bot: return
!d discord.ext.commands.Bot.check
@check```
A decorator that adds a global check to the bot.
A global check is similar to a [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is applied on a per command basis except it is run before any command checks have been verified and applies to every command the bot has.
Note
This function can either be a regular function or a coroutine.
Similar to a command [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check"), this takes a single parameter of type [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context") and can only raise exceptions inherited from [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError").
Example...
oh ok
there is this bot which does something when called and the thing is you can call the bot every 1 hour so i would like to know if its possible that I can make a bot that does that job for me
yes something like that.......OK my real problem is this ....there is this bot soccer guru so everytime you write the command sclaim you get a football player and you can call this bot every 1 hour that is 24 times a day so i would like to know if it is possible that i make a bot which calls this other bot every hour.....
tl;dr no
Any well-programmed bot won't respond to other bots, unless they have a good very specific reason to
okkk thank you
Tried it, doesn't work
Lmaoo
Imagine running one on replit 👀
Rip, I regret seeing yr pfp and banner now ;-;
I got ophidiophobia
totally didn't copy that word off internet
watch me 
@client.command()
async def setup(ctx):
guild=client.guilds[0]
await guild.create_text_channel('cool-channel')
channel=client.get_channel("cool-channel")
await channel.send("Testing")
What's wrong here
nothing
It doesn't work. It says Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send'
get_channel(id, /)```
Returns a channel or thread with the given ID.
just do channel = await guild.create_text_channel('cool-channel')
hmm
wait
i want to create a channel and make the bot send a message in the newly created channel
oooh thanks
wait
still waiting even tho am sleepy

if you were to make it so there was a button on a message and you were to click it could you add another button on that message you clicked
you would have a view, and when the button is clicked you would use view.add_item(your_button)
depending on your fork
what library are you using?
okay
a discord.py example: ```py
import discord
from discord.ui import View, Button, button
class MyButton(Button):
def init(self):
super().init(
label="...",
...
)
async def callback(self):
"""this gets called when the button is pressed"""
class MyView(View):
@button(...)
async def add_button(self, button: Button, interaction: discord.MessageInteraction):
self.add_item(MyButton())
# edit your message
async def command(ctx):
await ctx.send(view=MyView())
hopefully this helps
you pair add_item with editing your message
!d discord.ui.View.add_item
add_item(item)```
Adds an item to the view.
whats wrong with this? trying to get it to play with spotify url
so much wrong with this
does anyone here use discord-interactions
what is that?
When the warnas reach 3/3, it is necessary that the variable be reset, and on a new
whats disnake
Fork of dpy that has more builtin features
import string as pycharm```
Me big brain
@slim ibex
how do i use discord.py documentation
just started usng pycharm and everything is wrong but in visual code it isnt
why is this
is it cuz nothings imported?
oh
i see
It’s because of the linter iirc
it picks up all things that violate pep8
oh
You see how and which methods are to be implemented on objects-
I highly recommend you to visit #editors-ides
You can weirdify it as much as you like there, read rule 7 though
Restart editor
Using
heroku
You need a requirements.txt file also, this is not the appropriate channel, claim a help channel and ping me there
Just get the Member object and use the ban method on it
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
await member.ban(reason="cuz")
i am using requirements.txt
Whats member?
Thats really not helpful
well everytime i am helpful everyone bitches at me for "spoonfeeding"
Please claim a help channel and ping me there, this is not the appropriate channel
@bot.command()
async def ban(ctx, member: discord.Member, *, reason=None):
if reason == None:
await member.ban(reason="No reason given")
await ctx.send(f"Banned {member.name!}")
return
await member.ban(reason=reason)
await ctx.send(f"Banned {member.name} from this server!")
spoon feed much?
bruh
that's not how we help 
💀
Don't spoonfeed
It helps no one
Because there are other ways of explaining
Also calm down, no need to use that language
== cool
lol
i dont know how to help without spoonfeeding
idk what the "limit" is
await ctx.send(f"Banned {member.name!}")
return
```no one-liner sad 
Also, you can put the no reason given as the default value of reason, shorten your code by 4 lines
oh well
Imagine
i did that but then @slate swan said i didnt define member and that it wont be helpful
this never bans the user it just says it did thats not helpful
wth
Can you please not ping me without any valid reason?
gotcha
has been banned by ctx.author.name
np
remember brackets
this was working earlier now isnt
im stupid
why?
holy hell
- you probably changed py version
- what the hell
sympy isnt imported aswell so idk what it is might be pip install sympy in cmd
thats why its yellow
it is
no
it is imported
just on the wrong version
yea
did it ever get a new update
that would result in needing to import the new files
I literally told you 2 times to not ask about such things in this channel, can you please not? @slate swan please read that politely
please remove unused imports
yes
i will
huhhh?
such things?
as in
as in general python
embed = discord.Embed(
title = "my title",
description = "description",
color = discord.Color.random()
)
i did nothing wrong??
oh
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
sorry
they probably do tbh
Ashley is the main off-topic person
No
yes
they recite the rules in their sleep
so if Ashley says go away, you probably aren't talking bout dpy
I've changed since i got a warning from an admin 💀
you have to follow rules in here if you guys dont like to follow them leave lol
minimodding?
nah, u're still the same
wtf is wrong, help
def get_prefix(client, message):
prefixes = ['-', '~']
if not message.guild:
prefixes = ['?'] # Only allow '==' as a prefix when in DMs, this is optional
return commands.when_mentioned_or(*prefixes)(client, message)
intents = discord.Intents.all()
Streams=("https://www.youtube.com/watch?v=DWcJFNfaw9c")
StreamName=("Lofi Girl - lofi hip hop radio - beats to sleep/chill to")
bot = commands.Bot(command_prefix=get_prefix,
description='A Music Bot',
case_insensitive=True,intents=intents,status=discord.Status.online, activity=discord.Streaming(name=StreamName, url=Streams))
bot.add_cog(Music(bot))
client = bot
It won't respond to the prefix, whereas it did before, but i didn't change anything AHHHH
and your warning was because of rude speech, I saw the whole thing
Too lazy
when do you run your bot
no being responsible
??, u mean where
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
when does the bot run
dude
where is the bots run function
this is really confusing me rn
EY
ive seen that so many times
op wrong reply
not sure why youre doing a instance of a class instance
@slate swan they never set the cog as a class IF it is
And remember, member without defining it is useless
i just need the limit of code i can send someone until its considered spoonfeeding
I just run it manually, but I do have this:
@client.event
async def on_ready():
client.togetherControl = await DiscordTogether("------------ Redacted :)")
print('Bot is online!')
alive_status.start()
connections: ['(aiohttp.client_proto.ResponseHandler)']
@tasks.loop(seconds=10)
async def alive_status():
session = aiohttp.ClientSession()
await session.get('oof')
Session1 = await session.get('------------ Redacted :)')
await session.get('------------ Redacted :)')
Sesiop = await session.get('------------ Redacted :)')
await session.get('------------ Redacted :)')
print(Sesiop)
print(Session1)
print(session)
await session.close()
ye also there is no setup function 
yikers
the error handling after it looks bad
why are you doing so much sessions
they need their sessions for their dog photo api
it's so it http requests it's self and another bot so that other bot can do the same thing so it alsmost never has downtime
your sentry key is showing 😳
making 3 request each 10 seconds?
oh the rate limiting 😮💨
I get things like "nosniff lmao
quick question
Hi am trying to have user enter their name under name section?
How?
This is my code here
why not get the users name with the .name attr
the owner_id for @commands.is_owner() right?
dont use str for ctx.author as its already a string {ctx.author}
no bot owner
use owner_ids if you want an alt or something to access them
no owner_ids and owner_id both work in this situation
im literally using them right now and they work
alr ty
This is my code here
this is one request
owner_ids = [id, id, id, id]
the default takes the id from applications and looks for the bots owner
async def start(ctx):
embed=discord.Embed(title="Profile", description="Desc", color=0x00ff00)
embed.add_field(name= f"User: {ctx.author.mention}", value="✅Verified 18+✅", inline=False)
embed.add_field(name=str(name), value=str(name), inline=False)
await ctx.send(embed=embed)
print(f"The embed has been send")
but, seriously, how, I even tried just plain prefix, still, didn't work
then add the bots application owner
bro
They're saying that's done automatically if you don't define it
sent*
async def start(ctx):
embed=discord.Embed(title="Profile", description="Desc", color=0x00ff00)
embed.add_field(name= f"User: {ctx.author.mention}", value="✅Verified 18+✅", inline=False)
embed.add_field(name={name}, value={ctx.author}, inline=False)
await ctx.send(embed=embed)
print(f"The embed has been send")
```
so owner_ids is rlly handy for me
thank you for making it more clear
async def callback(self, interaction):
response = requests.get(f'https://discord.com/api/v9/users/{userId}/profile', headers=headers, params=params)```
anyone know how i can get the userId of the person that clicked the button using discord.py
Whats the issue with the code...
Damn, you just-
just use .author with context which returns a Member obj and since the class has a .name property use it
Ok i am trying to have a user enter his/her name in as a embed question if that make sense
in your line ```py
embed.add_field(name={name}, value={ctx.author}, inline=False)
are `{name}` and `{ctx.author}` in f strings? otherwise use name=name and value=ctx.author
making a request on each click oof
rate limiiiiitssss
I know it's not my code, because I use this on a verified bot, so
go brrrrrrrr
idk why it's not working
what do i do i am a nub
pov: is_ws_ratelimited is typing
😳
wait it isnt your code?
I use the prefix and requests on another bot and it works perfectly
check ur intents
no, i own a bot, that is verified lol
command_prefix = commands.when_mentioned_or(["b!","B!"]) or command_prefix = commands.when_mentioned_or["b!","B!"]
async def callback(self, interaction):
response = requests.get(f'https://discord.com/api/v9/users/{userId}/profile', headers=headers, params=params)```
anyone know how i can get the userId of the person that clicked the button using discord.py
i am nub so i need help
I enabled all of them
im too lazy to try it

the exact code on your verified one works but your non verified one doesnt?
yep
whats the difference?
is anything password protected or hwid protected?
just a bit of added features so it can have custom prefixes, but it worked when i had the exact code too
try Saad's response
ctx.author?
ah well its a method so just put the list inside of the params of the method
(list) and the other without ()
ctx.author.name lol
oh alr
thx, I'll try it ❤️

WHen i do do member.name it says its not defined
code?
because its not a variable thats defined?
its basic oop
not even
thats for prefix 
async def start(ctx):
embed=discord.Embed(title="Profile", description="Desc", color=0x00ff00)
embed.add_field(name= f"User: {ctx.author.mention}", value=":white_check_mark:Verified 18+:white_check_mark:", inline=False)
embed.add_field(name=f"{ctx.author.name}", value=f"{ctx.author.name}", inline=False)
await ctx.send(embed=embed)
print(f"The embed has been send")
```
i just want it to the user can enter his/her name
thats all
hmm
idk
you don't have to know no oop to define a variable
this sucks, wtf do I do
yup
@neat pagoda
So?
i would recommend using the name on discord than the user inputting a name
Hi
bro i gaved you an answer
Meaning?
what
thx, I'll try it
interaction.author.id
I came to this channel after literal 3 months
wait so name=f"member.name", value="inputting a name"?
^
sure ig
idk
Please help me
AttributeError: 'Interaction' object has no attribute 'author'
Depends on the Lib it maybe Interaction.user
so what do you want with f"member.name"
Does that mean anything? the built in function thing
ty it works now
You can't use mentions on titles
I think
indeed
@cold sonnet
Code?
I don't know how those got there

im not gonna even say anything
async def start(ctx):
embed=discord.Embed(title="Profile", description="Desc", color=0x00ff00)
embed.add_field(name= f"User: {ctx.author.name}", value="✅Verified 18+✅", inline=False)
embed.add_field(name=f"{ctx.author.name}", value="{ctx.author.name}", inline=False)
await ctx.send(embed=embed)
print(f"The embed has been send")```
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
and you don't even need it
async def start(ctx):
embed=discord.Embed(title="Profile", description="Desc", color=0x00ff00)
embed.add_field(name= f"User: f{ctx.author.name}", value="✅Verified 18+✅", inline=False)
embed.add_field(name=f"{ctx.author.name}", value="{ctx.author.name}", inline=False)
await ctx.send(embed=embed)
print(f"The embed has been send")
ctx.author.name returns a string
useless f string
Bruh just use str() if you want to be like that
f"User: f{ctx.author.name}"
no
just put ctx.author.name
that gives the name and the discriminator
So str{ctx.author.name}?
!resources please
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
Um no you need to learn some python first 🙂
async def callback(self, interaction):
print(interaction.user.id)
response = requests.get(f'https://discord.com/api/v9/users/{interaction.user.id}/profile', headers=headers, params=params)
So I did this but now I want to get a string from the button command
async def create(ctx, numTime, serverInvite, prize):
inviteCode = serverInvite.split("/")[3]
serverId = requests.get(f"https://discord.com/api/v9/invites/{inviteCode}").json()['guild']['id']```
like i would want to get the serverId
omg
async def callback(self, interaction):
print(interaction.user.id)
response = requests.get(f'https://discord.com/api/v9/users/{interaction.user.id}/profile', headers=headers, params=params)
So I did this but now I want to get a string from the button command
async def create(ctx, numTime, serverInvite, prize):
inviteCode = serverInvite.split("/")[3]
serverId = requests.get(f"https://discord.com/api/v9/invites/{inviteCode}").json()['guild']['id']```
like i would want to get the serverId
oh so we can't just use resources for someone
thinking anyone will read it
nah
I'm just gonna try helping those who have a day of python experience without saying anything
could anyone help me my question is up top
the silence tho
what lib is this?
"like i would want to get the serverId"
you only want the serverid?
well save ctx.guild.id
nah I'm honestly dumb
save serverId (camelCase is against pep8) to a bot variable
like bot.serverId = serverId
then you'll be able to access it from your button... Ig that's what you want?
I'm really just guessing, so if I didn't get it yet, provide more detail
i'm trying to get a serverid of the server I put in the $create command
what i'm trying to do now is the the serverid var in my
async def callback(self, interaction):
print(interaction.user.id)
response = requests.get(f'https://discord.com/api/v9/users/{interaction.user.id}/profile', headers=headers, params=params)```
Requests is blocking and why are you going through the bare api
hello i need som help somone help me?
how do i put like more stuff on the embed?
When the warnas reach 3/3, it is necessary that the variable be reset, and on a new (sql)
!d discord.Embed.add_field
add_field(*, name, value, inline=True)```
Adds a field to the embed object.
This function returns the class instance to allow for fluent-style chaining.
thanks works!
🤔
;
Okay

a ; is not used when using sql in a bot
✅
Still better practice too
dud how is it a better practice when you cant use a ; in a bot? You only use a ; when you're using the cmd prompt
yeah, I remember using ; in asyncpg
I used sqlite
asyncpg is just SS tier
ok, so you're saying that im supposed to do this?
await bot.pg_db.execute("DELETE FROM something");
This isn't javascript 😔
im talking about asnycpg and python and postgres
@manic wing :white_check_mark: Your eval job has completed with return code 0.
001 | 3
002 | 2
003 | 1
004 | 0
ive used sql and postgres
inhumane
it can mean whatever you want it to
you can write your code with ; after every line
theres no problem with it
can you show me how you do it in ur bot?
We're talking about sql, not python
and that guy is talking about using sql in a bot 🙂
I keep getting this error. The code for unreact is attached.
SQL is SQL. It doesn't matter where its used
🗿
😹
why he laughing
never said he was wrong tho
but that laugh is kinda sarcastic
It doesn’t matter where sql is used
you use ; at the end of sql queries
and not at the end of a python line

yeah
; is to end a query
I know...
sqlite doesnt use it iirc
it works in python 
Sqlite does
!e print('h') ; print('i')
@vast gale :white_check_mark: Your eval job has completed with return code 0.
001 | h
002 | i
Never said it didn't, just said it's unpythonic
ah, true that
at the end of the day, all python sql wrappers put stuff in a sql query
or a comma
!e print('h') , print('i')
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | h
002 | i
I got this error the code is attached. How would I fix it I've been trying.
seems like its None
please do never type that again
^
on_reaction_remove returns member as None
I don't have anything set to None.
i use it allot?
you wrote a tuple which is (None, None)
!e
a = None
print(a.strip(" "))
the value
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | AttributeError: 'NoneType' object has no attribute 'strip'
Where you see that?
yes
Discord docs
!d discord.on_reaction_remove
discord.on_reaction_remove(reaction, user)```
Called when a message has a reaction removed from it. Similar to on\_message\_edit, if the message is not found in the internal message cache, then this event will not be called.
Note
To get the message being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Reaction.message "discord.Reaction.message").
This requires both [`Intents.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.reactions "discord.Intents.reactions") and [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
Note
Consider using [`on_raw_reaction_remove()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_remove "discord.on_raw_reaction_remove") if you need this and do not want to enable the members intent.
I'm using on_raw_reactions_remove..
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
🗿
No documentation found for the requested symbol.
I've tried everything it says I can't seem to get it fixed.
Did you even read what I sent?
!d discord.on_raw_reaction_remove
discord.on_raw_reaction_remove(payload)```
Called when a message has a reaction removed. Unlike [`on_reaction_remove()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_reaction_remove "discord.on_reaction_remove"), this is called regardless of the state of the internal message cache.
This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
Yeah.
It doesn't return member
Because it has no attribute.
it does
No
It doesn't return it
that's why the line
await bot.get_guild(payload.guild_id).get_member(payload.user_id).remove_roles(role)
exists
nah, the discord api just sucks
No
remove actually doesn't return a member like add
So payload.member()??
on_raw_reaction_remove doesn't return a member
check in the docs
I can't
class discord.RawReactionActionEvent```
Represents the payload for a [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") or [`on_raw_reaction_remove()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_remove "discord.on_raw_reaction_remove") event.
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
click and see
It doesn't return a member object
Pick.
Neither
Only available if event_type is REACTION_ADD
Never said you couldn't?
that there's no member attribute...
...which is entirely a discord limitation
Trying to make this person understand it doesn't return a member object
Screw it I quit.
I don't understand what y'all trying to tell me to do to fix this problem of mine, everytime I ask here I get a bull crap answer I have no way of understanding.
we chillin
Yes.
Using this would be better
hey i want it so when i say a command the bot responds to it in the channel, (example, i say $hi and it says hello but only i can do that)
async def waa(ctx, author):
while True:
if author.id == 940652261141516370:
if ctx.content.startswith('$hi'):
ctx.channel.send('hello')```
On the on_raw_reaction_remove?
infinite loop? What’s the purpose
so its always ready to respond when i say something
my private bot uses this for no reason
that just means that it will keep sending hello if the conditions are true iirc. And the indentation in that ctx channel send looks weird
I could use what reptile said
Check out this tutorial
https://vcokltfre.dev/
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
Yes.
^^
It's faster than what reptile sent
Because it only searches through the members in the guild
!e
while True:
print("hello")
@slim ibex :x: Your eval job has completed with return code 143 (SIGTERM).
001 | hello
002 | hello
003 | hello
004 | hello
005 | hello
006 | hello
007 | hello
008 | hello
009 | hello
010 | hello
011 | hello
... (truncated - too many lines)
Full output: too long to upload
No all the members the bot can see
even if your bot's only in one server?
i also want to do it for some users that arnt the owner
I'm trying to fix a glitch in it lol. You fall through the map lol.
You see how while True will just keep looping
You could try timing it 5-10 times and comparing the average speeds
I hate when people check for user id with a single id
await ctx.send
why
^
if user.id in (id, …)
if user.id(435465642563, 54832578432)
ctx.send('blah')
its a coro
^
.send is a coroutine
needs to be awaited
and you forgot a colon
ctx.send enoguh
ye almost all 3/5 ppl who ask here dont know enough python to make a discord bot
done that all the time, output? ignored 😂
or just say "just help me"
ye
The name of the command.
yw
@bot.command()
async def addimg(ctx,link):
('gracieims.txt').append(link)
if link in ('gracieimgs.txt'):
await ctx.reply("**Your image has been added, thanks for submitting!**")
@bot.command()
async def removeimg(ctx,link):
('gracieims.txt').remove(link)
if link in ('gracieimgs.txt'):
await ctx.reply("**Your image has been removed from the database.**")
did i do this correctly? i don't think so since the command isn't working.
database?
yes
im using a txt file tho
you shouldnt store data in a txt file
ion got a database
Not hard to make one
^
ive been told that b4
You really don’t even have to make it
how do i make one?
then why not listen?
(‘file.txt’)🗿
laziness, but i wanna do it now
^
link is a str as said
i was testing something but it didnt work 💀
it’s just going to append the link to that tuple iirc
does tuple even have an append method?
They are immutable
ohh
basic python
hm alright so what database should i use?
sqlite to store data in a file and postgresql for server
so basically i have a txt file full of discord media links and i have a command ;img where users can get a random image. the ;addimg let’s users add images to this txt file , and the ;removeimg is self-explanatory.
alright yeah sqlite
but you are attempting to append to this tuple that contains the text file name
- you need to learn sql
- use aiosqlite
alright
have you showed the message in #community-meta ?
probably should learn more Python before continuing your project
its basic python
yeah i never did coding, i started coding my bot in decemeber
everyone should know that
not really into coding, just wanted to make a bot, but i should probably learn to code.
why yall so mean to people who just started python and wanna create a bot
def is_blacklisted()->Callable[[T], T]:
def predicate(ctx: AnyContext)->bool:
result = db.field("SELECT BlackListRoleID FROM Guild WHERE GuildID IS ?", ctx.guild.id)
return True if result is None or result not in any(role.id == result for role in ctx.author.roles) else raise CheckFailure()
why the interpreter is saying that raise CheckFailure() is unreachable in this code?
😭
because you should learn the language first lmao
😭
atleast be nice bruh
we're not being mean we're just telling the truth
🗿
Don’t see how this returns Callable? Do you return the predicate function?
you always need to return the function in a deco
^
def deco():
def method():
...
return method
yup didn't wrote it yet D_D
def deco():
def method():
...
return method
help?? it shouldve worked
but even if i wrote it the warning is still there D_D
oh shit im blind
It’s because you return the function before that line
i found that on a yt vid
honestly half of my code (if not all) is from yt videos and people helping me on this server 😭
i do want to learn to code but it’ll take time
me too
yt tutorials are all bad
Don’t copy off YT if you don’t listen to what they say
and that’s what i don’t have
- you only learn syntax
- most things are deprecated and outdated
- not clear
Except Corey Schafer and tech with Tim
yes i agree
i could pay someone to code a bot, but i don’t have money. so what do you have? a combination of no time or money? you code your own bot without knowing any code
Corey is the goat no cap
it’s easy for you guys to say i should learn this or that, but it’s really hard to understand for me
someone just give me a ban code bruh
No
this
No
i hope ur grandma gets bullied at bingo
okay this is too far, i feel like they should guide you, not just spoon feed you
cool
will look into it! :D thanks!
This server doesn't allow recruiting/ asking for paid for of any kind.
Don’t be disrespectful
most of those services are horrible and ran by developers who dont know everything in the most part
yeah of course, never said i would (i don’t even have the money to do so) i’m talking outside of the server, i have coder friends that could do it for me, that’s what i meant
i’m talking about my coder friends 😭
if hes your friend why is he asking for money?
who here isnt rude nd shit and can help me with my bot
we did you just can help yourself
because it’s a service and it takes time, you wouldn’t sell someone a house for free just because they’re your friend
you want everything given to you which we do not do here
all u did is say "no"
very very nice support
i agree, people should try to guide you in the right direction. but maybe let’s chill 😅
its a bot its a favor
read above lol
you asked if you can get spoonfeed which no we do not do here
u didnt even help me with my code bruh
true i didnt but panda did
also someone pin this pls !
he did?
^ (I can’t react Lol)
okimii just trolling at this point 💀
LMFAIQJHS
nah im just getting confused with ernesto lol
i was trying to make a kick and ban code
yeah i am just gonna ask my coder friend to spoon feed me 😭 i’ll learn on my own time, and later on i can adjust it
bro I legit told you what to do
IM NOT TROLLING WKBDIEJDHEHDUSJ
yep you did not panda lol
uhh not good idea
ik youre not lol
what
at this point yt tutorials will be more useful 😭
Getting spoon fed gets you no where
^
literally
@coarse anvil
guys we help everyone if you cant help yourself thats not really our problem
^
you ask we give
well i’m not going learn code (which can take a while) just for a bot, like i get ur point but i don’t have the time or money, i’m literally coding my bot on replit 😭
Well they aren't rude, they just need to explain it a bit better.. What okimii was probably trying to say is that most of us here don't want to code a lot for other people. Yes we like helping and solving problems but not make the whole bot for you. Or specific commands.
also i have school and etc
no no
just gonna give up because you don’t want to learn before doing a project? There are tons of other shit you can do with Python
If you don't want to learn code and are just here to ask for coders you are in the wrong server.
"=" means assigned to "==" means equal to
^
more clear
yeah i’m not here just to ask for coders i do want to learn code at some point, i come here for help every once in a while but i try figuring things out myself
or literal to, its ok
just not to cause confusion
well, ur not wrong





