#discord-bots
1 messages · Page 92 of 1
ahhaha ye i had that once too
hi
i get the locked error
I implemented: ```py
bot = commands.Bot(command_prefix='', intents=intents)
bot.db_con = None
@bot.event
async def on_ready():
if bot.db_con is None:
bot.db_con = bot.db_con = await aiosqlite.connect("cvb.db")
tho still getting the error
apparently this can help but idk how to integrate `int sqlite3_busy_timeout(sqlite3*, int ms);`
the two functions using the db and the task loop: https://paste.pythondiscord.com/uvapiyuher
(note: I try make it do 2 `executemany` with 600+ tuples each)
anyone know the nextcord way to do avatar_url_as? i cant do avatar.url cuz i need the actual image for pillow 😔
yeah that gives the link but cuz pillow is an image library it only accepts images and idk how to make it turn a url into an image
ye i misread that
async def info(ctx, user: discord.Member = None):
img = Image.open("black.png")
disc = user.discriminator
id = user.id
with open("users.json", "r") as f:
users = json.load(f)
lvl = users[str(id)]["level"]
asset = user.avatar_url_as(size=256)
data = BytesIO(await asset.read())
pfp = Image.open(data)
img.paste(pfp, (60, 30))
draw = ImageDraw.Draw(img)
font_medium = ImageFont.truetype("arial.ttf", 60)
font_small = ImageFont.truetype("arial.ttf", 40)
font_large = ImageFont.truetype("arial.ttf", 80)
text = "Name:"
draw.text((360, 45), text, (255, 255, 255), font=font_small)
text = f"{user.name}"
draw.text((500, 30), text, (82, 100, 196), font=font_medium)
text = "Level:"
draw.text((360, 135), text, (255, 255, 255), font=font_small)
text = f"{lvl}"
draw.text((500, 120), text, (82, 100, 196), font=font_medium)
img.save("nice2.png")
await ctx.send(file=discord.File("nice2.png"))``` my pillow avatar thing
np 🙂
i use asset = user.avatar_url_as(size=256)
and some more under it
it says member has no attribute avatar_url_as
hmm
you're using nextcord or a different fork?
discord
yeah nextcord is different
ah ok
thanks for trying though
anyone got ideas for a fun and simple thing for a random bot (im noob coder btw)
RPG
hmm
games
sounds the exact opposite of simple
i used an RPG cog to get myself started when I was first learning discord.py lol
i can umm reply to message
o
and just learn how to ping ppl lol
hmmm how about 8ball?
np
its easy to learn
but thats a good idea for a bit later on
ok
not if he dosent know the basics lol
very true
no embed in help command = trash
A custom minecraft command block interpreter
hmm yes sounds very simple
buttons hmm
It is, minecraft command block syntax isnt hard its just a CLI with 3 data types iirc, being str, int, bool
data types = ez
I've never seen it done in a discord bot and would be quite unique and cool to see
but everything else? nope
i just learnt how to mention a user
and you want me to make a whole interpreter XD
Just take an unknown amount of arguments being your code, and then pass it into a parser function that parses the given code and returns a result, e.g /summon ender_dragon returns the name of the mob and then you use an api to get an img of the mob, parse the payload and send an embed with an img of the mob saying it was summoned
it sounds like you are doing what i do when i talk to someone who doesnt know abt programming to make myself sound smart
and i have no idea how to do that
im new to discord python XD
this causes sqlite lock
do i add a asyncio.sleep?```py
if len(updatedInfoSv) >= 1:
sqlSv = '''INSERT INTO itemsInfo(name, sv_value, sv_demand, sv_rarity, sv_stability, sv_status, sv_opUpRange, class) VALUES(?,?,?,?,?,?,?,?)ON CONFLICT(name) DO UPDATE SET sv_value = excluded.sv_value, sv_demand = excluded.sv_demand, sv_rarity = excluded.sv_rarity, sv_stability = excluded.sv_stability, sv_status = excluded.sv_status, sv_opUpRange = excluded.sv_opUpRange'''
await cur.executemany(sqlSv, updatedInfoSv)
if svUpdate == None:
svUpdate = await lastUpdate("sv")
if len(updatedInfoMv) >= 1:
sqlMv = '''INSERT INTO itemsInfo(name, mv_value, mv_demand, mv_rarity, mv_stability, mv_status, sv_opUpRange) VALUES(?,?,?,?,?,?,?)ON CONFLICT(name) DO UPDATE SET mv_value = excluded.mv_value, mv_demand = excluded.mv_demand, mv_rarity = excluded.mv_rarity, mv_stability = excluded.mv_stability, mv_status = excluded.mv_status, mv_opUpRange = excluded.mv_opUpRange'''
await cur.executemany(sqlMv, updatedInfoMv)
if mvUpdate == None:
mvUpdate = await lastUpdate("mv")
I'm just explaining the basic abstractions on how it may be done
It would depend what you prefer
ik im just new to it lol
nextcord>>>>>
There's hikari, discord.py, disnake and much others
@primal token you know any nextcord?
just would like something up to date, and fairly robust I guess
In fact it doesn’t really have to be robust, just modern/easy to work with preferably
good docs etc
2 executemany in a row with 600 tuples each
can cause sqlite lock?
it didnt before, but since i run the function in a task loop it does
https://paste.pythondiscord.com/uvapiyuher
(i removed the cursor.close())
disnake has good docs, variety of libraries based/made using it and alot of compatibility ||although i prefer nextcord cuz interactions r faster and simpler||
iirc both stay upto date
If you're interested in something good and new hikari would be your choice, if you want the same abstractions as discord.py but has its old codebase your choice would be forks, i would prefer disnake as its abstractions are quite good and the library is up to date
how do i self host a bot
Thanks for the suggestions guys
do i run it in some edditor
run it on your own ide
or in .exe
like an idle or vsc
both would
are there any usefull tips?
good question but idk i just use a server
No? You would run it on a python interpreter thats version is 3.7+ iirc
tnx
!pypi hikari
noid you know nextcord?
random fact but you joined this server exactly a year after your account was made
Never really used it
rip
nice
good intentions
amazing
anyone uses Postgres or MySQL
ig i have to switch
aiosqlite keeps getting database lock
interactions are faster and simpler
How are they faster? I do agree, they're simpler in a sense of abstractions as they dont have trees etc compared to discord.py
thats compared to one library also i didnt look into them i mean from my experience they seem to be decently optimized since they dont take 50 years to go through like some other bots
They dont take 1 hour to register globally but that isnt due to the library but its due to the new discord REST API update that makes registering app commands almost instant
i didnt mean that i meant just something like clicking a button some bots take 50 years to register but i get thats most likely the code not library but you thought so much into a word i just said impulsively 😔
That would depend on the bots codebase, yes, maybe your wifi is just slow
my wifi is usually between 400-700mbps 
but you did just give me an idea to solve my issue
How can I make a slash command option take a discord.Emoji?
sure that's what i do
Hey there i have a simple create channel command, however how can i make it so it automatically makes the user go to the channel once it is created?
I want it so the user doesnt need to click on the new channel, it just places them in the channel automatically
No. You can ping it and have the user click on it however
Ah, understood. However how does the ticket tool do it, whenever a new ticket is made the user is automatically placed in the new channel
I don't know what tool you're talking about but it's not possible
unless it like deletes the current channel or some weird workaround to force the client to switch channels
lol
Hi guys just wanna know if it's possible to make a stack exchange discord bot that tracks the reputation and question answered.
If stack has an API, then why not
how to add a delay on a function
cant you just do asyncio sleep?
robin if you see this msg could you ping me? ty
i require your 9000iq
is this ok for a requirements file?
i believe so
although i recommend adding versions
pip3 freeze > requirements.txt
no need for aiohttp and asyncio as theyre dependencies of discord.py
ok thanks
why is this an error??
my bot was working fine until a day or two ago
for guild in client.guilds:
await guild.ban(user)
print("here")
wont get past this
i just put aysncio.sleep(some time) at the end of the function?
await asyncio.sleep(1) will wait 1 second
i know
but
do i just put it on the end?
put it where ever you want it to wait a bit lmao
oke tnx
since it is async im guessing it wont effect other functions
how do i fix this
File "C:\Users\Travis\PycharmProjects\MainAttempts\PikleDiscordBot.py", line 28, in <module>
bot.run(DISCORD_TOKEN)
File "C:\Users\Travis\PycharmProjects\MainAttempts\venv\lib\site-packages\discord\client.py", line 828, in run
asyncio.run(runner())
File "C:\Users\Travis\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\Travis\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "C:\Users\Travis\PycharmProjects\MainAttempts\venv\lib\site-packages\discord\client.py", line 817, in runner
await self.start(token, reconnect=reconnect)
File "C:\Users\Travis\PycharmProjects\MainAttempts\venv\lib\site-packages\discord\client.py", line 745, in start
await self.login(token)
File "C:\Users\Travis\PycharmProjects\MainAttempts\venv\lib\site-packages\discord\client.py", line 577, in login
raise TypeError(f'expected token to be a str, received {token.__class__!r} instead')
TypeError: expected token to be a str, received <class 'NoneType'> instead```
please help
i keep getting this
do yu have TOKEN = aaaaaaaaaaaaa or TOKEN = "aaaaaaaaa"
did u put it in " "
os.getenv("Insert token here", default=None)
use os.evniron(['DISCORD_TOKEN'])
someone help me fix this pls
yeah it wont
lets say i put async slep(10) and person on one server runs a command then 3 seoncds later in anouther server another person runs a command that other person will then have wait 7 seconds for someting to happend right?
dw it'll only affect that one function
oke tnx
TypeError: '_Environ' object is not callable```
Wrong use of operators, = is the assignment operator in python while == is the comparison operator
ur using replit right?
o
my bad
try this:
no im using pycharm, is that ok?
yes
client.run(token)```
my bad it isnt os.environ(['TOKEN])
with open('prefix.json', 'r') as f:
prefixes = json.load(f)
return prefixes[str(message.guild.id)]
@client.event
async def on_guild_join(guild):
with open('prefix.json', 'r') as f:
prefixes = json.load(f)
prefixes[str(guild.id)] = ','
with open('prefixes.json', 'w') as f:
json.dump(prefixes, f, indent=4)
@client.event
async def on_guild_remove(guild):
with open('prefix.json', 'r') as f:
prefixes = json.load(f)
prefixes.pop[str(guild.id)] = ','
with open('prefixes.json', 'w') as f:
json.dump(prefixes, f, indent=4)
@client.command(aliases=['prefix'])
async def setprefix(ctx, prefixset = None):
if (not ctx.author.guild_premissions.manage_channels):
await ctx.send("You're **missing** permission: ``manage_channels`` ")
return
if (prefix.set == None):
prefixset = ','
prefixes = json.load(f)
prefixes[str(ctx.guild.id)] = prefix.set
with open('prefixes.json', 'w') as f:
json.dump(prefixes, f, indent=4)
await ctx.send(f"The bot prefix has been changed to ``{prefixset}``")``` **This is the code can someone help me fix the error?**
from discord.ext import commands
import pygame
import pyautogui
import os
from discord import Intents
token = os.environ[token here']
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix=".", intents=intents)
@bot.command()
async def ping(ctx):
await ctx.channel.send("pong")
@bot.command()
async def print(ctx, arg):
await ctx.channel.send(arg)
bot.run(token)```
this is my code, what do i have wrong
here
@patent wagon i have to go, ill message you about this later, thanks tho
Alright, I send a get request to the API then I need to fliter the json response and get the ID and then send a new get request with the ID it go
how do I send private messages using the discord bot?
you need a member object, then use .send() to send a message
how would I put that with code?
Alright, I send a get request to the API then I need to fliter the json response and get the ID and then send a new get request with the ID it go
well that depends on your context on how/when you want to DM the user, but please read the docs
please someone help me
Hi, how can I use "for" iteration on discord bot like for this purpose : ```@client.hybrid_command(name = "testing", with_app_command = True, description = "Testing", )
@app_commands.guilds(discord.Object(id = guild_id))
async def testing(ctx: commands.Context, content, channel: discord.TextChannel):
channels_send.append(channel.id)
contents_send.append(content)
await ctx.send("ok", delete_after=3)
@client.command()
async def program(ctx):
for channel_send in channels_send:
channel = client.get_channel(channel_send)
print(channel)
for content_send in contents_send:
await channel.send(content_send)```?
What are you trying to do
Hola
@quaint epoch me puedes ayudar con un bot?
Necesito que alguien me ayude con un bot que usa java script
(Mencioname si me puedes ayudar por favor)
@upper glacier please use english to the best of your ability
@bot.command
@lightbulb.option("my_arg", "my_desc")
@lightbulb.command("my_cmd","my_desc")
@lightbulb.implements(lightbulb.SlashCommand)
How would i make my_arg only accept an integer?
Hikari, lightbulb lib
!rule 4
4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.
Alright, I send a get request to the API then I need to fliter the json response and get the ID and then send a new get request with the ID it got
how do i do that
#965291516031549500 would be better suited for this
what do i do in case someone steals my discord bot token
regenerate the token
im asking cos im giving my bots code to somone else to host it
then remove your token prior
is there any way i can save token in a locked file
wait
or someting
if they are hosting it then they somehow need to connect to the bot
exactly
so not that im aware of
either way, your bots token or theirs they'll have full access to the bot
well... yes
can they log in discord dev protal with my bots token?
no not what i was saying
No, they can't. If you trust the person enough, I wouldn't worry too much. Else, search for another host
they are hosting an minecraft server and have a bunch of space
and proper eqiipment
i mean.. equipment is a bit of a stretch
if its a smaller bot, you can host online for a very small cost
like lets say they want to use my bot for malicious puropse i could in theory delete the bot in deiscord dev portal and stop them right?
yes but thats not to say it wont nuke your server / ruin what you are doing before you have time to sign in and regenerate
if you're giving your bot files for someone else to host you better trust them 200%
im trusting them 90%
Then I wouldn't give it to them
bro it will be run on their server
I trust companies like AWS, GCP, MS Azure, Oracle 200%, I'll host my bot with them
You may want to consider looking into a few of those
how much per month
but if you dont have history with this person whos saying they wont just mess your server up?
It varies widely
theres small ones that are <$5
i do im saying hypotetically
If you've got any old hardware lying around that's very good
how much do u sell it for
I don't sell anything
i got an old pc
Great, install linux on it and run a bot. Should be more than enough
?
why linux?
worst case scenario, they do what they want before you realize, if this is a bot in say <10-20 servers you would be fine with an old pc or even a minimal server
Lightweight, more resources for your bot instead of bloating yourself with windows with stuff you don't need
don't even need a DE just pop on ubuntu server edition and you're golden
I personally use AWS for hosting my bot and it's dashboard, and a few other components needed to make the bot run. I could've probably done it on my raspberry pi, but I wanted to learn DevOps :p
again, if small would work
sounds to me like a good learning experience
hmmm
il give it a try
im yet to try heroku
Good, keep it that way
i heard they are soon removing some free features
will they effect the functionality of a bot?
well yeah you'll have to start paying
only some of the features will be removed tho
free hosting is 90% of the time is absolutely horrible unless done by you
i.e an old pc, localhost, pi etc
Why is this an error?
chanel?
??
guess not
im assuming you should be doing ctx.channel.mention or message.channel.mention
potentially different in your case ^ but i cant see the rest
works lemme test
how do i turn a discord timestamp into seconds?
something like discords unix time?
nvm
Check the type of message.guild
You can check if the guild is None
!d discord.Message.guild
The guild that the message belongs to, if applicable.
though there is a @guild_only check if that's what you're looking for
anything againt discord.ChannelType.private?
?
How do i send a message to a specific channel
channel = bot.get_channel()
await channel.send('hello')
then it only sends the first word
await channel.send('hello')
i am doing that 💀
but it only sends the first word
wym? 'hello' is one word
would be easier to debug if u can send an actual code snippet
channel = bot.get_channel(channel_id)
await channel.send('hello friend')
@weak quail ^
looks fine to me
do you want it to only send the first word? or..?
your code should work as expected
can you send the whole function?
THAT IS IT
Is there an event for when the forum channel is closed by the author and can I reopen it?
Thanks! I has another question, The close post option in threads, does it archive the thread?
Then, you filter py thread = interaction.channel if interaction.user == thread.owner: and use await thread.edit(locked=False, archived=False)
Yes
So I notice, when I use the close post it just sends it to Older posts
Yep
But I can still message in it? Archived posts I cant message in?
Oh wait never mind
I think I got it wrong, thanks for the help
No worries
How do i take something like a user object and print all the information it holds as a string or something? Like how you can do print(message) and it gives you everything, how do you do that for a user object?
you mean printing out an object's attributes?
Yeah
Repr() gets some but it does not get stuff like guild.icon_url
you can just make a function and print the attributes out accordingly though
Not if you don't know what type of object you're getting
use isinstance() to check then
Then i still have to write out every single check for every type of object tho
Which i have already done
Gotta be a better way tho
hmm then im not sure about it
i dont think this is the problem but you should break the while loop or return the function
i was making a pokemon bot and had to like use the pokemon emojis but there are like 800 pokemon 😔 should i just make the bot upload an emoji whenever it needs it and then delete it?
the while True one, if you dont break it or return it, it will keep waiting for a new number and the game wont end
o then its not the problem 🤔
life of every pokemon bot owner
'User' object has no attribute 'banner' ????
just start with gen1 and add emojis later once bot is verified
Im looking at the docs and it says property banner Returns the user’s banner asset, if available.
!d discord.User.banner
property banner```
Returns the user’s banner asset, if available.
New in version 2.0.
Note
This information is only available via [`Client.fetch_user()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.fetch_user "discord.Client.fetch_user").
ok 😭 ty
New in version 2.0.
How do i get version 2.0
Or do i just need to update it
?
how do I edit the content of a button
just ask your question and someone will answer
import discord
ModuleNotFoundError: No module named 'discord'
Any solution to this?
I tried pip install discord and python -m pip install discord both
just ping me if anyone can help
is python on PATH?
whats the correct discord.py term for gathering all messages in a channel? ik fetch_message is for a single one. I want my bot to add 👍 👎 emojis to all messages in a specific channel.
I just need the correct words so i can look it up on the docs (theres something like 100+ results when i just search 'message')
maybe an on_message event in x channel?
yeah but i want to add the emojis to every past msg too
i need a way to fetch the ids of all the msgs in said channel and use a for loop
itll be a once off; after this ill just remove that piece of code from the bot and use my existing on_message one that adds the emojis upon creation
pip install -U discord.py
!d discord.TextChannel.history
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") to do this.
Examples
Usage...
hello
??
we can't work without no errors. do you have an error handler?
german moment
program one message to one channel with a command and send all (so send every message to his specified channel)
multiples messages or multiple channels?
multiple channel
one message max to a channel
like this !program content1 #channel1 !program content2 #channel2 !send
so you wanna store messages and channels using the program command and then when you run !send it should send all the messages stored using program command by the user, right?
yes that’s it
I tried with a sample code (#discord-bots message) but it not really worked
Its not working it just says Requirement already satisfied: discord.py in ./.local/lib/python3.7/site-packages (1.7.3)
surely it won't work + that's not a good implementation
you should be using a dictionary or a database with bot variables because of scopes
dunno then
idk then
reinstall.
How?
pip uninstall discord.py
pip install discord.py
wait, lemme check pypi again
did they remove the release or what lol
no it's 2.0.1
try doing
pip install discord.py==2.0.1```
ERROR: Could not find a version that satisfies the requirement discord.py-2.0.1 (from versions: none)
ERROR: No matching distribution found for discord.py-2.0.1
ERROR: Invalid requirement: 'discord.py=2.0.1'
Hint: = is not a valid operator. Did you mean == ?
lmao
I try with a dictionnary but it’s the same, with a dictionnary i need to use "for loop" to get keys and values ?
I already edited that
ERROR: Ignored the following versions that require a different python version: 2.0.0 Requires-Python >=3.8.0; 2.0.1 Requires-Python >=3.8.0
ERROR: Could not find a version that satisfies the requirement discord.py==2.0.1 (from versions: 0.1.0, 0.2.0, 0.2.1, 0.3.0, 0.3.1, 0.4.0, 0.4.1, 0.5.0, 0.5.1, 0.6.0, 0.6.1, 0.6.2, 0.6.3, 0.7.0, 0.8.0, 0.9.0, 0.9.1, 0.9.2, 0.10.0, 0.11.0, 0.12.0, 0.13.0, 0.14.0, 0.14.1, 0.14.2, 0.14.3, 0.15.0, 0.15.1, 0.16.0, 0.16.1, 0.16.2, 0.16.3, 0.16.4, 0.16.5, 0.16.6, 0.16.7, 0.16.8, 0.16.9, 0.16.10, 0.16.11, 0.16.12, 1.0.0, 1.0.1, 1.1.0, 1.1.1, 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.2.5, 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.4.0, 1.4.1, 1.4.2, 1.5.0, 1.5.1, 1.6.0, 1.7.0, 1.7.1, 1.7.2, 1.7.3)
ERROR: No matching distribution found for discord.py==2.0.1
loop through dict.items
hm why would that happen reallyit already hes 2.0.1
How do i update python
Its python that needs to be updated
nice
And i forget how to do it
dict={channel1.id : content1, channel2.id : content2}for example and so i need to do
channel = client.get_channel(item)
await channel.send(item)```
Is it like this ?
just google for how to install python 3.10 in Amazon linux and run those commands
hi ash, howdy
Alr sarthy
for key, value in dictionary.items():
...
!d dict.items
items()```
Return a new view of the dictionary’s items (`(key, value)` pairs). See the [documentation of view objects](https://docs.python.org/3/library/stdtypes.html#dict-views).
Ok ashlyy
smh
🥺
thanks i will check that
@slate swan you seem like a very intelligent person, do you by any chance know how to get all the info for an object, say i had a command that accepts any id, be it a guild id or message id or user id and the command tries to return as much info as it can get from that id, how do i do that, because stuff like repr() only gets a little bit, like if it was a guild id it wouldn't get the guild.icon_url or anything like that.
right now i just have a ton of try and excepts to try and get every attribute of every possible object
@slate swan intelligent hooman. he'll help, igtg
you can get the IDS for those object and use converters to convert them into the objects
if it is not a valid id , an error would be raised and you can move on to the next object to convert
!d discord.ext.commands.MemberConverter.convert
await convert(ctx, argument)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
The method to override to do conversion logic.
If an error is found while converting, it is recommended to raise a [`CommandError`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError") derived exception as it will properly propagate to the error handlers.
!d discord.ext.commands.GuildConverter
class discord.ext.commands.GuildConverter(*args, **kwargs)```
Converts to a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").
The lookup strategy is as follows (in order):
1. Lookup by ID.
2. Lookup by name. (There is no disambiguation for Guilds with multiple matching names).
New in version 1.7.
channel = self.bot.fetch_channel(int(payload.data["id"]))
if channel.archiver_id == int(data["owner_id"]):
if channel.archiver_id == int(data["owner_id"]):
AttributeError: 'coroutine' object has no attribute 'archiver_id'
But it should be there?
https://discordpy.readthedocs.io/en/latest/api.html?highlight=get_thread#discord.Thread.archiver_id
await self.bot.fetch_channel
ahh thanks
Adding and removing users from a thread:
so to check if a member is in a thread i did ```py
if thread.permissions_for(member).view_channel:
raise BadArgument('They are already in this thread...')
however it seems like it doesnt work since they can view the thread even after i called `thread.remove_user()`, but just not type
is there an alternative?
also another problem is after i call `remove_user()` on them, doing `add_user()` does nothing, they're still "cancelled" from thread and cannot type anything
Iv done that, but how do i get all the info, the guild object alone does not contain the guild.icon_url
channel = await self.bot.fetch_channel(int(payload.data["id"]))
print(channel.archiver_id)
This returns none?
The channel is archived and printing the channel.id does return the channel id
you can send only 1 view per message, though 1 view could contain multiple components
But the channel is found.. channel.id returns the channel.id
Only the archiver_id isnt returned..
what's the type of the channel
Forum thread
there's no archiver_id attribute/property for discord.ForumChannel, do you mean discord.ForumChannel.archived_threads?
A thread is under a forumchannel right? You cant archive the main forumchannel, you can archive the thread in it
https://discordpy.readthedocs.io/en/latest/api.html?highlight=get_thread#discord.Thread.archiver_id
true
was the thread archived by someone or it was automatically archived for inactivity?
Archived by me
should work
@commands.Cog.listener(name="on_raw_thread_update")
async def forum_channel_archived(self, payload):
data = payload.data
if (
data["thread_metadata"]["archived"] == True
and data["parent_id"] == "1019806662766379160"
):
channel = await self.bot.fetch_channel(int(payload.data["id"]))
if channel.archiver_id == int(data["owner_id"]):
await channel.edit(archived=False)
await channel.send(
"You cannot archive your own thread. It has been unarchived and will be automatically archived after 1 hour of inactivity."
)
Thats my whole code
I'm not sure but could be that the fetched thread is not a full thread object?
Yeah thats what I thought, trying get_channel_or_thread now
The problem is my thread is alr archived
channel = await self.bot.get_channel_or_thread(int(payload.data["id"]))
AttributeError: 'ModmailBot' object has no attribute 'get_channel_or_thread'
And yes I am on dpy2
it's discord.Guild.get_channel_or_thread not discord.ext.commands.Bot.get_channel_or_thread
so you should use a discord.Guild obj
oh
btw if I'm correct this will not resolve your issue
are you sure that archiving a thread fires on_raw_thread_update? could it fire on_raw_thread_delete? (I'm saying that coz archiving a thread is mentioned only in on_raw_thread_delete)
Yeah it fires update, I checked
The event is triggered
I have tried everything.. this close to giving up
This line does not work. Everything else works fine. No errors either
what's the output of print(r)? also have you tried to print out member? what's it outpu?
print(r) prints nothing which is weird
its guild.icon.url
prints nothing @glad cradle
try to print(type(r))
Nothing
then the else block is not triggered
It is. Because the reaction gets removed
or the emoji is not equal to what you're checking
Should be
ah
After hours of working like an ass...
Won't even print the test
it was weird
are you sure that the reaction is removed?
Yes
Just changed to this to see if the else statements were fucking it up. Still nothing
do you have other on_raw_reaction_add in your code/Bot?
This is in the main.py file, only other ones would probably be in cogs which shouldn't matter
But no there's nothing else in the main file
Try putting a print function on top to see if the event is actually being triggered
The event should be being triggered. The reaction gets removed, But I can try
Ok now I'm officially confused. Not printing still...
Do you have Intents.reactions enabled

ima try putting this in a cog and see if it changes
bump
@naive briar Still doesn't work in the cog
it matter
are you removing a reaction in the on_raw_reaction_add that's in your cog?
I even disabled the line where it removes the reaction and it still removes my reaction
This is so weird
that's coz you have another on_raw_reaction_add in your Bot that removes a reaction
you're missing self as the first arg...
Ok I fixed it. But no, that shouldn't have been the issue
And yeah lol, I realized that after I fixed my issue
ty guys for the help
My discord bot is refusing to work, all the code is correct and the bot turns on but the bot will not respond to its prefix
is it verified?
no?
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot 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
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
The intent message_content could be missing 
This not worked
embed1.set_image(url="attachment://sprites/mouse.jpg")
you can't have dynamic paths
I mean, other directories
You can have a look at their FAQ
https://discordpy.readthedocs.io/en/stable/faq.html#how-do-i-use-a-local-image-file-for-an-embed-image
it has to be in the root dir else there's no point.

How do I check on what someone has reacted with?
!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.
The discord.ui.button decorator shouldn't be there
Or you can pass it to get back to edit it later
@discord.ui.button(...)
async def vote(...):
pass
No its not lol
guys I need help
I got an error
nextcord.ext.commands.errors.CommandNotFound: Command "balance" is not found```
I was trying to do economy bot
!d discord.Guild.icon
property icon```
Returns the guild’s icon asset, if available.
!d discord.Asset.url
property url```
Returns the underlying URL of the asset.
Im using guild.icon_url in my code and it returns the url
Yes
I updated then vomited when i saw you can't start a client with a user token and went back to 1.7.3
Check ur intents
You need messages
Because you are trying to see message content
@scarlet sorrel know u how to add nd button
Nah bruh i wish
You what
You dont need an application cuh
You just need to add messages to your intents
No you don't
Just add it the exact same as the other intent
Just add it the exact same as the other intent
You said you already had an intent
That aint an intent cuh
Ask someone else im busy af
anyone know how to fix
for url2, price in data1.items():
RuntimeError: dictionary changed size during iteration```
happens when im doing `!remove` command which is
``` data.pop(url)
data1.pop(url2)```
ping me if you answer to this pls
Hey @slate swan! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me
Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!
anyone can help me?
import discord; from discord.ext import commands
bot = discord.Bot(command_prefix='$', activity="asd", status=discord.Status.online, intents=discord.Intents.all())
@bot.command(name="payments")
async def p(a):
await a.send(embed=discord.Embed(title="payments below").add_field(name="paypal", value="yourpp@domain").add_field(name="ltc", value="addy"))
bot.run('bot token')
What is the problem?
discord.Bot is not a thing, it's commands.Bot
It is, in pycord
isn't he using discord.py
It's still a thing lol
if he's using discord.py it's not a thing that package
You never specified it wasnt a thing in the discord.py library
Guys i have a bot.wait_for('message') in my slash command code
So how can I send message to comamnd user channel when someone sends message?
bot = commands.Bot()
And you do e = discord.embed(title="hi")
await send(embed=e)
how to reply to a message?
Pls help me anyone!!!!!!
!d discord.Message.reply
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 "discord.abc.Messageable.send") to reply to the [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "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 "(in Python v3.10)") or [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.10)") instead of `InvalidArgument`.
?
?
I want to send message 2 times when someone my slash command but i not able to
Response can only be given 1 time
Other one should be a normal msg
But i making a rpg game i want to take user input and send message many times
How to send normal message?
interaction.channel.send?
Take the input in slash command itself
Would work
No i have a battle type i want to take input from user like type 1 for attack
I don't understand, but you can have it in slash commands too
@app_commands.command(name="wild", description="start a wild battle.")
async def _wild(self, interaction: discord.Interaction):
user = await self.check(interaction.user.id)
if user == False:
await interaction.response.send_message("Ah! you have not started the game.\nPlease start by using `/start` command.")
else:
user_stats = await self.bot.stats.read(interaction.user.id)
user_hp = self.hp(user_stats.hp,user_stats.hp)
mouse_stats = self.mouse_stats()
mouse_hp = self.hp(int(mouse_stats[0]),int(mouse_stats[0]))
embed1 = Embed(
title=interaction.user,
description=f"**You**: {user_hp}\n```{user_stats.hp}/{user_stats.hp}```\n**Mouse**: {mouse_hp}\n```{mouse_stats[0]}/{mouse_stats[0]}```"
)
file = discord.File("sprites/mouse.jpg",filename="mouse.jpg")
embed1.set_image(url="attachment://mouse.jpg")
embed1.set_footer(text="Type `1` to attack,`2` to defend")
original = await interaction.response.send_message(file=file,embed=embed1)
alive = True
while alive==True:
mes = await self.bot.wait_for('message',check=self.mss)
if mes.content == 1:
await interaction.channel.send("attack")
elif mes.content == 2:
await interaction.channel.send("defenc")
When i send 1 my bot is not sending message
Do you know why?
Message content is a string and you are comparing it with an int
hello
does anyone know why this
its getting an error
it says that it doesnt recongize bot as a work or szmin
Please provide the full error and a better view of the code.
Command raised an exception: AttributeError: 'builtin_function_or_method' object has no attribute 'endswith'
you have any on_message event ?
oh you have to add 'await client.process_commands(message)' in the last of your on_message
it have to be the last thing in your event
What would be the check for the bot.wait_for in slash command?
how u define def like verify n all ?
Hey all.
me wondering why i cant use a discord server to host my discord bot and use the channels to run code and as a database
im prob gonna use some channels as a db tho, unlimited storage
What is the problem?
The first makes no sense
The second one is plausible but not really
Wait nope
was more of a joke
but it should be possible to use channels as a db
u can use messages and edit them or read files and reupload them
discord will rate limit the Bot
what does that mean
It's against TOS iirc
uni friends of a friend of mine made use of channels as a db lol
idk specifics
for text its obviously dumb, unless if its just files
also for images it would make sense
selfbots are against terms of service
you need to make Api calls to fetch and send message (with the given example to read and write data), discord could rate limit the Bot depending on the requests made to read/write data
oh ok but do you know a fix ?
not that im obliged to tell you
dont create selfbots
its for my own server could you please jsut help ?
wym?
oh yeah, its the issue
he wants a selfbot but bot isnt an arg for that function since selfbots got deprecated
Yeah nvm, i thought he passed bot=True but i looked closer and it was False
lmao
My vision is slowly deteorating
old human im joking ily
eye issue
🥲

think if i used your name i can cancel myself for objectifying women? 😌
salut les amis
No encapsulation or polymorphism 😦
lmaooo
bot.loop returns None
i'm pretty sure its an internal only attribute after 2.0 iirc
so I have a simple ban command
can you help me ?
I am a beginner in phthon
!d asyncio.get_event_loop
asyncio.get_event_loop()```
Get the current event loop.
If there is no current event loop set in the current OS thread, the OS thread is main, and [`set_event_loop()`](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.set_event_loop "asyncio.set_event_loop") has not yet been called, asyncio will create a new event loop and set it as the current one.
Because this function has rather complex behavior (especially when custom event loop policies are in use), using the [`get_running_loop()`](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_running_loop "asyncio.get_running_loop") function is preferred to [`get_event_loop()`](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_event_loop "asyncio.get_event_loop") in coroutines and callbacks.
Consider also using the [`asyncio.run()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.run "asyncio.run") function instead of using lower level functions to manually create and close an event loop.
Deprecated since version 3.10: Deprecation warning is emitted if there is no running event loop. In future Python releases, this function will be an alias of [`get_running_loop()`](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_running_loop "asyncio.get_running_loop").
async def ban(ctx, member: discord.Member) how can I also allow this to accept an ID of the user
bot.pool return None
wait what
i was viewing the wrong thing again😭
hawk eyes
can you help me ?
I am a beginner in phthon
member: Union[discord.Member, int]
you should sleep
How do I replace numbers with words?
It's 10am, my sleep schedule is quite good
then enjoy the headache
do i import union
from typing import Union
or iirc with python >=3.9 you could just do member: discord.Member | int
sassy, smh not even "i hope you get better"
3.10*
now it says int object has no attribute "ban"
when do member.ban()
You should annotate the member argument with discord.Member only as the converter can do object conversion if a snowflake is passed then you can use the method on the local variable
huh
I hope you get better

take crack if it's too painful
⁉️
hey guys anyone interested in helping me to add economy to my bot?
oh yh true
Hi
So I want that if people will get a different role when the boost the server
for guild in bot.guilds:
for member in guild.members:
role = get(guild.roles, id ="1017155420550344808")
if str(1017155420550344808) in str(member.roles):
if str(member) not in booster["booster"]:
booster["booster"].append(str(member))
print(booster["booster"])
print(booster)
await member.add_roles(role)
with open("boosters.json", "w") as outfile:
outfile.write(json.dumps(booster, indent=4))
else:
if str(member) in booster["booster"]:
print(str(member))
booster["booster"].remove(str(member))
await member.remove_roles(role)
with open("boosters.json", "w") as outfile:
outfile.write(json.dumps(booster, indent=4))```
atm I have this
but it gives a error :/
role is None
for guild in client.guilds:
await guild.ban(user, reason=reason)
not sure why this isnt working
ids are int, not str
alr got it from internet
^ anyone know??
error?
Is that a nuke bot 👀
its just kicking a user from all the servers
as soon as it gets to guild.ban it doesn't work
im confused bc it was working just fine like a few days ago
well then the bot doesn't have perms to ban the user
or actually, the user is not in the server
it has admin as soon as it joins servers tho
or already banned
so if its banned in even 1 of the servers it wont work?
U gotta use a try except
can u show me?
can i edit field at 1 ? in embeds ?
How would I get all the roles in the guild?
!d discord.Guild.roles
property roles```
Returns a sequence of the guild’s roles in hierarchy order.
The first element of this sequence will be the lowest role in the hierarchy.
Well, to be exact they are represented as snowflakes in discords documentation, snowflakes being unique ints, but yeah you arent wrong but you arent right either
Snowflakes are int, when talking in Python's context, so no idea why u think I am neither right
Weirddd
You need make an instance of Warn. Right now you are just passing the class in. It should be Warn() not Warn
They are, but i ment an entities ID in discords documentation is referred to as a snowflake, a snowflake being a unique int
how are you now
guys how do you make this type of block of code?
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
This is not a Modmail thread.
I'm fine, just eat breakfast kek

select is an interaction object, just switch around select and interaction
I ment in your functions parameters!
Sry, I'm speaking german.
Now I understand.
how to make smth like this?
!d discord.ui.Button.url
property url```
The URL this button sends you to.
thamks
I tried it to fix it
The errror won't be gone.
Maybe I'm just stupid rn but here is the code if that's okay
Code:
class MySelect(View):
@discord.ui.select(
placeholder="Choose an option",
options=[
discord.SelectOption(label="Moderation", value="1", description="View the moderation commands."),
discord.SelectOption(label="User", value="2", description="View the user commands."),
discord.SelectOption(label="Music", value="3", description="View the music commands.")
]
)
async def select_callback(self, interaction, select):
select.disabled=True
if select.value[0] == '1':
em = discord.Embed()
em.add_field(title="RNG Moderation Commands", value="Comming Soon.", inline=False)
await interaction.respose.send_message(embed=em)
if select.value[0] == "2":
em2 = discord.Embed()
em2.add_field(title="RNG User Commands", value="Comming Soon.", inline=False)
await interaction.response.send_message(embed=em2)
if select.value[0] == "3":
em3 = discord.Embed()
em3.add_field(title="RNG Music Commnads", value="Comming Soon", inline=False)
disabled=True
oh I misread
am sleepy, it's dropdown
It's not here but maybe there is a way
afaik, you cannot disable a specific option in dropdown
So what it says are the only options that can be used in select.Option?
yes
thanks i never understood how these docs work
how do I load extensions with discord.Client? I've always been using discord.ext.commands.Bot but I'm re-writing to slash commands so I use the client instead
discord.Client doesnt have modular extensions
yeah I read the docs
how am I supposed to use cogs then? I don't wanna write each and every command on 1 file
do I just use discord.ext.commands.Bot anyways?
If you want Cogs and other abstractions, yes
k, thx
and how can i turn custom_id into label to add a custom answer depending on what you click?
where are you defining bot.pool?
for guild in client.guilds:
await guild.ban(user, reason=reason)
anyone know whats wrong with this?
how's this looking 
looks a bit empty and everything is in one spot maybe disperse each element
disperse?
Yes?
more padding between elements or?
someone please help
bot = commands.Bot(command_prefix='$', activity="asd", status=discord.Status.online, intents=discord.Intents.all())
File "C:\Users\Travis\PycharmProjects\MainAttempts\venv\lib\site-packages\discord\ext\commands\bot.py", line 171, in __init__
super().__init__(intents=intents, **options)
File "C:\Users\Travis\PycharmProjects\MainAttempts\venv\lib\site-packages\discord\ext\commands\core.py", line 1265, in __init__
super().__init__(*args, **kwargs)
File "C:\Users\Travis\PycharmProjects\MainAttempts\venv\lib\site-packages\discord\client.py", line 253, in __init__
self._connection: ConnectionState = self._get_state(intents=intents, **options)
File "C:\Users\Travis\PycharmProjects\MainAttempts\venv\lib\site-packages\discord\client.py", line 284, in _get_state
return ConnectionState(dispatch=self.dispatch, handlers=self._handlers, hooks=self._hooks, http=self.http, **options)
File "C:\Users\Travis\PycharmProjects\MainAttempts\venv\lib\site-packages\discord\state.py", line 207, in __init__
raise TypeError('activity parameter must derive from BaseActivity.')
TypeError: activity parameter must derive from BaseActivity. ```
this my error
@bot.command()
async def ping(ctx):
await ctx.channel.send("pong")
@bot.command()
async def print(ctx, arg):
await ctx.channel.send(arg)
bot.run('insert token here') ```
this my code
more space between each one
so its not so crowded
how do i check if a user is banned (for my user info command)?
# Move
async def move(self) -> None:
# Integers
Y_INCREMENT, X_INCREMENT = self.TRANSLATIONS.get(self.direction, (0, 0))
Y_HEAD, X_HEAD = self.head
# Adjust tuples
self.head = (Y_HEAD + Y_INCREMENT, X_HEAD + X_INCREMENT)
# Loss detection
if self.head in self.tail or self.head[0] < 0 or self.head[0] > self.COLUMNS - 1 or self.head[1] < 0 or self.head[0] > self.ROWS - 1:
self.halt = True
return None
# Win detection
if self.score == (self.COLUMNS * self.ROWS) - 1:
self.halt = True
return None
# Tail management
if len(self.tail) > 0:
self.tail.pop()
self.tail.insert(0, self.previous_head)
# Apple eating
if self.apple == self.head:
self.generate_apple()
self.tail.insert(0, self.previous_head)
self.score += 1
self.previous_head = self.head
# Post
await self.post(edit = True)
I made snake on discord, and I feel like some logic for the apple eating is messed up.
I'm not sure what, but it does not feel right at all.
@bot.command()
async def ping(ctx):
await ctx.channel.send("pong")
@bot.command()
async def print(ctx, arg):
await ctx.channel.send(arg)
bot.run('insert token here') ```
someone please help, this is my code that i have.
```File "C:\Users\Travis\PycharmProjects\MainAttempts\PikleDiscordBot.py", line 8, in <module>
bot = commands.Bot(command_prefix='$', activity="asd", status=discord.Status.online, intents=discord.Intents.all())
File "C:\Users\Travis\PycharmProjects\MainAttempts\venv\lib\site-packages\discord\ext\commands\bot.py", line 171, in __init__
super().__init__(intents=intents, **options)
File "C:\Users\Travis\PycharmProjects\MainAttempts\venv\lib\site-packages\discord\ext\commands\core.py", line 1265, in __init__
super().__init__(*args, **kwargs)
File "C:\Users\Travis\PycharmProjects\MainAttempts\venv\lib\site-packages\discord\client.py", line 253, in __init__
self._connection: ConnectionState = self._get_state(intents=intents, **options)
File "C:\Users\Travis\PycharmProjects\MainAttempts\venv\lib\site-packages\discord\client.py", line 284, in _get_state
return ConnectionState(dispatch=self.dispatch, handlers=self._handlers, hooks=self._hooks, http=self.http, **options)
File "C:\Users\Travis\PycharmProjects\MainAttempts\venv\lib\site-packages\discord\state.py", line 207, in __init__
raise TypeError('activity parameter must derive from BaseActivity.')
TypeError: activity parameter must derive from BaseActivity. ```
this is the error i keep getting
activity can't be just a string, it needs to be some form of Activity object
For example
!d discord.Game
class discord.Game(name, **extra)```
A slimmed down version of [`Activity`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Activity "discord.Activity") that represents a Discord game.
This is typically displayed via **Playing** on the official Discord client.
x == y Checks if two games are equal.
x != y Checks if two games are not equal.
hash(x) Returns the game’s hash.
str(x) Returns the game’s name.
you can find more Activity stuff in the docs
https://discordpy.readthedocs.io/en/stable/api.html?highlight=activity#discord.Activity
It's not required
ok
thanks
oh yeah one more thing
async def ping(ctx):
await ctx.channel.send("pong") ```
this sends a message in chat right? how would i make it send multiple times?
@bot.command()
async def ping(ctx):
await ctx.channel.send("pong")
await ctx.channel.send("pong")
await ctx.channel.send("pong")
await ctx.channel.send("pong")
await ctx.channel.send("pong")
...
thats it?
You can call send as many times as you want in the function
or do
for i in range(amount):
#do sum```
<button class="product-card__variant" data-variant="39253396095104" js-quick-add="" data-upsell="mens" aria-label="Add Variant">7</button>
how to retrieve the data variant?
can you give me an example? so like using that to print something
!e
for _ in range(6):
print("Hello World!")
@primal token :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | Hello World!
002 | Hello World!
003 | Hello World!
004 | Hello World!
005 | Hello World!
006 | Hello World!
yas
why do u need to use the function names like on_message and not ur own function?
If you use Bot.listen then you can use ur own function name but the library needs to be able to know what event the function is for
Because @client.event overrides internal methods of the bot, on_message is called when there is a message, so overwriting on_message lets you do your own thing
This also means you can only have one client.event for each even, as they overwrite eachother
how would i send embeds using interactions.py
Could someone help me with a project that I have on discord to create a bot for betting coins, games, among others, I need to help, thank you very much
I need someone who has ideas to be able to help me better
-Traceback (most recent call last):
- File "main.py", line 4, in <module>
- client = discord.Client()
-TypeError: __init__() missing 1 required keyword-only argument: 'intents'
i get this error
i can show the code
Intents is required on version 2 or above
intents = discord.Intents.default()
intents.typing = False
intents.presences = False
do i just use that
LGTM
.
async def timeout(ctx, member: discord.Member=None, time : int,*, reason=None): getting error of non defauly arguement at time followes a default arguement
Did u fix the issue?
Help me pls
async def timeout(ctx, time: int, member:discord.Member=None, *, reason=None)
I dont want the member as comoulsory
Then do that
What I sent
it still doesnt work
Guys is it possible to host discord bot on netlify?
no, Netifly is used to host webpages
hello how do i make a slash command bot send my embed?
hello how do i make a slash command bot send my embed?
Is there any free host service with 1gb storage?
How to get the list of banned members in a server
interaction.response.send_message(embed = embed)
thanks
interaction is not defined
How do i calculate number of banned members in a server
whats your current code
send me what you have so far
@slate swan no code i want that for my server info command
intents = discord.Intents.default()
intents.members = True
bot = discord.Bot(intents=intents,command_prefix='!')
@discord.ext.commands.guild_only()
@bot.slash_command(name="mines", description="game")
async def mines(ctx, server_hash):
round_id = str(server_hash)
round_length = len(server_hash)
if round_length < 64:
await ctx.respond(embed=discord.Embed(description="**invalid.**",color=FF0000))
elif round_length == 64:
sleep(5)
ctx?
yea
has this worked tho?
isnt ctx only for . ?
what
shouldnt it be interaction: discord.Interaction
where?
replacing the ctx
lemme try'
like that?
is server hash an integer btw?
integer? i dont understand
oh yea
where you have server_hash replace it with server_hash: str
and then change the ctx.respond with interaction.response.send_message
and see if that works; please mind me i dont use discord.py
okay
lemme try
len(await ctx.guild.bans())
Code:
@discord.ui.button(label="Mars", custom_id="Mars", style=discord.ButtonStyle.blurple)
async def planet4(self, button: discord.ui.button, interaction: discord.Interaction):
await interaction.response.send_message("You've chosen the 4th planet, Mars")
self.value = None
self.stop
Error:
line 99, in planet4
await interaction.response.send_message("You've chosen the 4th planet, Mars")
AttributeError: 'Button' object has no attribute 'response'
so I was using the music bot example with the help of wavelink, mentioned in the docs of Pycord, I setup a lavalink server and all, but everytime the command is executed I get this error
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: ', url=URL('my lavalink server url with song name ')
google says it's because no output is being passed?
relevant links:
https://guide.pycord.dev/voice/playing
any help would be appreciated
Pycord and Wavelink try to keep the playing of audio as simple and easy as possible, to keep making Discord
put the interaction: discord.Interaction before button: discord.ui.button and see if it works
interaction.response.send_message(embed=em)
RuntimeWarning: coroutine 'InteractionResponse.send_message' was never awaited
k, let me try that
await interaction.response.send_message
sigh
you should know this?
Traceback (most recent call last):
File "C:\Users\i\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 1009, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\i\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 359, in invoke
await injected(ctx)
File "C:\Users\i\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 135, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction
@slate swan tbh i suggest you look throught the docs and look at a few examples like https://github.com/Rapptz/discord.py/blob/master/examples/app_commands/basic.py
looks like copy paste code
ye
@slate swan go watchs yt tutorial or sumtin or read the docs
think you could help me with this?
im not got with music stuff
oh alr
is that daki
i was asking where were you writing your code
would I be using custom_ids from buttons to store a specific data for sending something related to that button and it varies.... If yes is this how I would store a custom_id, for a planet selected from a button(using python 3.9x and aiosqlite):
db = await aiosqlite.connect('player_data.db')
await asyncio.sleep(2.5)
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS planet(user_id, planets_id)")
await db.commit()
async def planets(user):
db = await aiosqlite.connect('player_data.db')
async with db.cursor() as cursor:
await cursor.execute("INSERT INTO planet VALUES(?, ?)", (user.id, custom_id,))
await db.commit()
return
``` and so on...
store the planet name not the button id lol
ohk, lol how would I do that, like give me a rough idea or smth(sry I suck...)
button.label ?
ohk, lol
if you have a credit card, sure
you can use aws or Google cloud
or sarth'll host it for you but will need your cc
💃 I can't even run myself rn, imagine running a python file
erro?
error*
@slate swan are u working on a counting system?
maybe use a json file to update the counting numbers
like for every msg it checks whether that number is right and then it updates in json file
idk I'm kinda new to python
wait
u use SQL?
hm ur right
what abt the indentations
can u show from the starting of the event
If i use termux is it possible to run my bot 24/7 on my device?
Hey!
I have a role info command i am trying to make:
Code:
embed.add_field(name="Who has the role", value=role.members, inline=False)
embed.add_field(name="Permissions", value=role.permissions)
But this is what it displays:
[<Member id=755155481458114630 name='api' discriminator='0002' bot=False nick=None guild=<Guild id=1009090888997281872 name="Carti's Studio" shard_id=0 chunked=True member_count=8>>]
Permissions
<Permissions value=1071698660937>
I want it to Ping who has the role, and say what permissions it has not the value
smth like this?
https://pastebin.com/07PZdD3Q
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
role.members returns a list of Member objects who have that role
is there a way to make it so it returns the pings of the peopel who have that role
you could do smth like
", ".join([member.mention for member in role.members])
and in the discord client, you'll see something like
@member1, @member2, @member3, so on```
idk how permissions values are resolved so cant help much with thay
Where would i put ", ".join([member.mention for member in role.members])?
in the place of
role.members
value=", ".join(...)```
thank you<3
???
why i have error?
i need help
Hey!
I am trying to make an afk command
Code:
https://hastebin.com/orocebozow.py
I want it so, if someone is afk, and someone pings them it responsds with this user is afk
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
which theme so colourful?
I will tell you in a moment and you are able to help me?
what does the error say?
tabs error
Hey @slate swan!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
mix of spaces and tabs?
where i used this?!
can u change code to correct and send me? I dont see spaces and tabs in one line
@shrewd apex
That could happen when the discord.Intents.guilds is disabled or the message is sent in DMs
Before you do anything that requires guild, you have to check if message.guild returns None
If you want to
sure
any1 can help with discord.ext.commands error?
What's the error
sending ss wait
btw any1 can help me with requests?
why?
@shrewd apex
that's my theme
help
@naive briar
if i want to do an if for each message then how do i do it?
if self.values[0] == 'say':
await interaction.response.send_message("say")
if self.values[1] == 'ban':
await interaction.response.send_message("ban")
if self.values[3] == 'kick':
await interaction.response.send_message("kick")
etc```
That would cause an error since if the message was sent in DMs, the message.guild would return None. I'd say just return it if the guild was None and if your on_message event is only for afk things
async def on_message(message):
...
if not message.guild:
return
...
help
The command lookup did not exist
Guys i want to make a level system in my discos bot Rpg
I already have a exp system
I want that like when user have more than 100 exp he reached level 2 and level 3 on 200 exp and level 4 on 400 exp and vice versa
Can anyone help me how to can i it?
It would be a nightmare for me to make if else statements for 100 levels
The error doesn't lie
I'm not sure what your on_message event has, but I think you should put that above the line that you're trying to get guild from the message
Pls help anyone
I'm using hikari slash commands library and people can use / commands in the bots direct messgaes, how could i disable that?
I have once made a afk command you can see that to take idea
member.avatar.url
you define member as membre right?
membre.avatar.url
try this
Which part of it? I don't know how your AFK system works
Are you using a database?
you never define the format
the data_format
try something like that
member.joined_at.strftime("%d/%m/%Y %H:%M:%S"))
no
what version you are using? the new one right?
idk this. in new discord version we have theses changes
avatar_url -> avatar.url
avatar_url.read() -> avatar.read()
avatar_url_as() -> avatar.replace()
send the code again sir
I honestly don't know what is wrong here, since I pretty much don't know how your AFK welcome back thingy works. Sorry if I can't help
wanna see my userinfo command?
and do your changes because im coding something else now
# ----------------------------------------------------
# USERINFO - COMMAND
# ----------------------------------------------------
@commands.command(aliases=['Userinfo', 'User', 'user', 'USERINFO'])
@commands.has_permissions(administrator = True)
async def userinfo(self, ctx, member : discord.Member):
accountage = (discord.utils.utcnow()) - (member.created_at)
time = int(accountage.total_seconds())
day = time // (24 * 3600)
time = time % (24 * 3600)
hour = time // 3600
time %= 3600
minutes = time // 60
time %= 60
roles = [role for role in member.roles[1:]]
embed = discord.Embed(colour=member.color, timestamp=ctx.message.created_at)
embed.set_author(name=f"{member.display_name}#{member.discriminator}", icon_url=member.avatar.url)
embed.set_thumbnail(url=member.avatar.url)
embed.add_field(name="**Όνομα Χρήστη:**", value=f'{member.mention}')
embed.add_field(name="Ημερομηνία δημιουργίας λογαριασμού:", value=member.created_at.strftime("%a, %#d %B %Y, %I:%M %p UTC"), inline=False)
embed.add_field(name="Ημερομηνία Συμμετοχής: ", value=member.joined_at.strftime("%a, %#d %B %Y, %I:%M %p UTC"))
embed.add_field(name="Διάρκεια Λογιαριασμού:", value=f"{day} Ημέρες, {hour} Ωρες, {minutes} Λεπτά", inline=False)
embed.add_field(name=f"Ρόλοι [{len(roles)}]:", value=" ".join([role.mention for role in roles]))
embed.add_field(name="Top role:", value=member.top_role.mention, inline=False)
embed.set_footer(text=f"ID: {member.id}", icon_url=ctx.author.avatar.url)
await ctx.send(embed=embed)
Can you be more specific
that's slash command i user can select channel to send his message.
Few things wrong
You're accessing the context channel anyway, which isn't the specified "kanal"
Secondly, you're using the * operator to denote the "text" attribute as filling the remaining slots
The kanal arg cannot be set regardless of input
The parser greedily consumes remaining arguments indiscriminately and sets them all to text
I am trying pycord and the code is working but only sometimes. BUT
Sometimes it shows the Commands in discord
Sometimes it shows them without description or it shows the description only the first time using it
Sometimes it shows them and after using them they disappear
And Sometimes it doesn´t show the Commands at all
Has anyone a clue what could be the issue. I used the bot token before with discord.py and that might cause some issues but that is the only thing i can think of but maybe one of you has an Idea. Thanks in Advance
The token being used with d.py shouldn't be an issue but there could be leftover registered commands
I'm not familiar with pycord but they should have a flush function somewhere that clears the bot tree
Ok thank you i look for sth like that
Guys i want to make a level system in my discos bot Rpg
I already have a exp system
I want that like when user have more than 100 exp he reached level 2 and level 3 on 200 exp and level 4 on 400 exp and vice versa
Can anyone help me how to can i it?
It would be a nightmare for me to make if else statements for 100 levels
Bro you need to define index first before adding value to it
msg = await ctx.send(content="**🎉 GIVEAWAY 🎉**", embed=embed1)
await msg.add_reaction("🎉")
await asyncio.sleep(timewait)
message = await ctx.fetch_message(msg.id)
for reaction in message.reactions:
if str(reaction.emoji) == "🎉":
users = await reaction.users().flatten()
print(reaction.users())
'async_generator' object has no attribute 'flatten'
Pls help me anyone
Do some math
level = exp / 100
and update the level only if exp / 100 % 1 == 0
That ik but i need to make that for 100 levels and that's a headache
You mean that if level is 3 user needs 300 exp? Right?
If user exp reached 101 what will happen?
Nothing will happen because of the if statement
Won't user reach level 1?
No
If the user is already level 1, but he gains 1 exp, nothing will happen
for every 100 exp they will gain level
I want that if user reaches like level 4 it should need 800 exp for level 5