#discord-bots
1 messages · Page 1112 of 1
when the user registers
it gives them an inv attribute with all the items and amount set to 0
and it would madly error if I add a new item to the shop and their inventory does not have such an item
Pass in guild?
or if I remove an item, my bot wouldn't recognize the item id
so I need a solution to update the user's inventory
the issue is when and how
ic
i don't see any other alternative than syncing the adding/removing item command and users inv attribute
another way could be to let the item remain on removing but items use is deprecated and will no longer have any function
@shrewd apex what is pass the guild?
Global command?
This seems like more of an issue with the actual database provider/database engine than your codebase
i saw the docs u have to do guild_id = None for global
and for limited guild_id = [guild Ids]
yeah but when would I do this
after they execute a command?
yeah you can do that
there's an on_command event which gets triggered everytime someone uses a command
you can utilise that.
essex
mhm do as sarth says
I'll need to build a really optimized function to do this
I don't want to send request to db every command
hmm
in that case you messed up as soon as chose to use a database that doesn't sync itself automatically
anyways, cache is your deal
cache all the stuff you want, and then push it to the database at regular intervals using tasks.loop, and then clear the task again
memory be like 5 gb
tf, what are you even storing
man uses redis to store all users and data, instantly regrets it
@client.command(aliases = ["lb"])
async def leaderboard(ctx,x = 1):
users = await get_bank_data()
leader_board = {}
total = []
for user in users:
name = int(user)
total_amount = users[user]["wallet"] + users[user]["bank"]
leader_board[total_amount] = name
total.append(total_amount)
total = sorted(total,reverse=True)
em = discord.Embed(title = f"Top {x} Richest People" , description = "This is decided on the basis of raw money in the bank and wallet",color = discord.Color(0xfa43ee))
index = 1
for amt in total:
id_ = leader_board[amt]
member = client.get_user(id_)
name = member.name
em.add_field(name = f"{index}. {name}" , value = f"{amt}", inline = False)
if index == x:
break
else:
index += 1
await ctx.send(embed = em)
``` this only sends 1 user who is the richest in the guild, i want this to send every users balance above 15k
Guys how can we make a running status in dpy in bot status like it's on screen lines run from left to right
Hmm I searched fir it but not got
guys i have question its not specifically related to discord bots but well
is doing something like this against discord tos or smth? i wanted to confirm before i do it lol i saw it on a yt video
nope
it's just grabbing all messages in channel
youre just making a simple request to the api and parsing the payload lol
ur talkin about something like this:
Hello world
dHello worl
ldHello wor
rldHello wo
orldHello w
WorldHello
WorldHello
o WorldHell
lo WorldHel
llo WorldHe
ello WorldH
Hello World
but if the token is a user not a bot, then that's against ToS
seems like bad code but you do you
requests is sync...
did you just typed at?
yes lmao
💀
dedication
ikr
u got it
basically there is a channel and a pokemon based bot sends messages in the channel like this thing got sold for this much(in an auction) so i want to retrieve it
that's selfbotting
poketwo💀
idk what that is lol but is it legal
no
yes 💀
where's pokethree
yea i dont think they care
f is there some other way to retrieve the messages
a bot
it's unlikely to get banned
their question was "is this against ToS"
keep notifications on ig 💀
make a bot which pings you on those messages maybe
poketwo won't allow other bots in their server
why
wait they are doing it in the official server lmao?
asyncio/events.py:80: RuntimeWarning: coroutine 'select_subject' was never awaited
self._context.run(self._callback, *self._args)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
guys I'm getting this error I don't even know why 😭
(I made sure I write await select_subect())
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
lmfao what did u think
you need to await that mate
no one's helping me i was just confirming if its legal or not , i deleted the script 😭
It isn't bro
we'll forget about that
its not
no way to help mate self botting is illegal
@app_commands.command(
name = "lol",
description = "hey",
guild_id=None
)
async def hello(ctx):
await ctx.send(f'Bot speed -{round(client.latency * 1000)}ms')
for a private server or something
it is not legal, negatory, not, nuh-uh, null, undefined, None
Correct?
I did 😭
send code
yep
can i see the codd
nope
Yes
write it yourself my guy, nobody is going to spoonfeed you code
discord.py 2.0a slash command info and examples. GitHub Gist: instantly share code, notes, and snippets.

No problem
just use disnake or pycord or whatever
anything but not pycord
Idk how to make it Ig its complicated
seen too many people here that ask for code
set a tasks.loop every 1s, but that'd probably get your bot ratelimited
Just give me a hint
if your status is long enough the discord client automatically marquees it on mobile clients afaik
wow really
iirc changing the bots presence is 2/120s
it has to be atleast 16fps👀
bro
I also saw it on many bots
yes
well try some long status and see
apparently its working for me
lol why?
im confused on what the person wants if its a huge status or changing a status many times like a neon sign that rotates
pycords source code isnt type safe or good lol
seen it and its something else
@alpine cove :white_check_mark: Your eval job has completed with return code 0.
001 | Hello world
002 | dello worlH
003 | Hello world
004 | dello worlH
005 | Hello world
006 | dello worlH
007 | Hello world
008 | dello worlH
009 | Hello world
010 | dello worlH
011 | Hello world
please do so
pls no
@slate swan, Asher you won't believe what happened XD
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
!e
string = 'Hello World'
lst = [string[i:] +string[:i] for i in range(len(string))]
for i in lst: print(i)
@shrewd apex :white_check_mark: Your eval job has completed with return code 0.
001 | Hello World
002 | ello WorldH
003 | llo WorldHe
004 | lo WorldHel
005 | o WorldHell
006 | WorldHello
007 | WorldHello
008 | orldHello W
009 | rldHello Wo
010 | ldHello Wor
011 | dHello Worl
oh yea lol
- overriding discord namespace? who tf asked for it?
- messing with paths:
- discord.Bot ( why tf does that exist) is a subclass of discord.Client
- and then they re-subclass commands.Bot from discord.Bot, ew.
- Bad typing, literally worse than discord.py
- the pip command installs 1.7.3 by default ( why? )
- bad code, the only part that is considerable is either from Danny, or swas.py and some code which was stealed from discord.py pull requests ( yes, im talking about the voice recieve feature)
https://paste.pythondiscord.com/lucisoyumo
add_rep = [
rq.get_alts(subject),
rq.get_reason(subject),
rq.get_proofs(subject)
]
I replaced this part, with this one:
add_rep = [
rq.get_alts,
rq.get_reason,
rq.get_proofs
]
these have nothing to do with async lmao
The error that should have show up didn't, and those that didn't have to show up did
I don't even get who this happened XD
if you put that in a while true it makes a gif of an animated Hello world lmao
string = 'Hello World'
lst = [string[i:] +string[:i] for i in range(len(string))]
while True:
for i in lst:
sys.stdout.write(f'\r{i}')
time.sleep(.1)
it would be cool if you added \r
indeed XD
bruh this game me so much ideas XD
I'll make a little super mario infinite walk XD
use whatever you want
whoever insists you use whatever language they like, most likely skid
if you're insisting someone to use a language, be ready to guide them lol
"just use Google" is really invalid, especially with discord bots
be a chad
and use rust
🚀
that's the whole point lmao
openai is pretty funny sometimes
rb.rs.py.cpp.html.c.php.go.cs.js 🗿
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
Im deeply sorry about this situation. i hope you find a place in your heart to forgive me and my ignorance.
ah crap, not this again
💀
Okami
nova
💀

def clear_alts():
con = sqlite3.connect(os.path.join(BASE_DIR, "salus.sqlite"))
cur = con.cursor()
update ='UPDATE scammers SET alts = NULL'
cur.execute(update)
con.commit()
cur.close()
con.close()
return True
In this code, is cur.execute(update) correct?
it is correct but cur.close aint a thing
use aiosqlite man, just need to await at some points
or work with the same istance of the connection
lmao
yeah that too
eh it's alright, dw
and use aiosqlite with a single connection to the file
which verson of discord.py support threads making via bots?
which library?
2.0 or above
3.8 or above
alr tysmm
what do you mean by a single connxion?
Wym
Discord.py disnake nextcord hikari or what
like you are connecting to the file whenever the function is run
and use aiosqlite, sqlite will block your bot
By block meaning slow down
alright ! thanks for this info... but I still don't get what I should do with the connexion.
in main.py in the very top, I should connect one you mean?
I see
I mean, are you on 2.0 ?
You don't know python? 🙃
no i don't, i copy paste from stackoverflow
yeah not everybody has a brain ^^
wha-
idk their question was intented to mock so i gave a random answer XD
bot = commands.Bot(command_prefix = '!', intents = discord.Intents.mock())
So yh you're not subclassing
yeah there are no classes in Pascal language
So if you use sqlite3, its not asynchronous and your bot will have to wait if two commands related to dB are used simultaneously. So the bot will complete one command then second command
oh aight thanks
Using aiosqlite this won't be a problem
yeah I knew about that but I drowned into coding other functionnalities and forgot to transfer to aiosqlite. but i'll do thanks for the explaination :D
class Bot(commands.Bot):
def __init__(self):
super().__init__(command_prefix="!", intents=...)
async def setup_hook(self):
self.con = await aiosqlite.connect(...)
self.cur = await self.con.cursor()
#do more stuff if you want
bot = Bot()
@bot.command()
async def uwu(ctx):
await bot.cur.execute(...)
await bot.con.commit()
#dont close the connection
use cm 😔
contextmanager
I don't do these fancy class things, can't I just do
import discord
import aiosqlite
con = sqlite3.connect(os.path.join(BASE_DIR, "db.sqlite"))
cur = con.cursor()
and that's it?
there is nothing fancy about it, writing a command is harder than that
THAT IS BLOCKING
oh yeah um... ok i assume i should read some documentation and come back
apologies
I just gave an example.....
😭
eh, why lol, it's fine
but i don't use code that i don't understand
my bot is working fine right now so, i'll just recode the sql functions into aiosqlite and that's it
after the bot is online and people use it, i'll reshape it into a better version using classes and opitmization
well, creating the class Bot is just the same as bot = commands.Bot(...) but subclassing commands.Bot provides more functionality as you can see that you can create a setup_hook function that is always run before the INDENTITY payload is sent to the discord api and is triggered automatically....
if you want you can use this repo: https://github.com/Tvrsier/BaseBot
Base bot setup for discord.py and relative forks. Contribute to Tvrsier/BaseBot development by creating an account on GitHub.
ugh i don't understand all of what u say yet, i'm new to discord.py and also i never used classes before so yeah
i'll take a look at it, thank you !
yeah i assume it is
for now i just need the bot to be online asap, and then i'll improve it and learn through that
well, your wish
yeah, there's thousands of people waiting for it, + putting it online would give me a break from 10 days of 24/7 coding, and a taste of achievement
because I feel that if I keep struggling a few more days, i'll just give up, like I always did when I try to be perfectionnist
which is why I ended up not knowing python classes... 😊
sometimes you gotta aim a bit lower and reward yourself with some achievement
damn, deep
the code looks very questionable
half the things are unnecessary for any normal user
why subclass the Bot class?
just overwrite the method
how...?
oh wait nvm
:))
bot.setup_hook = func?
yes
no
why not? ._.
sub-classing looks better tbh meh
and you can get type hints
i cant argue with that but it wasnt really my point
what is this rust🗿
sorry god
For some reason this button looks really shady
lib/cogs/test.py line 1
from disnake.ext.commands import *```
nice
okay sire
dont call me that either
call me oki or okimii :))
can I call you mine
yes
lmao, what do people in the dpy server and this server have with songs smh
the repo has ClassNaming/UpperWord and in a folder its names __init__.py and it doesnt even initate the folder😔
fr
it is called PascalCase
in pep8 its referenced as UpperWord and CamelCase
wtf
!pep 8
camelCase is this one
PascalCase is this one
¯_(ツ)_/¯
nope
CamelCase != camelCase
wtf
people just call them differently
but in pep8 its referenced as so, i dont make the rules
¯\_(ツ)_/¯
what's this then wtf
check function or class naming
I'm confused now
Python Enhancement Proposals (PEPs)
¯\_(ツ)_/¯
let's get this straight
pascal case - MyObject
camel case - myObject
snake case - my_object
camel case has 2 instances 1 hump aka camelCase and 2 hump aka CamelCase
sad kebab case 😔
then what is pascal case
no the latter is pascal case
my🥙object🥙in🥙kebab🥙case
sounds like what a man with a white van would say
whos okimmi?
never referred to you
you are okimii not okimmi
but maybe ¯_(ツ)_/¯
wow, hello then _ _ , interesting name
🗿
since you don't exist
yeah yeah
.topic
Suggest more topics here!
ping command bro, almost no bot has that
buttons > reactions
okay but maybe devs are just lazy to switch to buttons
someone submit more questions 😩
welp
buttons are better looking and have lower ratelimits over 2/1s😔
well yeah since every single reaction takes an api request
thats the ratelimit idk i forgot
plus buttons can have emojis😔
reactions are emojis 😔
that wasnt my point but ok🗿
lmao
.topic
Suggest more topics here!
modals
with React?
react
yes you heard that right
i'm predicting you're gonna mention Svelte or something similar
👀
web dashboard? for what?
for your bot
e.g mee6
create a REST API instead of a dashboard with UI
i mean, you can't make dashboard without API
i wanna try making a restful api with rust
RESTFUL API
and then wrap it in py
ew
js better
yeah I know, I usually make my APIs REST
in what sense?
Just cz I like JS, never tried rust
🗿
Rust is statically typed, fast, is compiled, memory safe and its syntax is lovely
sus
its syntax is lovely
sure
that name
How do I remove this space? (eaither title or field name)
Can't
just dont specify the title....?
Like how do I make it like this
!d discord.Embed
class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.
Changed in version 2.0: `Embed.Empty` has been removed in favour of `None`.
the title kwarg
It's not, it's just name
and why a field it looks like a description😭
fn main() {
println!("Hello World!");
}
imagine not using cpp at this point meh
Bruh?
its literally just an entry point function
just lemme know what to do please
should I remove a name and put invisible symbol and put it as title then
remove title
embed = discord.Embed() embed.add_field(...)
okay why the fuck is there an exclamation mark in that println
You can remove title?
yes?
So like this?
means its a macro call iirc
what is a macro.
try it maybe?
mmm
afaik its code that writes code aka meta programming
embed = discord.Embed(title='How do i become a staff Member?', description='You can apply.....',).set_thumbnail(url='https://media.discordapp.net/........................')
😔
OH
didn't know that-
its easier to read documentation over hard coding something
tysm
well uh- I can't find any documentation for some reason
čć
!d discord
!d discord.Embed
class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.
Changed in version 2.0: `Embed.Empty` has been removed in favour of `None`.
ty
I don't have both and turned out okish
im back after centuries
why??
__import__("time").sleep(86400 * 365)
theres no such key
That guild doesn't exists in your json.
oh
doesn't exist
goodbye for another year
😭
that's what u ask for 😂😂😂

