#discord-bots
1 messages ยท Page 291 of 1
other buttons works with followup tho
Show one
class CanvasButton(ui.Button):
async def callback(self, interaction: discord.Interaction):
await interaction.response.send_message(f"[Spotify Canvas]({canvasurl})")
wait no not this one
class PlayButton(ui.Button):
async def callback(self, interaction: discord.Interaction):
await interaction.response.defer(thinking=True)
songlink = f"https://open.spotify.com/track/{spotify_id}"
file_bytes = download(songlink)
custom_path = "./files/ogg/"
if not os.path.exists(custom_path):
os.makedirs(custom_path)
with open(f"{custom_path}{name}.ogg", "wb") as f:
f.write(file_bytes)
with open(f"{custom_path}{name}.ogg", "rb") as f:
await interaction.followup.send(f"`{name} by {artists}` | Quality: `VERY_HIGH`", file=File(f, filename=f"{name}.ogg"))
shutil.rmtree(custom_path)```
Defer is a response too
Just another thing, if songs_query is a function or anything, it's blocking
songs query is a function but it works fine, thank you
It might work fine but it's blocking so eventually it'll become a problem ๐คทโโ๏ธ
Just a matter of time
do i make it coroutine
You'd want it to be async, yes
def songs_query(query):
base_url = "https://api.music.apple.com/v1/catalog/us/search"
params = {'term': query, 'types': 'songs'}
response = requests.get(base_url, headers=HEADERS, params=params)
data = response.json()
return data['results']['songs']['data'][0]
this is the current function but idk how to do async
do i just add async or
Yes
and await right
You'd also need to use aiohttp or a similar library as requests is blocking
!d aiohttp
ooh i have to switch to aiohttp too
!d aiohttp.ClientSession.request
coroutine async-with request(method, url, *, params=None, data=None, json=None, cookies=None, headers=None, skip_auto_headers=None, auth=None, allow_redirects=True, ...)```
Performs an asynchronous HTTP request. Returns a response object.
is that the reason why I am getting those heartbeat errors while executing something
๐ญ thank you for the heads up
does anyone know why it wont send the embed? (get erroro on last line)
@bot.hybrid_command()
async def purge(ctx, messages: int):
if messages > 100:
return await ctx.send("You cannot delete more than 100 messages.")
else:
await ctx.channel.purge(limit=messages)
embed = discord.Embed(title="**Messages removed!**", color=0x2a7412)
embed.add_field(name="** **", value=f"{ctx.author.mention} successfully purged `{messages}` messages!", inline=False)
await ctx.send(embed=embed)
Just ran that code, I didn't get an error.
it has all perms
You maybe missing permissions to run that command
it just cant send the embed for some reason
na it does delete the messages
It worked when I tried it
tf
What error is it giving you?
Hybrid command raised an error: Command 'purge' raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction
just try @bot.command
na then it wont be a slash command anymore
In that code, it dosent make it a slash command
@bot.hybrid_command() is slash command......
do you have a slash command handler?
ye
hm, idk
but everything works fine
I need to figure out how to use the cog thing, so I can seperate my command files
I have all my commands in 1 file lnao
lmao*
same XD
it says: ERROR discord.ext.commands.bot Ignoring exception in command purge
Send the traceback
Was on the last line so ctx.send(embed=embed)
Send the traceback
Cant anymore its getting to late so i gtg
can anyone tell my a python bot tutorial
Could someone explain to me how to create a bot in discord.py with cogs and slash commands?
The slash one works fine too
@quartz rune
hi
import discord
from discord.ext import commands
# create a new instance of a bot with a command prefix.
bot = commands.Bot(command_prefix='!')
@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name} ({bot.user.id})')
# Replace 'YOUR_BOT_TOKEN' with your actual bot token.
bot.run('dddddddddd')
```py
ignore the ddddddd
hey vitness could i ask ua question
sure
!intents
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.
There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.
Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.
i do not understand why its giving me erros
You are copying from some old guides
https://github.com/Rapptz/discord.py the official guthub repo with examples
https://discordpy.readthedocs.io/en/stable/ docs
https://github.com/Rapptz/discord.py#bot-example minimal bot example
intents is what you are missing in the code you gave
still getting an error
File "C:\Users\thisa\AppData\Roaming\Python\Python311\site-packages\discord\client.py", line 849, in runner
await self.start(token, reconnect=reconnect)
File "C:\Users\thisa\AppData\Roaming\Python\Python311\site-packages\discord\client.py", line 778, in start
await self.connect(reconnect=reconnect)
File "C:\Users\thisa\AppData\Roaming\Python\Python311\site-packages\discord\client.py", line 704, in connect
raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
PS C:\Users\thisa\OneDrive\Desktop\l>
Just do what it says ยฏ_(ใ)_/ยฏ
It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
show screenshot
No, screenshot of you enabling it
I guess "I did it" means that everything is running fine

oh
i mean i wanna
vc with someone because like i still need help smh
it was not anymore lol
Is it the same error?
its no error
i just cant add my bot to my server
cause i went to the oauth thing like i see in videos and its asking for a uri
Only select Bot
Disable "Require code grant" in your bot's settings
You can't just "explain" how to make discord bot
why it says this? All intent are correct and the token is correct too
Is it possible to create interaction and text command with a single function
Check hybrid_commands
What is that output from? Some library / copied code?
It is something that me and my friend work on in 2021
I don't know why it say that, it worked perfectly back then.
if bot:
headers = {
"Authorization":
f"Bot {token}"
}
else:
headers = {
"Authorization":
token
}
rex = commands.Bot(
command_prefix=prefix,
intents=discord.Intents.all(),
help_command=None
)
yes
what is this?
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 Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
the output is just print
But you are doing it after some condition or something i guess
is that for oauth
if __name__ == "__main__":
clear()
#print("\033[38;5;92m" + license)
#sleep(3)
clear()
print(f"\033[38;5;89m[\033[38;5;92m{ftime}\033[38;5;89m] \033[0mLoading client.")
try:
rex.run(
token,
bot=bot
)
except Exception:
print(f"\033[38;5;89m[\033[38;5;92m{ftime}\033[38;5;89m] \033[0mSpecified a wrong token or a bot token without all intents.")```
Remove the try-except and show the actual error
traceback.print_exc()
that looks bad
i do already
it is very slow replit
I know
"bot is not recognized"
i just remove that "bot=bot"
I keep getting this error when turning case_insensitive to true
return super().__contains__(k.casefold())
TypeError: unbound method str.casefold() needs an argument
but when it's false, it works just fine
full traceback?
File "C:\Users\Jade\PycharmProjects\CharmCords\CharmCord\Classes\Commands.py", line 16, in command
async def go(ctx, *args, Code=Code):
File "C:\Users\Jade\PycharmProjects\CharmCord\venv\lib\site-packages\discord\ext\commands\core.py", line 1521, in decorator
self.add_command(result)
File "C:\Users\Jade\PycharmProjects\CharmCord\venv\lib\site-packages\discord\ext\commands\bot.py", line 246, in add_command
super().add_command(command)
File "C:\Users\Jade\PycharmProjects\CharmCord\venv\lib\site-packages\discord\ext\commands\core.py", line 1360, in add_command
if alias in self.all_commands:
File "C:\Users\Jade\PycharmProjects\CharmCord\venv\lib\site-packages\discord\ext\commands\core.py", line 257, in __contains__
return super().__contains__(k.casefold())
TypeError: unbound method str.casefold() needs an argument
what is function go
It's a command
Also if it does delete like 11 messages?
can you show it
no argument
(The code inside isn't really relevant, it's for a custom package)
whats Name and whats Aliases
this is error return super().contains(k.casefold())
The async func is embedded within a regular function in which those parameters are provided
so what are the values of those
!e
str.casefold()
@naive briar :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | str.casefold()
004 | TypeError: unbound method str.casefold() needs an argument
Currently
Name: "Test"
Aliases: []
That's not how you define variables in Python
k is not define
I'm not the one using it tho, it's within the library itself
ik lol
If it's discord.py, I doubt if it will make this kind of mistake
it comes from discord.py so it must have been provided to it somehow from outside
return super().contains(str(k).casefold())
Hello, I know a little development but not the python language. lately I wanted to set up my own music bot that fetches music on youtube via !play link or title of the video by asking chatgpt to code it for me (not working). I wanted to know if anyone has published a code that works? Thanks in advance !
!ytdl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTubeโs robots.txt file; (b) with YouTubeโs prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
doesnt really matter what it is for
is this your own wrapper over discord.py?
Nope
Mhm, been working on it for awhile to make it easy for people without programming experience
It worked many times before
So I'm a bit confused now
lots of repeating code btw
Yea, Ik, I was refactoring before I ran into this error ๐
what discord.py version is that?
put return super().__contains__(str(k).casefold())
Did you change how it add commands?
k is a str type, so that's not very useful
!e
print(str(str))
@naive briar :white_check_mark: Your 3.11 eval job has completed with return code 0.
<class 'str'>
not running into that issue with this version
it is bug with his version
!paste @lethal drift how about more 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 Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
and casefold() is instance
str.casefold()```
Return a casefolded copy of the string. Casefolded strings may be used for caseless matching.
Casefolding is similar to lowercasing but more aggressive because it is intended to remove all case distinctions in a string. For example, the German lowercase letter `'ร'` is equivalent to `"ss"`. Since it is already lowercase, [`lower()`](https://docs.python.org/3/library/stdtypes.html#str.lower) would do nothing to `'ร'`; [`casefold()`](https://docs.python.org/3/library/stdtypes.html#str.casefold) converts it to `"ss"`.
The casefolding algorithm is described in section 3.13 of the Unicode Standard.
New in version 3.3.
you know what you are talking about?
i know it all he send me code
I didn't send you anythin-?
lol
Why you have all imports inside the functions :/
That looks even more confusing than discord.py ๐ตโ๐ซ
backend very much is-
tbh, I started that way when I first began the project and never actually changed it-
so I kinda drifted to other things in the project xD
isnt that caused by the fact you are giving default value to a list
which will cause errors further
!e ```py
def f(value=[]):
print(value)
value.append(1)
f()
f()
@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | []
002 | [1]
OMG YOU JUST FIXED IT-
Because I had str as a default
even when nothing was given
i say that
first
๐คฆ
no
Thank you so much for the help, and all of you for the many refactoring ideas! It's about time I tidied it up a bit
๐
just seeing with your eyes that code looks not good >>
nice joke
Is it actually a joke? xD
wow
look at it
this is only intro to new python era
Python 4
unimport and sync keywords
there are Python 2 and Python 3 but it was a joke 
Remember to:
โข Ask your Python question, not if you can ask or if there's an expert who can help.
โข Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
โข Explain what you expect to happen and what actually happens.
thats not even a screenshot but yeah photo applies
pep 9001 yes, pep 8 no
the welcome message is not being sent
hey check the date when that pep was posted
async def on_member_join(member):
general_channel: discord.TextChannel = client.get_channel(1143525494973804648)
await general_channel.send(content=f"Bienvenue sur le serveur {member.display_name} !")```
.get_channel can return None use this syntax ```py
channel = client.get_channel(...) or await client.fetch_channel(...)
this will ensure that you will get channel object
where should i put this code?
when you get TextChannel object from id
don't general_channel: disord.TextChannel ?
just channel ?
async def on_member_join(member):
general_channel: discord.TextChannel = client.get_channel(1143525494973804648)
await general_channel.send(content=f"Bienvenue sur le serveur {member.display_name} !")
or await client.fetch_channel(1143525494973804648)```
@slate swan
like that ?
No

why do you do general channel
tuto ytb
what
Tutorial YouTube
how ?
They literally just sent how it should look like
this work
where !?
async def on_member_join(member):
channel = await client.fetch_channel(1143525494973804648)
await channel.send(content=f"Bienvenue sur le serveur {member.display_name} !")```
You don't see this giant code block?
!d discord.Client.get_partial_messageable no need to get or fetch the channel just to create a message
get_partial_messageable(id, *, guild_id=None, type=None)```
Returns a partial messageable with the given channel ID.
This is useful if you have a channel\_id but donโt want to do an API call to send messages to it.
New in version 2.0.
it still does not work !!!!!

it does
Cause you changed nothing
you are just do it wrong KID i just test it
?
no ?
put print statement inside to ensure its invoking
default_intents = discord.Intents.default()
default_intents.members = True
client = discord.Client(intents=default_intents)
@client.event
async def on_ready():
print("Le bot est prรชt.")
@client.event
async def on_member_join(member):
channel = await client.fetch_channel(1143525494973804648)
await channel.send(content=f"Bienvenue sur le serveur {member.display_name} !")
@client.event
async def on_message(message):
if message.content.lower() == "ping":
await message.channel.send("pong", delete_after=5)
if message.content.startswith('$hello'):
await message.channel.send('Hello!')
client.run('`token')``` full code
?
There is no message content intent enabled
Can you do what i ask for
You dont need that to send messages
.
For now they are trying to fix on_member_join
Guess that's the next part
i dont understand
Yep
put print statement inside to ensure its invoking
What's so complex in this
The English language ๐
put intent
the translation
Let me rephrase it
Print something inside this event to make sure its called
how ?
print("something")?
Ah yes printing, beware any printer connected will print this on an A4
where
๐ฟ I used python 6
Inside the event
I personally use 11
preferably first line of it
async def on_member_join(member):
channel = await client.fetch_channel(1143525494973804648)
await channel.send(content=f"Bienvenue sur le serveur {member.display_name} !")
Print("something")````
I used 11 but there is a problem
Now i want create 12
here ? @slate swan
๐
Small p in Print
Nah 12 isn't supported that much.
yes ?
Phone coding confirmed
Developed by me, only hackers use it
How is that
is this all the event?
Are you ok?
No only the on_member_join function body is the event
Print("something")
async def on_member_join(member):
channel = await client.fetch_channel(1143525494973804648)
await channel.send(content=f"Bienvenue sur le serveur {member.display_name} !")
still no.
I'm drunk I'll be back I'm going to eat
Drunk coding is good vibe ngl
raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: JSONDecodeError: Expecting value: line 1 column 1 (char 0)```
```@bot.slash_command()
async def predict(ctx):
games = scraper.get("https://rest-bf.blox.land/games/crash").json()```
scraper = cloudscraper.create_scraper()
Anyone can help me?
@slate swan ๐ฟ
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
๐ฟ
And you have been already asked to not ask questions related to this
hey
please can you correct this
what is the error
I wanted to say that it pissed me off, I didn't drink
there is no error just when someone joins the serv the welcome message is not displayed
did you check the intents
yes
ok
in api
@client.event
async def on_member_join(member):
print(f"Member joined: {member.display_name}")
channel = await client.fetch_channel(1143525494973804648)
await channel.send(content=f"Bienvenue sur le serveur {member.display_name} !")
can you try this
ok go message private please
don't work
ok
np ty
Do u still need help?
yes
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 Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
There
infact I have no error messages but the bot does not send anything when a member joins the server
What intents do u have
I checked everything in the api
Prob same solution to this
async def on_member_join(member):
general_channel: discord.TextChannel = client.get_channel(1143525494973804648)
await general_channel.send(content=f"Bienvenue sur le serveur {member.display_name} !")```
default_intents = discord.Intents.default()
default_intents.members = True
client = discord.Client(intents=default_intents)
Itโs ok
Ok so put a print statement inside the event
So where the code isnโt working out a print statement
I do not know what it is
what should I change?
.
Itโs basic python
The very first thing everyone learns
i'm noob
Should learn python before but anyways
This
Where u did print
Put it inside event
but is it already an event?
Yes just put it inside with the rest of the code
But where is the event?
The on_member_join?
but it's not already inside?
The print statement (make another one)
what does this shard thing mean? Is it beneficial
I have to copy my code?
Do u have a auto sharded bot?
No just leave it
Yes
Makes sense
Does it make the bot better at all, does it make a difference?