python discord question: why does it keep responding to messages that isnt in message.content.lower? it doesnt respond to bots, just normal users?
async def on_member_join(member):
await client.get_channel(971319830064017458).send(f"Welcome {member.mention}, this is our proofs channel!", delete_after=30)
#chat bot
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.author.bot: return
if 'hello' in message.content.lower():
await message.channel.send(random.choice(greetings))
time.sleep(1)
await message.channel.send(random.choice(cq))```
"why does it keep responding to messages that isnt in message.content" what do you mean?
i have e defined as e = client.get_channel(. . .)
This responds when there is a character combination of that with "hello"
channel could not be in cache.
@client.command()
async def suggest(ctx,*,suggestion):
await set_sug(ctx.guild,ctx)
guilds = await get_sug()
chn = guilds[str(ctx.guild.id)]["channel"]
e = client.get_channel(chn)
e1 = discord.Embed(title=f"Suggestion from {ctx.author.name}", description=suggestion, color=discord.Colour.og_blurple())
e1.set_author(name=ctx.guild.name)
async with ctx.typing():
r = await e.send(embed=e1)
r.add_reaction(":arrow_up:")
r.add_reaction(":arrow_down:")
I recommend defining e as ```py
e = client.get_channel(...) or await client.fetch_channel(...)
What is chn?
i dont want my bot to respond when someone's message doesnt contain the word "hello"
if message.author.bot: return
That's why
Defined above it
Is it an id?
Yah
then inverse the condition.
!d not
6.11. Boolean operations¶
or_test ::= and_test | or_test "or" and_test
and_test ::= not_test | and_test "and" not_test
not_test ::= comparison | "not" not_test
``` In the context of Boolean operations, and also when expressions are used by control flow statements, the following values are interpreted as false: `False`, `None`, numeric zero of all types, and empty strings and containers (including strings, tuples, lists, dictionaries, sets and frozensets). All other values are interpreted as true. User-defined objects can customize their truth value by providing a `__bool__()` method.
The operator [`not`](https://docs.python.org/3/reference/expressions.html#not) yields `True` if its argument is false, `False` otherwise.
That line makes the code under it unreachable if the user that sent the message is a bot
That line makes the code under it unreachable if the user that sent the message is a bot
Pandabweer#7576
bro if i remove it, it will respond to bots
I suggest using my posted code.
Use an id?
At the ellipsis yes.
Ik, but you asked why it doesn't respond to bots
I mean I have it custom per guild
Is it not possible to do something like that?
no thats not what i meant, what i asked is i dont want it respond to bots or users, when it doesnt contain the word "hello"
It was a bit confusing but he/she asked if the message.content does not contain "hello" send a response.
Just place the variable there.
I did
.
Have you tried it?
That's not what I suggested.
I suggested to use this ```py
e = client.get_channel(...) or await client.fetch_channel(...)
mhm
how?
!d not
6.11. Boolean operations¶
or_test ::= and_test | or_test "or" and_test
and_test ::= not_test | and_test "and" not_test
not_test ::= comparison | "not" not_test
``` In the context of Boolean operations, and also when expressions are used by control flow statements, the following values are interpreted as false: `False`, `None`, numeric zero of all types, and empty strings and containers (including strings, tuples, lists, dictionaries, sets and frozensets). All other values are interpreted as true. User-defined objects can customize their truth value by providing a `__bool__()` method.
The operator [`not`](https://docs.python.org/3/reference/expressions.html#not) yields `True` if its argument is false, `False` otherwise.
Suggestions are welcome lmao
@discord.ui.button( emoji = f"{e_checkMark}", style=discord.ButtonStyle.green, row=1)
async def iron_yes(self, interaction: discord.Interaction, button: discord.ui.Button):
embed = discord.Embed(
description= "Проверяем вас на судимость наличие должности в другой компании..",
color= 0x00b300
)
img = Image.open("./ImageO/Экономика/Work/Договор_Железо.png")
url = str(interaction.user.display_avatar)
url1 = requests.get(url, stream = True)
url1 = Image.open(io.BytesIO(url1.content))
url1 = url1.convert('RGBA')
url1 = url1.resize((154, 147), Image.ANTIALIAS)
img.paste(url1, (165, 155))
img.save("./ImageS/Договор.png")
file4 = discord.File("C:/bot py/ImageS/Договор.png", filename="D.png")
embed.set_image(url= 'attachment://D.png')
embed_dict = embed.to_dict()
embed= discord.Embed.from_dict(embed_dict)
await interaction.edit_original_message(attachments = [file4], embed= None)
os.remove("./ImageS/Договор.png")
Dear tell me why he does not delete the picture?
can u explain this?
!e ```py
if not True:
print("almost true")
if not False:
print("My time to shine")
@cloud dawn :white_check_mark: Your eval job has completed with return code 0.
My time to shine
guys my bot has to get images from links and attachments and save their links in database. however since it's linked to a ticket system the channel get delete after command use and images disappear. what do u guys suggest?
maybe actually save the image and store filepaths in database
Did the application got launched in administrator mode?
I don't have enough space on my cloud :(
for the amount of images I will have to store
okie thxs
I suggest trying that.
either the path is wrong
try: C:/bot py/ImageS/Договор.png
but how does this fix the issue? and where to use it?
How can i use this?
cursed-
search on youtube
what lib?
is not a coroutine so i can't use await 🤔
then don't use await
¯_(ツ)_/¯
then the command doesn't exist...?
also, guild_ids should have integers, not strings
that's why it aint working most probably
yeah but it's guild_ids... you have to use it as a list
well im trying to get the command in the guild where it's registered
list with integers
i can assure u that without guild ids is still going to be none
lemme try actually
yep still none
hard luck
...
Me when you where typing that ```py
@property
def latency(self) -> float:
return round(super().latency * 1000, 2)
I cant say anything about that, doesn't look bad, just overwriting the method
¯_(ツ)_/¯
damn
lmao what
I thought I was doing something illegal
lmao
hey guys i was using a website for coding discord bot but rn im coding with pycharm and i cant import discord
help
I'm weirder, I was trying dpy 2 and....
class Bot(commands.Bot):
#super shit
async def setup(self):
#load cogs
await bot.start(token)
def launch(self):
asyncio.run(setup())
bot = Bot()
bot.launch()
I did that before too the context stuff just looks ugly lol
hey guys i was using a website for coding discord bot but rn im coding with pycharm and i cant import discord
help
import asyncio
from client import Dispy
from constants import config
client = Dispy()
async def main() -> None:
async with client:
await client.start(config.bot.token)
if __name__ == "__main__":
asyncio.run(main())
``` I ended up with this.
Once is enough, I never miss any messages, anyhow, error?
no i just type import discord and it says discord not found......
Have you installed it?
thats actually not bad
that's like the recommended method too to do that
it isnt?
offfffffffffff
Where?
wym where
you have to install discord.py smh
no, i kinda like that. imma borrow it 👀
lmao
Any method is good ig, when using run you get thrown inside a context anyways but run is a bit more ugly in the library I think danny want to deprecate it.
uwu
it's not deprecated, they just added an update to it with auto-logging
lmfao
I didn't mean the project location. Pycharm is based on the usage of envs so did you install dpy inside Pycharm or cmd?
In pycharm go to python packages and then search for discord.py
I told you they installed the client not dpy :)
smh
!pip discord.py
0 is good
0 is False 😔
'
wym
lmao
So i want to make a slash command in which a user can send an image/gif through it instead of a message.....any idea hows that possible ?
lib?
dpy?
thanks its ok now
can i set 2 prefixes for a bot?
Yes.
hi all, if possible how can i get previous messages on a channel via discord.py?
how?
async def uwu(inter: discord.Interaction, image: discord.Attachment):
...
should work
pass in a list/tuple to the prefix
async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") that enables receiving the destination’s message history.
You must have [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.
Examples
Usage...
oh
bot = commands.Bot(command_prefix="+", "~") ??
bot = commands.Bot(command_prefix=("!", ".", "uwu"))
thanks <3
LIST/TUPLE
me: {"!", "."}
@cog_ext.cog_slash(name="uwu", guild_ids=[933980948268208130])
async def uwu(inter: discord.Interaction, image: discord.Attachments):
await ctx.send (image)
return
``` ?
its not, its some 3rd party lib
for slash ^
@shell wing type show discord.py in ur terminal and show result
ew
ya dont use that, use dpy 2.0 it has slash commands
it says bash show discord.py not found 💀
😔
Never had any issues.
pip show mb, anyways, uninstall that lib and upgrade to 2.0
it's easy, I can say that after using hikari-lightbulb
Ahsley tryna lure people to hikari
nah, it's not for beginners so uhh
uninstalll all these libs
^
ehhhh
yes
alr ? ig
just run pip uninstall lib1 lib2 lib3 lib4 lib5 replace the name of the libraries with lib#
I'm still only syncing guild-only, I'm planning on making a custom sync solution, I've already got a custom solutions for Group "cogs".
ashley
skill
why u keep using uwu as examples
because im too uwu
😳
panda comes with his high end crap (crap for me cz I dont understand a thing) for loading extensions
removing libs is soo much work 🥱
pip uninstall
why does a function work when i call it in the code but if it is called through a command it no work???
wdym?
it seems to stop when i try to os.listdir()
os.listdir() returns a value, it does not print it
like if I use function() in the code it works
but if I run function() as part of a command for the bot
it doenst work
def delete_old_data():
print('requested old data delete')
files = list(os.listdir('../cogs/hystats-data/'))
print(files)
print('created list of files')
for file in files:
x = os.stat('../cogs/hystats-data/'+file)
age = (time.time() - x.st_mtime)
print('found age of all files')
if int(age) >= 1:
os.remove('../cogs/hystats-data/'+file)
print(f'deleted {file}')
else:
print(f'kept {file}')
pass
print('deleted data')
return True``` works when I just run this code but not when the bot tries to run it
I always get ignored fml
HEY guys how i can run bot with token
which ver of dpy?
just pass in the token to the run method...... (or start as required)
:::?//
bot.run('TOKEN')
^
thanks
what about me
os.listdir is already a list there isnt any need to typecast it with a list
are there any errors?
it says : Process finished with exit code 0
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
nono im using ur method onlyy
no
I see
thats a cog
that's not for you
uh lol
show code
so ig no one helps me
its in the pastebin link
show code.
i deleted all of them !!!!!
must be satisfying
import asyncio
import random
from discord.ext import commands
bot = commands.Bot(command_prefix=("+", "~", "!"))
bot.remove_command("help")
@bot.event
async def on_ready():
await bot.change_presence(status=discord.Status.online, activity=discord.Game(name=" +help, ~help, !help "))
bot.run("amogus")```
oh
you are running it inside the on_ready function and you have to pass in a valid token
also yo can just do help_command=None while definig bot
I think they dont want to leak their token lol
these exist too
god no
oh okay cool
import asyncio
import random
from discord.ext import commands
bot = commands.Bot(command_prefix=("+", "~", "!"))
bot.remove_command("help")
@bot.event
async def on_ready():
await bot.change_presence(status=discord.Status.online, activity=discord.Game(name=" +help, ~help, !help "))
bot.run('idk')```
??????
refer to this now -> #discord-bots message
OUTSIDE of the function
see
nice
alrr
helppp
import discord
import asyncio
import random
from discord.ext import commands
bot = commands.Bot(command_prefix=("+", "~", "!"))
bot.remove_command("help")
@bot.event
async def on_ready():
await bot.change_presence(status=discord.Status.online,activity=discord.Game(name="+help,~help,!help "))
bot.run('idk')```
run the bot
try dummy prints inside the delete_old_data function and see where it stops working
when i run it bot dosent start
why remove help command 😭
it stops just before os.listdir
sorry, didn't see it
remove the spaces before bot.run line
yes
"removing the spaces" called un-indenting
oh yeah sorry, I'm blinded
why keep it
default help cmd ugly ugly
it workeddddddddddd
because it's better
no
to subclass HelpCommand
its ugly
subclass it
thanks guys
also a valid option
dont tell me you guys hardcode your help commands...
we totally don't iterate over the commands property
YESIDOANIMSODUMB
ayyyy same pinch
All the time it allows for fine tuning.
My bot is 1000 lines :p
My bot has 31 lines but is a total brainfuck lmao
fill in the blanks
why would u do this
no
cz why not
unnecessary
I was thinking of doing something like this as well lol.
you guys can contribute though - https://github.com/Ash-02014/_
how many features u have
lmao
hey you forgot to gitignore pycache
and also rename ur commits to just an underscore
laziness creeps inside of me lmao
too much work
And you still load it that awful way lol
i see
1 help command for my help command.
well why not
1000 lines for a help command
interesting
I feel like I'm being judged.
whenever I subclass HelpCommand my code is filled with list comprehensions
and now it's too idiomatic it looks like absolute shit
it isn't even idiomatic it's idiotic
now make a command
what if u wanted to redesign the help command
u would have to take down the bot
and then upload ur new work
I do have a command in an extension
oh i see
oh my
I know it looks ugly but who cares, I rewrote the bot so uhh
did u do it on purpose
nah, I was just a beginner back then
3 months
yeah...
good improvement i approve
I uhh
discord bots ain't hard, just learn to read the docs and stop writing crappy code ¯_(ツ)_/¯
not about discord bots about the quality of ur code
guys why its not working ?
async def help(self, ctx: commands.Context):
embed = discord.Embed(title="Help Menu:", description="** **", color=0x79ff00)
embed.add_field(name="Meme", value="Bot Will Send A Funny Meme.\nUsage: !meme, +meme, ~meme", inline=false)
await ctx.reply(embed=embed)```
whats the error? or no error?
hm, I see
but for loops.....ew ew
Traceback (most recent call last):
File "D:\Rolex project\venv\lib\site-packages\discord\ext\commands\bot.py", line 606, in _load_from_module_spec
spec.loader.exec_module(lib)
File "<frozen importlib._bootstrap_external>", line 879, in exec_module
File "<frozen importlib._bootstrap_external>", line 1017, in get_code
File "<frozen importlib._bootstrap_external>", line 947, in source_to_code
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "D:\Rolex project\venv\commands.py", line 49
def setup(bot: commands.Bot):
^
IndentationError: unindent does not match any outer indentation level
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\Rolex project\main.py", line 14, in <module>
bot.load_extension("commands")
File "D:\Rolex project\venv\lib\site-packages\discord\ext\commands\bot.py", line 678, in load_extension
self._load_from_module_spec(spec, name)
File "D:\Rolex project\venv\lib\site-packages\discord\ext\commands\bot.py", line 609, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'commands' raised an error: IndentationError: unindent does not match any outer indentation level (commands.py, line 49)
Process finished with exit code 1
!indents
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
😔
😐
sorry Panda
helppp
@warm tulip
You are using Pycharm... I think your linter is having a stroke rn.
github copilot do be doing everything for me right now
~~ bot sends a funny meme omg~~
ew copilot
xd
how do i change my bot's status from online to idle or something?
!d discord.Status.idle pass in this to your bot constructor
The member is idle.
await change_presence(*, activity=None, status=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Changes the client’s presence.
Example
```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
``` Changed in version 2.0: Removed the `afk` keyword-only parameter...
ty
await message.channel.send('leaving..')
await message.channel.send('left')
await message.channel.send('rejoin? type yes or no')
if message.content == 'no':
await message.channel.send('you picked no')
elif message.content == 'yes':
await message.channel.send('you picked yes')
else:
await message.channel.send('you didnt pick anything')```
how do i make this: wait for the users response instead instantly going to else and saying that it didnt pick anything
bot = commands.Bot(..., status=discord.Status.idle) #discord.Status.online, discord.Status.dnd, discord.Status.offline #or just use what uwu sarthak said
basicaly how do i make this wait for the user to response
!d discord.Client.wait_for
wait_for(event, /, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.10)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.10)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.10)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
will this work for like.. users cuz this aint a discord bot
like this thing
^
banned moment
IT IS?
yes
.. oh crap
yeah
dw just dont do it
!d aiohttp.ClientWebSocketResponse.send_str
coroutine send_str(data, compress=None)```
Send *data* to peer as [`TEXT`](https://aiohttp.readthedocs.io/en/stable/websocket_utilities.html#aiohttp.WSMsgType.TEXT "aiohttp.WSMsgType.TEXT") message.
whats that
that's an example.
it will just show Playing with the API as the activity/status of the bot
wherever you're setting it
ohh
I'm trying to send a raw post the the API.
oh
is there anyway to connect a file into another file?
#bot-commands for self serving searches
!d import
7.11. The import statement¶
import_stmt ::= "import" module ["as" identifier] ("," module ["as" identifier])*
| "from" relative_module "import" identifier ["as" identifier]
("," identifier ["as" identifier])*
| "from" relative_module "import" "(" identifier ["as" identifier]
("," identifier ["as" identifier])* [","] ")"
| "from" relative_module "import" "*"
module ::= (identifier ".")* identifier
relative_module ::= "."* module | "."+
```...
like appending bytes of one file to another?
how do i pass args when loading a cog
yes
i want to pass a object
bot_ins.add_cog(bot_ins)
sorry im just new here
Hey, i have problem with message.content.
try:
print(f"Message: {message.content} ") ```
wait, but why
no wait, you can
you probably don't have message content intent
wdym
do you know what intents are
class Cog(commands.Cog):
def __init__(self, bot: commands.bot, arg1, arg2):
...
#while loading
bot.add_cog(Cog(bot, "uwu_arg_one", "uwu_arg_two"))
#level.py
class Level(commands.Cog):
def __init__(self, client, console):
self.client = client
self.console = console
#bot.py
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
_console.print(f"Loading extension: {filename[:-3]}", 1)
# i want to pass _console as a arg
client.load_extension(f"cogs.{filename[:-3]}")
ah i see
you'll have to manually load the cog in that case
just make console an attribute of the bot.
OH TRUE
it can read my messages but cant read other messages
how do i give a time using
type=discord.ActivityType.playing ?
my bad wrong channel
no discord updates it itself
ohh
bra i cant find dat shit in da docs how do i do it
it's not updating :(
!e ```py
class Bot: ...
bot = Bot()
bot.console = "your console"
how access it : bot.console
print(bot.console)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
your console
dat didnt work my brother
bot's playing activities don't get updated
_console = Console()
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix = ',', intents=intents)
# create a new attribute for the bot called console
client.console = _console
yeah and what did you do after that?
is there a way i could?
create a task
I guess you're asking for change_presence in a task
don't think so, never see a bot having such activity.
its a rich presence, not supported by bots
how?
@task.loop(seconds=60)
async def my_task():
...
my_task.start()
so do i change from @bot.event to @task.loop(seconds=60)?
and put the my_task.start thing
from discord.ext import tasks
bot = ...
bot.activity_up = 1
@tasks.loop(minutes=1)
async def add_time():
await bot.wait_until_ready()
bot.activity_up += 1
await bot.change_presence(activity=discord.Game(f"Valorant | Elapsed: {bot.activity_up}"))
add_time.start()
bot.run("token")
hey i have a problem
ask
async def on_ready():
Channel = bot.get_channel(988526792602177636)
Text= "Wie alt bist du(13-15)[Reagiere auf die nachricht]"
Moji = await Channel.send(Text)
await Moji.add_reaction('👶')
@bot.event
async def on_reaction_add(reaction, user,message):
Channel = bot.get_channel(988526792602177636)
if reaction.message.channel.id != Channel.id:
return
if reaction.emoji == "👶":
Role = nextcord.utils.get(user.server.roles, name="988529250493661184")
await user.add_roles(Role)
else:
await bot.process_commands(message)``` why isnt this working?
reaction add?
yes?
yeah, that'll work like that, you can't have rich presence and sarth told
sadge
reaction add takes only 2 para
oh okay thanks
just reaction and user
@bot.event
async def on_reaction_add(reaction, user):
Role = bot.get_role(988529250493661184) or await bot.get_role(988529250493661184)
if reaction.message.channel.id != 988526792602177636: return
if str(reaction.emoji) == "👶": await user.add_role(Role)
else: await bot.process_commands(message)
thank you!!!
it still isnt working kinda
idk
what's not working?
does somebody know how to get every arg after a certain arg discord.py
it doesnt give an role. the first bot.event is working
user.add_role()
oh ok
wym?
@bot.event
async def on_reaction_add(reaction, user,message):
Role = nextcord.utils.get(user.add.roles, id=988529250493661184)
if reaction.message.channel.id != 988526792602177636: return
if str(reaction.emoji) == "👶": await user.add_roles(Role)
else:
await bot.process_commands(message)```like this?
i edited my answer check that
you're looking for consume rest, add an asterisk before the 2nd argument
I want to like get the sentence after these args and if I add space it moves to another arg I want how many spaces I add it will read all args after a certain arg
yes
idk
oh ok
async def(arg1, *, arg2): #this will make all subsequent arguments after arg1 a string arg2
async def(*arg1): #returns a tuple of all ur args
ok
but how can I access the variable its just a *
so like I would I access it:
arg1+arg2
and will it return all the args between it
y don't u print and see👀
you might want to give him an example too
ok
emm it pretty simple it would be a better learning experience to print and get on his own
it's just a string and a tuple💀
async def shit(ctx, first_arg, *, second_arg)
#...
!shit pants every single day
first_arg = "pants"
second_arg = "every single day"```
vs
```py
async def shit(ctx, first_arg, *second_arg)
#...
!shit pants every single day
first_arg = "pants"
second_arg = ("every","single", "day",)```
=> more info about this: `consume rest operator`
so much dedication👍
Slash commands be like int value should be less than or equal to 9007199254740991.
Why are the using safe integer 😐
javascript is irritating and thus the client can only handle integers up to 2^53
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
was just the file name but understandable
ik
Its not just a file name, its a well known package on github
And as such, we won't provide help on it
alright then
also sorry for ping but do you guys see as synapse x as a roblox hacking tool or a dev tool @velvet compass
aka am i aloud to ask help about it here
Looks like it is a package specifically designed to exploit Roblox. I'd say it falls under rule 5 as well
alright then good to know thank you
why isnt this working?py @bot.event async def on_reaction_add(reaction, user,message): Role = bot.get_role(988529250493661184) or await bot.get_role(988529250493661184) if reaction.message.channel.id != 988526792602177636: return if str(reaction.emoji) == "👶": await user.add_role(Role) else: await bot.process_commands(message) error TypeError: on_reaction_add() missing 1 required positional argument: 'message'
description="Answers a yes/no question.",
brief="Answers from the beyond.",
aliases=['eight_ball', 'eightball', '8-ball'],
pass_context=True)
async def eight_ball(context):
possible_responses = [
'That is a resounding no',
'It is not looking likely',
'Too hard to tell',
'It is quite possible',
'Definitely',
'Maybe so.'
]
await context.channel.send(random.choice(possible_responses) + ", " + context.message.author.mention)```
why its not working?
!d discord.on_reaction_add
discord.on_reaction_add(reaction, user)```
Called when a message has a reaction added to it. Similar to [`on_message_edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_message_edit "discord.on_message_edit"), if the message is not found in the internal message cache, then this event will not be called. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") instead.
Note
To get the [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Reaction.message "discord.Reaction.message").
This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
Note
This doesn’t require [`Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") within a guild context, but due to Discord not providing updated user information in a direct message it’s required for direct messages to receive this event. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") if you need this and do not otherwise want to enable the members intent.
Doesn't take a message.
i dont really understand?
helppp
oh okay
but what about myelse: await bot.process_commands(message)
@cloud dawn
You don't need to process the command here.
oh , only in the on message event?
Yep.
oh, thats good to know :) i didnt know that
Guys how can we display the servers count of bot in its status?
!d discord.ext.commands.Bot.guilds
property guilds```
The guilds that the connected client is a member of.
you can do py @bot.event async def on_ready(): await bot.change_presence(discord.Game(f"{len(bot.guilds)} servers")) iirc
Thank u
:)
on ready presence and not awaited, 
trolling smh
a task loops also needed
This isn't the appropriate channel for this please use @novel apex
async def on_reaction_add(reaction, user):
Role = bot.get_role(988529250493661184) or await bot.get_role(988529250493661184)
if reaction.message.channel.id != 988526792602177636: return
if str(reaction.emoji) == "👶": await user.add_role(Role)
```it still isnt working? pls help
no? It's not lol, it's just a single presence change
I wouldn’t recommend that
specify error
@robust fulcrum please don’t change presence in on ready
Could you fix this Robin -> #discord-bots message
there is no erorr?
why tho
I’ll file a report, thank you