Basically when ur bot gets in a lot of servers (1k+) then the bot needs sharding that way the bot doesnโt slow down
Afaik no
huh
Ok type print(โtestโ) then press tab
he has no idea whay youre saying, he doesnt want to copy it, he wants you to literally make a whole new script
tab the touch ?
I would but Iโm on mob ๐ฆ
Just put it inside (under) the event
the tab key?
Ignore that part
Yea
and ?
Does it print anything when a member joins?
idk
no
no message

@vocal laurel
No print?
no
That means the event was never triggered
Should I do something with: OAuth2
No no
Well idk then donโt think I can help
why
?

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 Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
Ok paste ur code there and I will see if I can see the error
its good ?
gl
Does ur on message work?
the ping pong, yes otherwise the join it did not work
Is there even someone joining to trigger the event
I joined
Did not work
retry
K
i'm actually using pycord and i get the following error (appearing in the ss)
here is all the script imports :
from discord.ext import commands
import discord
from discord import default_permissions
from colorama import Fore, Back, Style, init
import json
import os
import pathlib```
Reinstall it i guess
alr did
pycord has a tendency to shuffle around import locations from discordpy
I don't use pycord so I can't tell for sure but they may have just moved commands somewhere else
From their docs it looks they didn't
why ?
i don't think that it can be benefic
humour me
hm ?
database is the correct choice
what's the difference between dictionary and json format in python? 
sure
So im trying to make a translate command but I don't know why i get this error when trying to send the translated text https://api.doxbin.life/aenq271q.png
File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\lightbulb\app.py", line 1162, in invoke_application_command
await context.invoke()
File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\lightbulb\context\base.py", line 334, in invoke
await self.command.invoke(self)
File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\lightbulb\commands\base.py", line 798, in invoke
await self(context, **kwargs)
File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\lightbulb\commands\base.py", line 712, in __call__
return await self.callback(context, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\Administrator\Desktop\teddy\ext\fun.py", line 92, in translate_text
translated_text = data["data"]["translations"][0]["translatedText"]
~~~~^^^^^^^^
KeyError: 'data'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\lightbulb\app.py", line 1203, in handle_interaction_create_for_application_commands
await self.invoke_application_command(context)
File "C:\Users\Administrator\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\lightbulb\app.py", line 1180, in invoke_application_command
raise new_exc
lightbulb.errors.CommandInvocationError: An error occurred during command 'translate' invocation```
how would you get all fields of a slash command in discord.py? So far I've got
for i in bot.tree.walk_commands():
command = i if i.name == command_name else False
if command:
if isinstance(command, commands.slash_command):
description = command.description
And I'm kinda stumped.
I know the problem is with the JSON but don't know how to fix that
Keyerror data means there's no key called data
might wanna double check your json file
it works when I use this instead but i tried putting it into my bot file but the same error exit https://api.doxbin.life/1wf0ojox.png
Online api
[][data] probably?
why don't you use the data variable you've defined previously?
Okay.
Cuz im braindead 
as a sidenote, you can use pass_options=True in the command decorator to get the command options as a variable as a function argument
@option("name", ...)
@option("arg1", ...)
@command("command", "description", pass_options=True)
async def my_cmd(ctx: lightbulb.Context, arg1: ..., name: ...) -> None:
saves you from writing extra code
uh
unfortunately we cant help with that due to rule 5
hi im trying to get a free game notifier but my code doesnt seem to work can anyone help me?
session = requests.Session()
session.headers.update({'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'})
@tasks.loop(seconds=5)
async def free_epic():
channel_id = 1144298794641526874
channel = bot.get_channel(channel_id)
epic_url = 'https://www.epicgames.com/store/en-US/free-games'
try:
epic_response = session.get(epic_url)
epic_response.raise_for_status()
epic_soup = BeautifulSoup(epic_response.text, 'html.parser')
epic_free = []
for game in epic_soup.find_all('div', class_='css-w6ymp8'):
title = game.find('span', class_='css-1162pv2').text.strip()
epic_free.append(title)
if epic_free:
embed = discord.Embed(title="Free Games Alert!", description="Here are the latest free games:", color=0x00ff00)
epic_list = "\n".join([f"โข {game}" for game in epic_free])
embed.add_field(name="Epic Games", value=epic_list, inline=False)
expiration_time = datetime.utcnow() + timedelta(days=7)
embed.set_footer(text=f"Expires on {expiration_time.strftime('%Y-%m-%d %H:%M:%S')} UTC")
await channel.send(embed=embed)
except requests.RequestException as e:
print("An error occurred:", e)
error: An error occurred: 403 Client Error: Forbidden for url: https://store.epicgames.com/en-US/free-games
This is extremely obvious
Read the error
it says forbidden but it shouldnt be
Have you thought that a multi billion dollar company wouldn't want bots spamming it's webpage?
ik but its my own computer and idk how to fix it
but can i let it act like a computer? there are many people who have a working one
This is what we call breaking TOS
This isn't really a discord-specific error, you might be better off asking elsewhere or trying to find some official API documentation
On a side-note you should use aiohttp to make HTTP requests in an async application
na there was something for bots on there but i closed the page
๐ฅ
find an official api that provides storefront
If you have to impersonate a computer they don't want bots visiting that website
You've already tried and you've been blocked, therefore it's disallowed
if i try this one it also has some other stuff that is allready expired: https://store-site-backend-static.ak.epicgames.com/freeGamesPromotions?locale=us-ES&country=US&allowCountries=US
I think private apis is againest the rules here cant help you with that
refer to their official docs
cant find there are to many docs
What are you looking for
for how to get the info so i contacted epic support and they told me there was no problem with it and it should work so now i have to ask discord ๐
Which API did they tell you to use
What service do you use to host a discord bot? I can host one on my own computer, but what else do people use?
I've heard good things about AWS and Oracle
I've been using digital ocean for around 6 months, their pricing is decent imo and i've never really had any issues with their service
DO k8s is nice
Heznter
also DO bc i have free credits to spend
I'm just going to use my raspberry pi and see how it goes
make sure you have a good internet connection
Ethernet so
I'll see how it goes for like a day
I have no clue how much RAM I bought
Hopefully 4GB
I already have a PI so
If it doesn't turn out good or if I need an upgrade I'll prob go with do or hetnzer
Only downside for Hetnzer is no Canadian servers
But most people using the bot are gonna be in the USA or elsewhere so ๐คทโโ๏ธ
the best is vps
Just a cheap vps that is running a server version of linux with ssh
Just the store link XD
await bot.tree.sync()
pycord autosyncs doesnt it ?
can someone help me with this import error please ? ...
ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)
What library are you using?
Run this script
Then there are two cases:
- You are using discord.py:
Then you are ready to go should be working - You are not using discord.py:
Then you need to run this too:
pip uninstall discord.py
pip install -U YOUR_LIB
Read my last message
Run commands i gave you here
And replace YOUR_LIB with py-cord
same problem occurs
from discord.ext import commands
ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)
can you run this script:
print(__import__("discord").__version__)
py-cord doesn't have ext. You are most likely using discord.py code.
Doesnt it?
How come that py-cord is getting so popular??
!pypi py-cord
Damn tutorials.
No it's discord.Bot
They have in the docs ยฏ_(ใ)_/ยฏ
Pycord offers a lower level aspect on interacting with Discord. Often times, the library is used for the creation of bots. However this task can be daunting and confusing to get correctly the first...
Its only alias
i always use that code for pycord but it's not working for packages importing shit and i always forget what should i do
Though it's a second such question here. There was someone with the same problem in pycord yesterday
discord/ext/commands/bot.py line 390
class Bot(BotBase, discord.Bot):```
@tall temple ?
It should give error when ran
how about __title__ instead of __version__
yes
discord/__init__.py line 11
__title__ = "pycord"```
Pycord Has such attribute
Pycord has ext.commands too ยฏ_(ใ)_/ยฏ
I'd just jump into the import discord (ctrl + click in pycharm, idk about another ide) and look what's there
(Vscode too)
------------------ ---------
aiohttp 3.8.5
aiosignal 1.3.1
anyio 3.7.1
async-timeout 4.0.3
attrs 23.1.0
certifi 2023.7.22
charset-normalizer 3.2.0
colorama 0.4.6
discord-protos 0.0.2
exceptiongroup 1.1.3
fernet 1.0.1
ffmpeg-python 0.2.0
frozenlist 1.4.0
future 0.18.3
h11 0.14.0
httpcore 0.17.3
httpx 0.24.1
idna 3.4
imageio-ffmpeg 0.4.8
multidict 6.0.4
numpy 1.25.2
pip 23.2.1
protobuf 4.24.1
py-cord 2.4.1
pyaes 1.6.1
pycord 0.1.1
requests 2.31.0
setuptools 57.4.0
sniffio 1.3.0
typing_extensions 4.7.1
urllib3 2.0.4
yarl 1.9.2
Do u have a file called discord.py
no
What is discord-protos
idk ๐น
Also uninstall pycord
ok ok
py-cord is the correct one
ik
I'd just uninstall everything.
Nah its most likely caused by pycord lib
Work with venv's and only install packages globally what you use when playing around/ running random code.
!pip pycord
Or maybe no 
hmm
~/Downloads (0.957s)
pip list
Package Version
numpy 1.25.2
pip 23.2.1
psutil 5.9.5
setuptools 65.5.0
this all of my packages lol
@slate swan have you ever heard of warp?
no?
It's pretty gut been trying it out, it's mac only app for now.
what is it for
It's just a fancy command prompt, but it has some cool features.
ill check it out
Dm me if you have slah command code
Can someone tell me how can I set the new custom status in discord.py?
!d discord.ext.commands.Bot you can pass activity to the 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.
!d discord.ext.commands.Bot.change_presence or just this
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...
I think they're asking about the custom activity type of status
That's what the method is for
Yea I see it now
Or is this what you meant
Is that different?
The following types currently count as user-settable:
- Activity
- Game
- Streaming
- CustomActivity
there is CustomActivity
!d discord.CustomActivity
class discord.CustomActivity(name, *, emoji=None, **extra)```
Represents a custom activity from Discord.
x == y Checks if two activities are equal.
x != y Checks if two activities are not equal.
hash(x) Returns the activityโs hash.
str(x) Returns the custom status text.
New in version 1.3.
its that one with emoji
owo thanks man
class discord.CustomActivity(name, *, emoji=None, **extra)
this one looks like the one i need
does it still work why is the bot reacting with trash
What still work?
yeah
And the trashcan emoji is for the user to delete the embed
i noticed it a few days ago
oh sry i didnt know i am new ๐
๐ yeah
Waiting for hi, i am old emoji
๐ lol
I'm trying to get users from a database. How can I skip the user's selection if he is leaved the server?
(I don't want to delete users from the database)
That try-except should work fine. Weird that you still get the error
Maybe it's from some other place or the file is not saved
It might be that it's wrapped inside HTTPException
How can I get the post count for a user?
What method?
what post count is?
how many messages they sent?
I select 10 records from postgresql and if there is a user in these records who has left the server, everything stops. I want to skip these users without deleting. Of course, I can prescribe member = None, but that's not what I want
Yeah
you cant really do that unless you store this data yourself
You are looping over them or what
Then do continue in except
for example python bot has api to store it https://github.com/python-discord/bot/blob/main/bot/exts/info/information.py#L433
bot/exts/info/information.py line 433
user_activity = await self.bot.api_client.get(f"bot/users/{user.id}/metricity_data")```
wow, thank you so much. I do not know what many keywords like continue do
There are not so much keywords :/
7.10. The continue statement
continue_stmt ::= "continue"
``` [`continue`](https://docs.python.org/3/reference/simple_stmts.html#continue) may only occur syntactically nested in a [`for`](https://docs.python.org/3/reference/compound_stmts.html#for) or [`while`](https://docs.python.org/3/reference/compound_stmts.html#while) loop, but not nested in a function or class definition within that loop. It continues with the next cycle of the nearest enclosing loop.
When [`continue`](https://docs.python.org/3/reference/simple_stmts.html#continue) passes control out of a [`try`](https://docs.python.org/3/reference/compound_stmts.html#try) statement with a [`finally`](https://docs.python.org/3/reference/compound_stmts.html#finally) clause, that `finally` clause is executed before really starting the next loop cycle.
So there is no way search up the total amount afterwards?
i guess no
i doubt you can loop over each message in each channel and check ids but you will mostlikely be ratelimited so easily
You can, with the abc.Messageable.history method but it will take forever
bruh, it seems that there is no way to do without deleting
1 3 5 6 ...
Just change the number only if the member is found
But if you want to get exactly 10 users, then yeah, that can become very inefficient
Also use get_member and fetch_member together to decrease api calls count
!d discord.Guild.get_member
get_member(user_id, /)```
Returns a member with the given ID.
Changed in version 2.0: `user_id` parameter is now positional-only.
It sounds like you're assigning the placement in a for loop, why not do a for loop to add them to a list, that way you can sort out whether they're a member or not inside the for loop, and after you're done use the list of members to assign placement
how do i ping someone by id in discord.py?
i have the id
but i don't know how to ping it
<@id>
like this then:
f"character of <@{ctx.author.id}>"
or am i wrong?
!d discord.User.mention or just this if you have a user/member object
property mention```
Returns a string that allows you to mention the given user.
https://discord.com/developers/docs/reference#message-formatting-formats
also you can find all formats here
@severe sonnet
oh i see, it's not a variable thing but a string thing
okay soo i'm still confuse on how webhooks works
i got this structure:
{
"username": "Webhook",
"avatar_url": "https://i.imgur.com/4M34hi2.png",
"content": "Text message. Up to 2000 characters.",
"embeds": [
{
"author": {
"name": "Birdieโซ",
"url": "https://www.reddit.com/r/cats/",
"icon_url": "https://i.imgur.com/R66g1Pe.jpg"
},
"title": "Title",
"url": "https://google.com/",
"description": "Text message. You can use Markdown here. *Italic* **bold** __underline__ ~~strikeout~~ [hyperlink](https://google.com) `code`",
"color": 15258703,
"fields": [
{
"name": "Text",
"value": "More text",
"inline": true
},
{
"name": "Even more text",
"value": "Yup",
"inline": true
},
{
"name": "Use `\"inline\": true` parameter, if you want to display fields in the same line.",
"value": "okay..."
},
{
"name": "Thanks!",
"value": "You're welcome :wink:"
}
],
"thumbnail": {
"url": "https://upload.wikimedia.org/wikipedia/commons/3/38/4-Nature-Wallpapers-2014-1_ukaavUI.jpg"
},
"image": {
"url": "https://upload.wikimedia.org/wikipedia/commons/5/5a/A_picture_from_China_every_day_108.jpg"
},
"footer": {
"text": "Woah! So cool! :smirk:",
"icon_url": "https://i.imgur.com/fKL31aD.jpg"
}
}
]
}
but i hacve no idea how they works
do i just send it as a dictionary or...?
yep still confuse
and i read the docs
i'm trying this:
but i still have no idea what to do
using this dict
Why when I make an account send command with requests the command doesn't work
Its not even called
- Did you enable message_content intent?
- Do you have any on_message event?
It's command with prefix + all intents is enabled+ when I type command it work
Only when send it with requests not working
What does send command with requests means?
Do you know requests library?
Yes?
I'm using it to send command with an acc
Send what command
Show it
The only problem with requests is blocking
But it seems it's something else by you
!blocking
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.
What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:
import discord
# Bunch of bot code
async def ping(ctx):
await ctx.send("Pong!")
What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.
async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!
use aiohttp instead
Any ideas why I couldn't display an animated emoji in an embed title? Works when I swap to a regular one.
shouldnt it be lowercase a?
Oh you know what, it's formatted as a title
Custom Emoji (Animated) <a:NAME:ID> :b1nzy:
its lowercase here dont know if it changes anything for discord
Yea that's probably what it is. When I'm putting together the embed I'm formatting the text as title
can a bot read replies like this?
!d discord.Message.reply yes
await reply(content=None, **kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A shortcut method to [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable.send) to reply to the [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message).
New in version 1.6.
Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError) or [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError) instead of `InvalidArgument`.
thank you
The message that this message references. This is only applicable to messages of type MessageType.pins_add, crossposted messages created by a followed channel integration, or message replies.
New in version 1.5.
oh thats why its not working
is there any example usage?
I read that wrong 
I mean you'd use it just like every other attribute
Hello anyone know how to hide member Offline on server discord?
@buoyant quail Sorry but you know?
For example, when a member is offline, it should not appear in the member list section
Are you sure that's possible?
.......
yes like here look member offline
you cant see on member list
Yes i am sure
Is there an example of small server with that
Because here it's causing so much lags to my discord that i am not sure that all people are loaded
Yes i understood. I mean a small server where it surely is so
Because here i feel more like discord just is not going to destroy my pc by showing all the 200k people
the photo my server
I mean how to hide
That is, no one should see it
And i mean i still don't believe that it's possible
There is, I'm sure
anyone can help me?
https://support.discord.com/hc/en-us/community/posts/360029340312-Toggle-the-offline-member-list
https://www.google.com/search?q=discord+is+it+possible+to+hide+offline+members+list+on+server
I understand that this was just reverted from only being toggled off if a server has 100+ members. But please let us be able to toggle it off. It lags mobile clients, and completely hard crashes it...
1000 members and you won't see them
automatick?
ye
Ty
!d discord.CustomActivity
class discord.CustomActivity(name, *, emoji=None, **extra)```
Represents a custom activity from Discord.
x == y Checks if two activities are equal.
x != y Checks if two activities are not equal.
hash(x) Returns the activityโs hash.
str(x) Returns the custom status text.
New in version 1.3.
what did you try?
are you using raw discord api?
thats how its parsed here
What should I show?
code
(would be good to send with and without to look only on the difference)
I will show only requests part
payload = {
"content" : f"-join {self.server_id.value} {self.count.value}"
}
headers = {"authorization" : "the token of the acc"}
r = requests.post("https://discord.com/api/v8/channels/1100879507541459034/messages", data=payload, headers=headers)
Are you self-botting?
๐ง
lies
So what's the token of the acc means
But only there is this part using an acc in it
I said I'm using an acc in the first message I sent
..
Account of what
Discord maybe?
isnt that definition of self botting?
If it's an user account, that's self-botting
So?
so we wont help you
!rule 5
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
Nvm
Self botting is enforced by discord as well
We would ban, they would obliterate the account
Why you didn't tell me when I send the first message?
I don't read every message in the server ยฏ_(ใ)_/ยฏ
I mean them
didnt we?
Well it seems like they were trying to understand what you were asking about
How do i make a Slash command? can someone give me code?
for me?
yes!
can i dm?
why would you need to dm me
i want to show you my code and what to paste in im VERY new
?
no i mean i show you code and errors if they occur
show them here then
from discord.ext import commands is that the same as from discord import app_commands
no
ok thans
commands is for prefixed commands while app_commands is for slash commands
oh so should i delete that with the prefix
you can use prefixed commands with slash
but i want the / command that shows up when u type in /
they do not bother each other
bot = commands.Bot(command_prefix="/", intents=discord.Intents.all ()) can i delete that?
then its slash command
you will need a Bot instance but seting prefix to / doesnt make commands slash commands
please look at the example i linked
so do i delete that
^
wich line?
every
ok lemme read throught
the example purpose is to run it yourself check how the commands work, then try to understand why and how it works then change some stuff in the code and see what it changes on discord. Basically thats how you learn
so it says something about tree can u explain im very new
Thanks Down
what is a CommandTree?
a command tree just stores your commands you dont need to bother how it works, just how to use it
ok so i need to use?
please do what i said here and then afterwards ask questions about what you dont understand
ok
@client.tree.command()
async def hello(interaction: discord.Interaction):
"""Says hello!"""
await interaction.response.send_message(f'Hi, {interaction.user.mention}')
that is not working?
What is not working
what is not working about it?
ERROR discord.ext.commands.bot Ignoring exception in command None
discord.ext.commands.errors.CommandNotFound: Command "hello" is not found
remove the / as prefix
ok
can bots see bio?
no
i see
It now does not react when I type /hello
Bots cannot see any client stuff like bio
Did u sync
show how it looks like on discord
when you try
you need to choose this command from list that pops up
for example type / here and see what commands you have got to choose from
Does it show up on the command list
Just type in / and see if your /hello command appears
If it doesn't, then it's time to sync your command tree
also show your code
await self.tree.sync(guild=MY_GUILD) i did not include that because it was an eroor
removing the line of code cause it has error doesnt solve the error
what was the error?
mport discord
from discord.ext import commands
client=discord.client
bot = commands.Bot(command_prefix="!", intents=discord.Intents.all ())
from discord import app_commands
MY_GUILD = discord.Object(id=1066713764356964372)
class MyClient(discord.Client):
def init(self, *, intents: discord.Intents):
super().init(intents=intents)
self.tree = app_commands.CommandTree(self)
async def setup_hook(self):
self.tree.copy_global_to(guild=MY_GUILD)
intents = discord.Intents.default()
client = MyClient(intents=intents)
client.event
async def on_ready():
print(f'Logged in as {client.user} (ID: {client.user.id})')
print('------')
@client.tree.command()
async def hello(interaction: discord.Interaction):
"""Says hello!"""
await interaction.response.send_message(f'Hi, {interaction.user.mention}')
bot.run(TOKEN)
i did the token but discord says its dangerous to chat it
!code
format it please
Oh boy auto syncing
why you create both Bot and Client instance?
import discord
from discord.ext import commands
client=discord.client
bot = commands.Bot(command_prefix="!", intents=discord.Intents.all ())
from discord import app_commands
MY_GUILD = discord.Object(id=1066713764356964372)
class MyClient(discord.Client):
def __init__(self, *, intents: discord.Intents):
super().__init__(intents=intents)
self.tree = app_commands.CommandTree(self)
async def setup_hook(self):
self.tree.copy_global_to(guild=MY_GUILD)
intents = discord.Intents.default()
client = MyClient(intents=intents)
client.event
async def on_ready():
print(f'Logged in as {client.user} (ID: {client.user.id})')
print('------')
@client.tree.command()
async def hello(interaction: discord.Interaction):
"""Says hello!"""
await interaction.response.send_message(f'Hi, {interaction.user.mention}')
bot.run ("The tokn i should not Share")
huh? whats that
Should be client.run
Im trying to create a Discord bot. Do you have any recomendations of Youtube videos or places where I can reserach more?
replace all your code with the example
No yt tutorials. Read the dpy docs and if you need, just go ahead and join the dpy server for help
!d discord.py
!pypi discord.py
please what is the code for "intents
Tanks
yes, to see how it works
class discord.Intents(value=0, **kwargs)```
Wraps up a Discord gateway intent flag.
Similar to [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.
To construct an object you can pass keyword arguments denoting the flags to enable or disable.
This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client).
New in version 1.5.
https://fallendeity.github.io/discord.py-masterclass/
this is the guide
A hands-on guide to Discord.py
That guide has some stuff missing ngl
TypeError: BotBase.__init__() missing 1 required keyword-only argument: 'intents'
its not done
!intents
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.
There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.
Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.
Ik
Thank you
Exception has occurred: NameError
name 'Optional' is not defined
File "C:\Users\Phil\Desktop\discordbot.py", line 70, in <module>
async def joined(interaction: discord.Interaction, member: Optional[discord.Member] = None):
^^^^^^^^
NameError: name 'Optional' is not defined
are you sure you copied all the code?
its defined on the very first line https://github.com/Rapptz/discord.py/blob/master/examples/app_commands/basic.py#L1
examples/app_commands/basic.py line 1
from typing import Optional```
oh i see
Traceback (most recent call last):
File "C:\Users\david\PycharmProjects\pythonProject\bot discord\venv\Lib\site-packages\discord\ext\commands\core.py", line 235, in wrapped
ret = await coro(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\david\PycharmProjects\pythonProject\bot discord\main bot discord.py", line 18, in delete
messages = await ctx.channel.history(limit=number_of_message + 1).flatten()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'async_generator' object has no attribute 'flatten'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\david\PycharmProjects\pythonProject\bot discord\venv\Lib\site-packages\discord\ext\commands\bot.py", line 1350, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\david\PycharmProjects\pythonProject\bot discord\venv\Lib\site-packages\discord\ext\commands\core.py", line 1029, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\david\PycharmProjects\pythonProject\bot discord\venv\Lib\site-packages\discord\ext\commands\core.py", line 244, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'async_generator' object has no attribute 'flatten'```
my god
.flatten is removed by now i belive
from migration guide: ```py
before
users = await reaction.users().flatten()
after
users = [user async for user in reaction.users()]```
403 Forbidden (error code: 50001): Missing Access
File "C:\Users\Phil\Desktop\discordbot.py", line 28, in setup_hook
await self.tree.sync(guild=MY_GUILD)
File "C:\Users\Phil\Desktop\discordbot.py", line 116, in <module>
client.run('TOKEN')
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
i want delet message
?
yeah here you have how to transform it to not use flatten
i test and you tell me if it's good
403 Forbidden (error code: 50001): Missing Access
File "C:\Users\Phil\Desktop\discordbot.py", line 28, in setup_hook
await self.tree.sync(guild=MY_GUILD)
File "C:\Users\Phil\Desktop\discordbot.py", line 116, in <module>
client.run('TOKEN')
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
full traceback
That means?
!traceback
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
~~~~^~~
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
In this basic example, we just synchronize the app commands to one guild.
# Instead of specifying a guild to every command, we copy over our global commands instead.
# By doing so, we don't have to wait up to an hour until they are shown to the end-user.
async def setup_hook(self):
# This copies the global commands over to your guild.
self.tree.copy_global_to(guild=MY_GUILD)
await self.tree.sync(guild=MY_GUILD)
xception has occurred: Forbidden
403 Forbidden (error code: 50001): Missing Access
File "C:\Users\Phil\Desktop\discordbot.py", line 28, in setup_hook
await self.tree.sync(guild=MY_GUILD)
File "C:\Users\Phil\Desktop\discordbot.py", line 116, in <module>
client.run('TOKEN')
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
@slate swan There are no options here?
Admin gives all options
At the bottom
what options you expect to be there?
No url
cause you selected some scopes that require redirect url
at the top u need to select
which you prolly dont want
ok
select only bot and application.commands
So if the self bot is illegal
Can I make another bot send a message in the same project?
Hi ! Im new in dev discord bot with python and my bot not respond to any command. No error in console ..
- format it
- thats still not full traceback
messages = [user async for user in ctx.channel.history(limit=number_of_message + 1)]
The complete code?
@slate swan its user or message ?
should be working but why name message user?
Would this allow to bot to responde with messages as well?
traceback not code
Thanks
what is the code then?
where do i find it?
this is the correct code you just use name that will be misleading
bot do nothing
thats like you would do ```py
for char in range(10):
char + 2
# char will be a number so why name it char
did you enable message_content intent?
in the console?
why ?
cause you name message a user
yes
how to not mention the user
you need to enable it in code too
n-2023.14.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '60554' '--' 'C:\Users\Phil\Desktop\discordbot.py'
2023-08-25 21:33:44 INFO discord.client logging in using static token
PS C:\Users\Phil\Desktop>
rename the varriable in for loop?
thats logs
im in terminal
i want the traceback you provided earlier just not full
@slate swan Its not allowing me to save?
Thats all there is standing
Exception has occurred: Forbidden
403 Forbidden (error code: 50001): Missing Access
File "C:\Users\Phil\Desktop\discordbot.py", line 28, in setup_hook
await self.tree.sync(guild=MY_GUILD)
File "C:\Users\Phil\Desktop\discordbot.py", line 116, in <module>
client.run('TOKEN')
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
its telling you why directly?
should i just chane it to none?
but you pass actual token to it right ..?
yes, ofc
there is no way this is full traceback
what should I replace user with here?
message name is good
thats not a traceback
dont run it in debug mode unless you know how to use it
but I don't have to remove the "user"?
where shoul i run it?
i just pressed f5
My friend told me
no you dont but why mislead
how is that top right corrner?

