#General Help
1 messages Β· Page 23 of 1
update
it's updated, I created a new project to make sure everything is stable
it's in my venv
What DB do you use?
postgres
my interpreter is in my venv, everything is fine, but the packages installed in my venv aren't recognised
nice :))
not able to help u srry, but ik a venv is a virtual enviroment, but whats it used for
@midnight cedar
it's up to you
I mean whats simpiler? (but still got pleanty use)
it's to separate packages from different projects, for exemple, if you just install your packages without in a venv, it will install them generally on your computer, if you install them in a venv, it will just be installed in the venv, this provides the possibility to use different packages versions for each projects and not to have 1000 packages that are installed on every projects
mongo is similar to json
i think it actually uses something called bjson
or jsonb
postgres is an SQL standard db
so whats more simple (lol)
couldn't tell you
never used mongo
from what i've seen though
sql queries make more sense
mongo is basically just json structured documents
no relational fields at all so its not suitable for that application
Might give postgres a go ig
Why does this happen? It has worked in other embeds
suggest = discord.Embed(title=f"Suggestion by {interaction.user} Under Review <@&988496229229002792>)``` (Theres more code in that line but dosent need sent)
are you mentioning a role?
Yeah, Is it cause its in the title?
mentions dont work in titles
You can use the description as a title, then use embed.add_field() to add the description
alr
I mean it did ping it, but i renembered roles wont actualy ping in an embed (I am trying to ping for a suggestion), How would i add a normal message just above the embed with the ping
just ctx.respond?
await ctx.respond("message here", embed=embed)
ty
async def callback(self, interaction: discord.Interaction):
m = await interaction.response.send_message("Suggestion send!", ephemeral=True)
suggest = discord.Embed(title=f"Suggestion by {interaction.user} Under Review ",color=discord.Color.blue())
suggest.add_field(name="Your Suggestion: ", value=self.children[0].value)
suggest.set_footer(text=f"Message id: {m.id} ")
channel = self.bot.get_channel(987396375069224960)
embed = await channel.send(" Ping: <@&988496229229002792>", embed=embed)
await embed.add_reaction('β')
await embed.add_reaction('β')```
Connected to bot: FelBot
Ignoring exception in modal <Modals.Suggestions.Suggestions object at 0x00000212475EAB60>:
Traceback (most recent call last):
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ui\modal.py", line 260, in dispatch
await value.callback(interaction)
File "C:\Users\jackd\Documents\Felbcord Py\Modals\Suggestions.py", line 18, in callback
await embed.add_reaction('β')
UnboundLocalError: local variable 'embed' referenced before assignment
why do i get this error?
i dont see embed being used before it
you named
your embed
suggest
it should be embed=suggest
Hey, any ideas why this is not recognised?
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="-", intents=intents)
intents.message_content = True
AttributeError: 'Intents' object has no attribute 'message_content'
what pycord version you on?
the last one, I installed it via pip install -U pycord
should I use the pre version?
uh
yeah, strange error
I don't get why
did you intall this
lol
?tag install
-
Uninstall
discord.pyor any other forks of discord.py you might have with the namespacediscord.
python -m pip uninstall discord.py discord -y -
Install
py-cord
python -m pip install py-cord
Installing other builds:
Note: You need to have git installed. Use !git to find out how to install git.
Updating the module to Alpha (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord
Updating to release candidate:
pip install py-cord==2.0.0rc1
i'll try this
nope, followed the docs
@slender lintel
but you said you did
pip install -U pycord which is not py-cord
also the normal py-cord
is version 1.7.3 I think
BRUH
yeah
u right
π
just forgot the -
@slender lintel should I use the 2.0.0 version?
I get an other error if I install pip install py-cord==2.0.0rc1
but if I don't use it, the other error appears again

what error you get?
this is not recognised if I use it
limit=60000
well it's recognised but:
guys how can make a response that only the ctx author can see?
what is your on_ready code?
ephemeral=True
oh ok, thanks
@slender lintel now messages is not recognised
should I try with something else than on_ready?
async for message in channel.history(limit=60000)
still not works, every message is not recognised if I don't import it
no no
I need message.embed because they are embeds
I need to check embeds
no no no no
OH
ok
I'm dumb
sorry
ok
was going to explain but if you got it π
other error now, sad
?
@slender lintel
@slender lintel
BRUH
ok know I gotta concentrate
π
@slender lintel Thanks for your help
I got another error but I'll find it by myself
Gl
Anyone know why my task is not starting? I have all imports correct, not getting any errors with it either. Tried looking it up, but can't find the reason it isn't running.
['cogs.moderation', 'cogs.events']
Traceback (most recent call last):
File "C:\Users\maksi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 727, in _load_from_module_spec
setup(self)
File "d:\Desktop\peer\cogs\events.py", line 19, in setup
client.add_cog(events(client))
File "C:\Users\maksi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 597, in add_cog
raise discord.ClientException(f"Cog named {cog_name!r} already loaded")
discord.errors.ClientException: Cog named 'events' already loaded
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "d:\Desktop\peer\bot.py", line 34, in <module>
client.load_extension(cog)
File "C:\Users\maksi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 787, in load_extension
self._load_from_module_spec(spec, name)
File "C:\Users\maksi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 732, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.events' raised an error: ClientException: Cog named 'events' already loaded
Code:
cogs = []
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
cogs.append("cogs." + filename[:-3])
print(cogs)
if __name__ == "__main__":
for cog in cogs:
client.load_extension(cog)
Had this problem a few days ago
and i still havent figured out how to fix it
Oh god, I had this and It was a pain to fix because trying to fix it I made it 100x worse but I forgot how to fix it lol
oof
Anyone has an idea of how I could get this working? It's currently not finding any, even if I put some messages with the right regex in the channel
token_regex = re.compile(r'/[\w-]{24}\.[\w-]{6}\.[\w-]{27}/')
@bot.event
async def on_ready():
print("bot connected")
channel = bot.get_channel(988378560249090119)
embed = ""
async for message in channel.history(limit=60000):
if token_regex.search(message.content) in message.embeds:
embed = message.embeds[0].description
log = "{0.content}{1}".format(message,embed)
print(log)
is it possible to take a file as a argument for a slash command ?
examples/app_commands/slash_options.py lines 49 to 65
@bot.slash_command(name="attach_file")
@option(
"attachment",
discord.Attachment,
description="A file to attach to the message",
required=False # The default value will be None if the user doesn't provide a file.
)
async def say(
ctx: discord.ApplicationContext,
attachment: discord.Attachment,
):
"""This demonstrates how to attach a file with a slash command."""
if attachment:
file = await attachment.to_file()
await ctx.respond("Here's your file!", file=file)
else:
await ctx.respond("You didn't give me a file to reply with! :sob:")```
examples/app_commands/slash_options.py line 4
from discord import option```
this is option btw
thank you !
I see option is very usefull !
file?
yes
So you want the app commands in that file only register in that guild, or only outside of that guild?
so i type in .disable fun and it make the fun cog isn't warking for the guild
well, you can store the guild id in your db and check if the guild is in there each time a command runs
if it is, then return
else, don't
ok and is there a way that isn't that much elaborate
well, it should be stored persistently, right?
instead of using database, textfiles are fine until they become too long
oh, in that case
custom checks are great
and is there a event to check that?
Hello
Hi guys i have a question. How can i check if the member from e.g. /userinfo [MEMBER] is a real member e.g. if someone types /userinfo blabdfhbsd how can i check if thats a real member and send a message saying smth like "That member is not a real User"
Does user command work in cogs?
Yes (i code with him)
There's plenty of regexes.for discord tokens online
How do i fix pip? (Pip is not a reconized script)
Is there a maximum number of pages for the paginator ?
yes this is the right regex but loop is not working
try using python3 pip ...
yeah thats what i use, but pip should be working
Is there any way?
Confused by what you're asking. You are trying to show real members in comparison to what?
@dawn wagon you can just use
if message.author == client.user:
return
if message.author.bot: return (smth like this)
If you are using slash commands you can use options to make it only possible to pass real users.
user: discord.User should work iirc
Using prefix commands you could fetch the user and catch the error.
member: Option(discord.Member)
if the above does not work
hi i need some help what am i doing wrong here ?
class Help(commands.Cog):
""" A collection of the commands for moving the bot around in you server.
Attributes:
bot: The instance of the bot that is executing the commands.
"""
def __init__(self, bot):
self.bot = bot
class Select(discord.ui.Select):
def __init__(self):
options=[
discord.SelectOption(label="Option 1",emoji="π",description="This is option 1!"),
discord.SelectOption(label="Option 2",emoji="β¨",description="This is option 2!"),
discord.SelectOption(label="Option 3",emoji="π",description="This is option 3!")
]
super().__init__(placeholder="Select an option",max_values=1,min_values=1,options=options)
@commands.slash_command(name = "help", description= "Shows Help Message", Guild_ids=config.Guilds, pass_context=True, hidden = True)
async def Help(self, ctx):
await ctx.send("Menus!",view=Select())
def setup(bot):
bot.add_cog(Help(bot))
its inside a cog
and i want to use a drop down menu with my help command
so i can select the help category
but its not working
how can i get the application commands of my bot? i tryna see the ids so i could manually delete 2
huh
What "is not working"?
ctx.send sends a message instead of responding to a slash command
You should use ctx.respond
I think your issue is that you are not passing a View but rather a select this should be an easy fix. In your command you can create a view view = discord.ui.View() than add your select to the view
with View.add_item(Select()) than view=view
You also should not name your select class Select as it might override things unexpectedly. You could name it something like HelpSelect
ice do u know how to fix that?
import requests
from pprint import pp
spooky_id = "939049331586113566"
token = "shhh"
header = {
'Authorization' : f'Bot {token}'
}
requests.get(f'https://discord.com/api/v9/applications/{spooky_id}/commands', headers=header)
r is a response object.
https://www.w3schools.com/python/ref_requests_response.asp
I think you want the content attribute
Also, just want to make sure. Pycord does all that for you. (Are you are making your own wrapper?)
no, what im trying to do is to get all my current application commands so i can delete 2
manually delete 2
using this
im just trying to get the application command id
With pycord? or with HTTP?
You can access all endpoints available to bots via pycord methods
all im trying to do is to get my application command id... π
could u tell me how it could be done using pycord?
Actually you would want this
https://docs.pycord.dev/en/master/api.html?highlight=remove_app#discord.Bot.remove_application_command
name like /hello would be hello
Normally API calls in on_ready breaks things but it should be fin if you are doing it once and than removing the code
as long as its not perminate code
on_connect is better for that iirc
thanks ill try that
yes long time ago x)
if yes then just do
await spooky.sync_commands(force=True)
specify the guild ID in the remove... function
Are cogs more memory efficient than pasting all the commands in one file (another info on separate)
@reef dove
wait is a tortoise error
o ok
Yeah try what Xout said
i just get a confudes by this part than add your select to the view
with View.add_item(Select()) than view=view
Im not sure about memory but they have a few perks
You can load/unload cogs while your bot is running opposed to commenting out a command and restarting your bot
Its a lot easier to read your code because it is not thousands of lines
They can handle errors locally
Iβve got limited ram even though itβs free for other hosts you require to send in personal details which Iβm not a fan of
60mb ram π
so you created your view you need to add the select item to the view
You than send the view instead of the select
i now have this
class HelpSelect(discord.ui.Select):
def __init__(self):
options=[
discord.SelectOption(label="Option 1",emoji="π",description="This is option 1!"),
discord.SelectOption(label="Option 2",emoji="β¨",description="This is option 2!"),
discord.SelectOption(label="Option 3",emoji="π",description="This is option 3!")
]
super().__init__(placeholder="Select an option",max_values=1,min_values=1,options=options)
@commands.slash_command(name = "help", description= "Shows Help Message", Guild_ids=config.Guilds, pass_context=True, hidden = True)
async def Help(self, ctx):
view = discord.ui.View()
await ctx.respond("Menus!",view=view)
this is what you meant right ?
because idk where you said to put the View.add_item(Select())
after you create your view
@worthy basin do u have sql / tortoise knowledge? im having a bad issue with my models ;/
I have 0 knowledge of them but I can maybe help :P
I believe
After you create the view you need to add the item.
Very little but I somewhat understand DBs
@commands.slash_command(name = "help", description= "Shows Help Message", Guild_ids=config.Guilds, pass_context=True, hidden = True)
async def Help(self, ctx):
view = discord.ui.View()
options = View.add_item(Select())
await ctx.respond("Menus!",view=view)
like so ?
No like this
view = discord.ui.View()
view.add_item(HelpSelect())
await ctx.respond("Menus!",view=view)
The 2nd line takes the View object you just created and ands your select to an internal list of items so when you send a view It sends all the items attached to it
Correct me if Iβm wrong but didnβt the highlighted one need changing?
let me check
yes antinuke models issues...
Since in the view variable he needs to reference the class
aaah okey sorry my bad
but now HelpSelect is yello
I dont think so.
discord.ui.View() creates a default view and assigns it the the view varible
fixed the db.. sorry about that
whats it say when you hover over the yellow line?
why is HelpSelect inside your Cog?
but since it is
or self.HelpSelect() I think actually
wait
no hm
what Xout said
also your help select __init__ function is indented once to many
Also, I have a command that is able to change cooldown depending on the users interaction, how would I make sure that the command uses the new cooldown value?
helpselect is not defined pylance
The command gets the cooldown via a file and casts it to int
cause i am using cogs
self.HelpSelect() does resolve it being yellow
π
it now posts
but if i select a option it does nothing
and says This interaction failed
Here's the dropdown example.
^ Look at this example. Please
i don't think that on ready worked to delete the cmd
do you have another code running with the same token that is using an old script?
nope
You might have to create your own cooldown Object for the command im honestly not sure how to d othis
i will try to do it in the cog..
The only problem is that the command uses the cooldown value assigned to it during the start of the script and not the values after it which is frustrating
Is the cooldown decided after the command comes to completion?
Yes
str? don't they ask for the name of the cmd?
Iβll try it with dynamic cd tomorrow
I guess you need to get the comand first and pass the object
Iβll let you know if itβs working when I see online
how could i do that?
await exp cannot be used cuz "None Type"
lol
alr woolfy cya
wait is not a coroutine
btw why the label on :onpage doesnt changed when :before button pressed?
you have to also edit the view
await interaction.response.edit_message(embed=embed, view=self.view)
oh ok
ok i got it
guys, is there a way to add checks to slash commands?
if i try to manually assign like:
@slash_command(checks=[check1, check2])
async def ...
this isn't actually working
..and i can't find any docs about this
using the regular discord.ext.commands checks also work
wow really?
thanks
as i said
that not seems working
I'm trying to nest dictionaries into a tree and i cant figure out how to do it
basically if I had a list with ["a", "b", "c"]
I want to nest it into {"a": [{"b": [{"c": []}]}]}
would anyone know how to do this
nvm i figured it out
Are there any examples on how the forms work?
nvm think i found, it goes by a different name
[ffmpeg] Destination: ORIGINAL SONG MVMantra Hujan - Kobo Kanaeru hololive Indonesia 3rd Gen-SF-_47-oCtk.mp3
Deleting original file ORIGINAL SONG MVMantra Hujan - Kobo Kanaeru hololive Indonesia 3rd Gen-SF-_47-oCtk.webm (pass -k to keep)
Ignoring exception in command play:
Traceback (most recent call last):
File "c:\Users\Teddy\Documents\bot discord python\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\Teddy\Documents\bot discord python\main.py", line 125, in play
os.rename(file, "song.mp3")
AttributeError: module 'discord' has no attribute 'FFmpegPCAudio'```
can someone help?
async def play (ctx, url : str):
song_there = os.path.isfile("song.mp3")
try:
if song_there:
os.remove("song.mp3")
except PermissionError:
await ctx.send("Wait for current song to stop or use 'stop' command")
return
voiceChannel = discord.utils.get(ctx.guild.voice_channels, name="Musik")
await voiceChannel.connect()
voice = discord.utils.get(bot.voice_clients, guild=ctx.guild)
ydl_opts = {
'format': 'bestaudio/best',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([url])
for file in os.listdir("./"):
if file.endswith(".mp3"):
os.rename(file, "song.mp3")
voice.play(discord.FFmpegPCAudio("song.mp3"))```
this the code
miss 1 word=eror
so nice
Traceback (most recent call last):
File "c:\Users\Teddy\Documents\bot discord python\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "c:\Users\Teddy\Documents\bot discord python\discord\ext\commands\core.py", line 855, in invoke
await self.prepare(ctx)
File "c:\Users\Teddy\Documents\bot discord python\discord\ext\commands\core.py", line 789, in prepare
await self._parse_arguments(ctx)
File "c:\Users\Teddy\Documents\bot discord python\discord\ext\commands\core.py", line 697, in _parse_arguments
transformed = await self.transform(ctx, param)
File "c:\Users\Teddy\Documents\bot discord python\discord\ext\commands\core.py", line 542, in transform
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: msg is a required argument that is missing.```
can someone help?
async def play (ctx, url : str, msg):
try:
voice_client = await msg.author.voice.channel.connect()
voice_clients[voice_client.guild.id] = voice_client
except:
print("error")
try:
url = msg.content.split()[1]
loop = asyncio.get_event_loop()
data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=False))
song = data['url']
player = discord.FFmpegPCMAudio(song, **ffmpeg_options)
voice_client[msg.guild.id].play(player)
await ctx.reply(f"Playing {url}", mention_author=True)
except Exception as err:
print(err)```
this is the code
self explanatory
you dont need the msg parameter
instead, change msg.author.voice.channel.connect() to ctx.author...
the ... just means the rest of the syntax
I mean to Check if the user is on the server and if not send a ctx like "User not found"
Smth like if member is not in ctx.guild.members:
if a member is not a real member, discord will raise an exception commands.MemberNotFound
it will do the same if a user isnt on the server
'Context' object has no attribute 'content'
i got this
async def play (ctx, url : str):
try:
voice_client = await ctx.author.voice.channel.connect()
voice_clients[voice_client.guild.id] = voice_client
except:
print("error")
try:
url = ctx.content.split()[1]
loop = asyncio.get_event_loop()
data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=False))
song = data['url']
player = discord.FFmpegPCMAudio(song, **ffmpeg_options)
voice_client[ctx.guild.id].play(player)
await ctx.reply(f"Playing {url}", mention_author=True)
except Exception as err:
print(err)```
ctx.message.content
'VoiceClient' object is not subscriptable now i got this
same code(changed to ctx.message.content.split)
Is there a way for the bot to tell the differences between a thread being created and it joining a thread
pls ping in reply
I wanted to make a simple tic-tac-toe bot. I have everything working except for a turn system. I already stored the two people playing in a list and made a turn variable, but when trying to change the turn variable in any way, I get many errors. Is there an easier way of doing it other than people[turn]?
how do i edit the message sent from ctx.respond()? i tried doing interaction.original_message() but i got a AttributeError: 'coroutine' object has no attribute 'edit'
on_thread_create is the event reference for creating a thread and on_thread_join for joining
thank! now ill just sit on the corner thinking how i could have missed that when it was just below original_message
Hey Guys!
There there a way to, for a button on click, to just continue with the main function.
a = await ctx.send("abc", view=View(ctx.author, msg))
# if button is clicked continue
#else dont
print("e")
'VoiceClient' object is not subscriptable
can someone help?
async def play (ctx, url : str):
try:
voice_client = await ctx.author.voice.channel.connect()
voice_clients[voice_client.guild.id] = voice_client
except:
print("error")
try:
url = ctx.message.content.split()[1]
loop = asyncio.get_event_loop()
data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=False))
song = data['url']
player = discord.FFmpegPCMAudio(song, **ffmpeg_options)
voice_client[ctx.guild.id].play(player)
await ctx.reply(f"Playing {url}", mention_author=True)
except Exception as err:
print(err)```
this is the code
the bot can connect but cant play music
https://github.com/Pycord-Development/pycord/blob/99b29e79c6b5a1a866e99ad15bc32cc6572f73db/examples/views/confirm.py
Maybe this can help you
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/confirm.py at 99b29e79c6b5a1a866e99ad15bc32cc6572f73db Β· Pycord-Development/pycord
def __init__(self, ctx: Context, content: list[str]):
self.ctx = ctx,
self.content = content
Why does ctx get the type tuple[Context]?? It should just be the context object
tysm
is there no way to do that with a button?
I don't think you have defined voice_clients.
wdym?
like a confirm button instead of view
NVM
it is a button
i though it was a menu
srry
np xd
And is there a way to use commands in threads? Or maybe, even better, trigger an event whenever a bot gets pinged in a thread
And what's on_thread_update?
im trying to get the data of this api
@commands.slash_command(name = "advice", description= "gives you some advice", Guild_ids=config.Guilds)
async def advice(self, ctx):
async with aiohttp.ClientSession() as cs:
async with cs.get("https://api.adviceslip.com/advice") as r:
res = await r.json()
print(res)
thats my code and it returns this Application Command raised an exception: ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8', url=URL('https://api.adviceslip.com/advice%27)
whats going wrong cause i never saw this error before
well the website is responding with a different mimetype than expected
can i change the mimetype for only that command by any chance ?
@past gate
its the server that sets the mimetype not the client (in the response)
what status code does the website return?
nothing it just works
thats the link
it just returns
{"slip": { "id": 15, "advice": "If it ain't broke don't fix it."}}
that
that would be great !
yeah it appears the server responds with the incorrect mimetype leading clients to throw errors
you could work around that by parsing the result of r.text into JSON via json.loads
hmm okey
maybe add in a try-except just incase it returns something other than JSON
so like await r.json(r.text)
ah okey
hi
guys
how to get the inviter id
i mean when somebody join the bot get the person that he invited and get his id
@scenic leaf @past gate
could you please stop pinging me
im not sure about getting the id but this is what i use when someone invites someone else
@bot.command()
async def invites(ctx, usr: discord.Member=None):
if usr == None:
user = ctx.author
else:
user = usr
total_invites = 0
for i in await ctx.guild.invites():
if i.inviter == user:
total_invites += i.uses
await ctx.send(f"{user.name} has invited {total_invites} member{'' if total_invites == 1 else 's'}!")
it gets who invited who and how many they have invited allready Xd
ok thanks
no problem
looking into the internals of the aiohttp lib, I've realised you could just pass the content_type kwarg to the json() function call on the response with the expected content type from the server which in this case will be text/html (for some reason)
okey can you guide me to a doc or piece of code that does that
cause im not know with aiothttp that well yet
just res = r.json(content_type='text/html')
When i try to print the message object i get TextChannel' object has no attribute 'news'. Is there a fix for it?
Is it possible to edit a response?
anyone knows how to fix this?
ooh thanks !
Why does
await ctx.respond(f"Ping {role.mention}",allowed_mentions=discord.AllowedMentions(roles=True))
``` not ping on a slash command?
Guys pls help. Does anyone know how to check if the user from e.g. /userinfo [member] is a member on the server and if not send a msg like "User is not on this server" to prevent error in console
just make a try except statement
it is possible to select in modal ?
i fixed it but now it send me this and idk how to fix it
your r variable is None
I is None, make sure that I is an object
No its inviter
oh ok
try:
[your_code]
except YourException:
[what should happen if that exception gets raised]
in that case its the user variable since both user and r access .name
so its hard to tell which one is throwing the error without your code
this error suggests the code was different to what it is in your screenshot
no the error is in line 89
whats is the current error being thrown?
use an error handler
the error that is usr variable has no attribute with the id idk why
can you send the error
clearly line 88 is not working properly then
its not discord light theme
Still pain
Is that replit?
yes
i tried to change the code and still dont work
get_member need a ID so yes usr.id
Try it
?
If the I'd was already int why you doing it again. ?
how do you get a bot to edit a specific message from an interaction?
You want to edit bots interaction msg ?
interaction.response.edit_message()
so i type usr.name?
I'm saying why you converting multiple time with base 10 int ?
yeah it sends a embed in the channel and also 2 buttons to dms and the result of those buttons needs to change the embed in the channel
Ok
await interaction.response.edit_message()
You have to make the after edit embed also
Or you can add a field to embed.add_field_to
But if you think to edit a perticular word or line it not possible
It possible if you make a variable
Of the part and you write with f string
how do i get it to edit the message in the guild not in dms?
i dont understand
you mean i have to change usr.id?
heyo! I just recently started switching from discord.py to use slash command etc, everything running smoothly until i attempted to get a paginator to response to the context interaction, it just raises a 404 Unknown interaction error, anyone have any advice?
From message.attachments, how would I turn one into a discord.File type?
file = await message.attachments[index].to_file()
thanks
never mind, only just read about the 3 seconds interaction, fixed with await ctx.defer()
how do i replace words in a message cause i have this
@bot.event
async def on_message(message):
input = message.replace(' ', '+')
but it says Message' object has no attribute 'replace'
Select on modals work ?
input = message.content.replace(' ', '+')
no
aah thanks !
np
how would i prevent the bot from reacting to its own messages Xd
@bot.event
async def on_message(message):
input = message.content.replace(' ', '+')
async with aiohttp.ClientSession() as cs:
async with cs.get(f"https://api.popcat.xyz/chatbot?msg={input}") as r:
res = await r.json()
response = res["response"]
members = message.guild.members # also works with ctx.guild.members
for member in members:
if member.bot == True:
print('Member is bot')
else:
print('Member is not bot')
await message.channel.send(response)
is what i now have
but it reacts to its own messages haha
like breh Xd
@bot.event
async def on_message(message):
if message.author.bot:
return
input = message.content.replace(' ', '+')
async with aiohttp.ClientSession() as cs:
async with cs.get(f"https://api.popcat.xyz/chatbot?msg={input}") as r:
res = await r.json()
response = res["response"]
members = message.guild.members # also works with ctx.guild.members
for member in members:
if member.bot == True:
print('Member is bot')
else:
print('Member is not bot')
await message.channel.send(response)```
np
view = Confirm()
await view.wait()
if view.value is None: # If the user didn't press the button
await msg.edit_original_message(embed=discord.Embed(title=f"Power | {server.capitalize()}", description=f"Timed out waiting for confirmation, Aborting.", color=embed_color).set_footer(text=embed_footer).set_author(name=embed_header, icon_url=embed_icon))
return
elif not view.value: # If the user cancelled
await msg.edit_original_message(embed=discord.Embed(title=f"Power | {server.capitalize()}", description=f"Cancelled, Aborting.", color=embed_color).set_footer(text=embed_footer).set_author(name=embed_header, icon_url=embed_icon))
return
await msg.edit_original_message(embed=discord.Embed(title=f"Power | {server.capitalize()}",description=f"Confirmed, continuing with the operation.",color=embed_color).set_footer(text=embed_footer).set_author(name=embed_header, icon_url=embed_icon))
it's result never gets shown
Hey ahh i want my bot to delete it's message like take an break for 10 sec and after that deletes it's message
Hey,
I can't seem to find a way for a message from slash command to be only visible for the user that launched the command.
Hi, not code related but i made a feature that creates invites for all server that its in and gives them to me. Is that allowed or against the ToS? Becuase some random guy said he's gonna report me for it if i dont remove it
There's a parameter in the send function called delete_after
await ctx.send("something",delete_after=10)
It varies from server to server you would need to respect their privacy so it would be best if you do remove it
Ok
anyone knows how to fix it
i've got this error
File "/Volumes/Danya disk/Windows Hall/Programer/Py-cord/KeyBot/bot.py", line 41, in <module>
async def keyadd(ctx, key: Option(name="ΠΊΠ»ΡΡ", description="ΠΠ»ΡΡ ΠΎΡ ΠΈΠ³ΡΡ Π² Steam",input_type="Key"),
TypeError: Option.__init__() missing 1 required positional argument: 'input_type'```
How can i fix it?
Hey how i can check mass join and this members kicked?
I have google used and i have what by stackoverflow found but this is not helping me?..
https://stackoverflow.com/questions/68069760/discord-py-check-if-there-is-a-mass-join-raid
I would like to have my bot check if more than 10 people enter in 15 seconds in a server with discord.py
Is there a default function of discord.py or do I have to create it myself?
Then you have the msg id, channel id in ur db ?
You can use my pakage which is on my GitHub or about me name called pycord-ext-menus
no thanks, already fixed my issue
You have to make events manually for it using time module
you can use ephemeral messages with embeds right
does it only work with ctx.respond
or can you send an embed ephermeral
?tag emphermal
No tag emphermal found.
?tag ephermeral
?tag ephemeral
An 'ephemeral' message is one that's only visible to the person who invoked a command. If you ever got a command error with a blue background, this is an example of one.
To do this, set ephemeral=True when you first use an ApplicationContext. (This includes .defer()ing it; the choice of whether a message is ephemeral or not must be made up front. If you .respond() to a deferred message, setting the ephemeral flag at that time will have no effect.)
This is the equivalent of hiddene=True if you're coming from interactions.py
lol nvm
import discord
import os
import motor
import MongoDB
from dotenv import load_dotenv
from discord.ext import commands
from discord import slash_command
bot = commands.Bot(command_prefix='>', intents=discord.Intents.all(),debug_guilds=[964126154774679582,740616442034258002,965533467557371944], activity=discord.Activity(type=discord.ActivityType.watching, name='Over The Felbcord'))
('mongodb+srv://FoolishBlue:<password>@cluster0.90c9j48.mongodb.net/?retryWrites=true&w=majority')
motor = motor.motor.asyncio.AsyncIOMotorClient(str(bot.connection_url))
db = mongo['felbot']
load_dotenv()
directories = ["./commands", "./Embeds","./Events","./Modals"]
for directory in directories:
for filename in os.listdir(directory):
if filename.endswith(".py"):
bot.load_extension(f"{directory[2:]}.{filename[:-3]}")
@bot.event
async def on_ready():
print('Connected to bot: {}'.format(bot.user.name))
@bot.event
async def on_application_command_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.respond(error,ephemeral=True)
else:
raise error
bot.run(os.getenv("TOKEN"))```
error:
Traceback (most recent call last):
File "C:\Users\jackd\Documents\Felbcord Py\main.py", line 4, in <module>
import MongoDB
ModuleNotFoundError: No module named 'MongoDB'
(in <password> i did have pass but ofc removed it)
Idk whats wrong?
reinstalll the module i guess?
-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/python
-----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
! Push failed
can someone help?
i got it, just a bad tutoital i used
import discord
from discord.commands import slash_command
from discord.ext import commands
from discord.ext.commands import Cog
class Suggestions(discord.ui.Modal):
def __init__(self,bot,*args, **kwargs) -> None:
self.bot = bot
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Your Suggestion: ", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
m = await interaction.response.send_message("Suggestion send!", ephemeral=True)
suggest = discord.Embed(title=f"Suggestion by {interaction.user} Under Review ",color=discord.Color.blue())
suggest.add_field(name="Your Suggestion: ", value=self.children[0].value)
suggest.set_footer(text=f"Message id: {m.id} ")
channel = self.bot.get_channel(987396375069224960)
embed = await channel.send(" Ping: <@&988496229229002792>", embed=suggest)
await embed.add_reaction('β')
await embed.add_reaction('β')
class Suggest(Cog):
def __init__(self,bot):
self.bot = bot
@slash_command(name="suggest", description="suggestions")
@commands.cooldown(1,7200, commands.BucketType.user)
async def modal_slash(self,ctx: discord.ApplicationContext):
await ctx.send_modal(Suggestions(self.bot, title="Suggestion"))
db = db['FelBott']
mid = await collection.find_one({'_id':{m.id},mdata})
await collection.insert_one(mdata)
def setup(bot):
bot.add_cog(Suggest(bot))``` Why am i getting all these errors?
m is defined lol
Hello guys i have a question. How can i fix the error. I wanted to make an addrole command but if someone e.g. types /addrole asidg then theres an error. I tried to fix it with if member == ctx.guild.members: and else: but that clearly doesnt work. Pls help :P
The concerter cant xonvert to member
(if member in ctx.guild.members)
But that wont fix it
just this now
?
You give "d" as input which is not a correct meme rr
and how do i check if its not an member lol
how xd
In your handler
Could anyone help? I managed to fix a lot of them myself but cant fix these
The error explains itself
?tag python
its is very difficult to help you if you don't understand python first.
As it stands, you do not or cannot show that you understand the basic fundamentals of Python. Please continue to learn Python first, as pycord is a Python framework and as such requires that you have a confident grasp on these fundamentals . For now, pause your current project and when you have learned enough Python you can then pick it back up and continue where you left off (if at all possible).** You cannot drive a truck if you do not know how to drive at all.**
cool free resources are
w3school
freecodecamp.org
there are also a lot of python programming tutorials out there a youtube search will give a lot awesome content. If you need help with python there is a python server for that where they will be more that happy to help you with these thing, you can also ask for python help in #881309540639997952.
python server: https://discord.gg/python
I got it fixed lol
i was just dumb
but now i have this
i try to push my bot to heroku but i got this error:
Push failed: cannot parse Procfile.
Traceback (most recent call last):
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "C:\Users\jackd\Documents\Felbcord Py\main.py", line 31, in on_application_command_error
raise error
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 993, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 357, in invoke
await injected(ctx)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 134, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'Bot' object has no attribute 'mongoConnect'
i already have smth like that from a yt tutorial but how do i do that with member checking
can someone help?
what does your procfile look like?
?
Look what error is raised and make the same thing what you did with missing perms
Also explains by itself
hmm
what should i write
Yes.. but it dosent expain how to fix it does it
looks fine
You calling it on the wrong object
not sure
Wym? (Btw is this to me lol)?
Yes
Can you explain? Im using a tutoital and tryna understand it but ive got confused
how do I use the discord API directly to fetch a user?
Please learn basic python.
For real pycord is not a beginner lib.
Its a reference error the bot does not have a mongoConnect method.
I know basic python
might want to get rid of one of the two else clauses and make the membernotfound error check an elif
For u the same lern basic python first.
Hint: you brackets are wrong
I know basic python, Its just databases confuse the hell out of me
like this?
its not necessarily his brackets, he's missing a comma he put a ) in its place instead
...
Like i said his brackets are wrong xD
Nanidafq
Maybe you should learn Python
^
Just a suggestion
May you explain a fix?
Thank you
HAHAH TO MUCH ERRORS XDDDDDDDDDDD
?tag install
a fix to databases confusing you? learn databases.
-
Uninstall
discord.pyor any other forks of discord.py you might have with the namespacediscord.
python -m pip uninstall discord.py discord -y -
Install
py-cord
python -m pip install py-cord
Installing other builds:
Note: You need to have git installed. Use !git to find out how to install git.
Updating the module to Alpha (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord
Updating to release candidate:
pip install py-cord==2.0.0rc1
Your client object does not have the method mongoConnect
But what did i do wrong :o
Your "about me" says "program computer." Is that the operating system?
The rest you have to figure out by yourself because it depends on your implentation
quite a lot tbh
https://www.w3schools.com/python/python_conditions.asp Look at this itll help you in this case
Na its just a way of saing doing the programming.
@dawn wagon

put the elif with the raise error at the bottom and use "else" instead

wow you can read
now do the same thing with MemberNotFound as you did with MissingPermissions
xd
but i already did that or wdym
Its red
yes ik
Modals do timeout internally right...
right?
uh are you using a JSON file?
yup
after how long exactly?
did you not do
from discord.ext.commands.errors import MemberNotFound```?
I think default is 30?
we dont talk about that :)
smh
my brain cells are 0 rn i swear xd
No results found when searching for modal.timeout in pyc
What rly ?
Do you have a code line for that ?
actually, you can't
because discord limitation
at least it's not documented by discord
What i meant is that the modal is never removed from the modal store if its not submitted.
As far as i can see there is no internal timeout handler.
But if there is one i would like to know where
+1
Now that error is here D: xd
If you dismiss a modal on a command with max concurrency it just makes the wait() hang forever, blocking the entire command
why do you have member as an argument?
you can get the user with ctx.author
Remove the member argument
It only takes in 3 arguments
its an addrole cmd so when smone types !addrole blah then the bot will send "User blah not found" you get me xd?
you can implement your own timeouts
You can wrap it in an asyncio.wait_for
Which solves the blocking issue.
But the problem is that your memory leaks because the modal is in the store but never removed
make it an issue on github
but i wanna send the member that wasnt found
Jea i will
I already stated the problem in #discussion but no awnser from core team
I'm not sure how you can get the invalid name given but you could just do "The specified user was not found"
Yeah I figured that, I just didn't know if there was a library-native solution like in Views
ok thanks
I could go open a PR tbh
will .format() work maybe?
jesus christ how beefy is the repo
You should learn python first
I think modals were implemented pretty rushed
so it's just the bare minimum
Reasonable tbh
If you fork i would love to work on a solution together
I like that song
You would want to delete that
ext.pages, now they want to ad ipc in the lib.
Im not sure if this are good decisions
Bruh i hate my life my friend must go know so i cant go on with fixin the damn errors D:
As 3rd party packages hell yea
But why as native.
Is so out of scope for pycord
cool
pages are fine
but ipc, not really
Does anybody know a non webbased VERY GOOD python programm to code together? I searched my ass up but didnt find a single good programm
Were using pycharm code together
on his pc
visual studio code and live share extension
So when hes not online i cant code
or just github and anything
just make a github repo
thats webbased and slow as hell
Yea same
I can see pages
But ipc is totaly out of scope
But pages also firs better as 3rd party tbh but i can see why its in hwre
so you can make code changes without the need to wait for the other party
i need smth in a cloud so i can code when hes off and he can code when im off
not sure if this works if the host is offline
im already doing that w/ my friend
but its on his pc
so when hes off I CANT CODE :(
github is best way
agreed
There is still replit ig
can you send a link or smth i cant find it
how you couldn't find it lol
are you searching through bing or what
you code on your ide and if the code works you then move your code on to here with git
and your collaborators can also see the changes
bruh thats not what i wanted D:
i want real time coiding and a cloud
is that so hard xd
I just released a new version of my bot to heroku, ended up getting this:
2022-06-21T19:06:51.915449+00:00 app[worker.1]: Traceback (most recent call last):
2022-06-21T19:06:51.915469+00:00 app[worker.1]: File "/app/DiscordBot.py", line 2, in <module>
2022-06-21T19:06:51.915531+00:00 app[worker.1]: import discord
2022-06-21T19:06:51.915540+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.10/site-packages/discord/__init__.py", line 25, in <module>
2022-06-21T19:06:51.915630+00:00 app[worker.1]: from .client import Client
2022-06-21T19:06:51.915638+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.10/site-packages/discord/client.py", line 53, in <module>
2022-06-21T19:06:51.915745+00:00 app[worker.1]: from .webhook import Webhook
2022-06-21T19:06:51.915757+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.10/site-packages/discord/webhook/__init__.py", line 12, in <module>
2022-06-21T19:06:51.915852+00:00 app[worker.1]: from .async_ import *
2022-06-21T19:06:51.915861+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.10/site-packages/discord/webhook/async_.py", line 49, in <module>
2022-06-21T19:06:51.915971+00:00 app[worker.1]: from ..channel import PartialMessageable
2022-06-21T19:06:51.916000+00:00 app[worker.1]: ImportError: cannot import name 'PartialMessageable' from 'discord.channel' (/app/.heroku/python/lib/python3.10/site-packages/discord/channel.py)
Still get the same error after reverting the changes
any programm out there?
do you mean like a google docs but for coding
YES EXACLTY
replit
you are asking for too much
Just pay for Hacker
how much is that
bruh just Visual Studio Code and Live Share extension
tell that to him not me smh
google console/cloud
And everything worked while testing on my pc
but thats the same not in a cloud
#969580926885580801 message
check pycord version
I updated it to rc1 with this release, but reverting the changes (which also made it to be b4 again) didnβt help eitherβ¦
You cant code in that
Thats just a cload
Not a ide
well ide then you've got jetbrains, vscode, sublime, but as you said they aren't cloud, replit is the only cloud ide that actually lets you run stuff, so you can pick that, or grab yourself a cheap vps or a vps sharing (causes more problems), if you do get a vps, jetbrains and vscode will allow you to deploy and run your stuff easily from the ide
error:
TypeError: list indices must be integers or slices, not str
db = ['FelBot']
collection = db['FelBott']
m = await collection.find_one({'_id':m.id},m.id)
await collection.insert_one(m.id)```
Why do i get this error? (I have been tryna figure it out for so long)
collection = db['FelBott']
im proably being stupid
you are indexing using a string
I am connecting my db, Showing what collection isnt that right? (Could you show an example)
@idle linden
Would I update it like this?
py-cord==2.0.0rc1
yes
its rc1
?
is rc1 better?
yeah, latest
a oke
that's what I did when I started to get the error, py-cord==2.0.0b4 is what I had before, but yeah, even reverting all my changes back to how it'd been when it worked didn't help...
I guess I'm too scatterbrained right now to understand your code, unless you're not showing your whole code
##1434 If you can help me fix whatever is causing this issue to be thrown out be my guest
Ill take a look when im home
Im not sure if this is right or not but, dont you need to await self.on_timeout? since it is a coroutine and you are calling it
it would also make sense as your error is mentioning that you are missing an await
Got it fixed by removing unnecessary requirements
Again, I copied the code from discord.ui.View, and I checked for all references of the variables used, and its never waited in discord.ui.View. Furthermore, its being casted to create_task, which awaits it in the background
ah ok
how to send dm
user.send("msg")
thank you.
?tag install
-
Uninstall
discord.pyor any other forks of discord.py you might have with the namespacediscord.
python -m pip uninstall discord.py discord -y -
Install
py-cord
python -m pip install py-cord
Installing other builds:
Note: You need to have git installed. Use !git to find out how to install git.
Updating the module to Alpha (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord
Updating to release candidate:
pip install py-cord==2.0.0rc1
I'm currently having issues with my models
whitelisted = fields.ManyToManyField("models.UserModel", on_delete=fields.SET_NULL, null=True)
logs_channel = fields.ForeignKeyField("models.ChannelModel", on_delete=fields.SET_NULL, null=True)
isnt it called "modal"?
What does that have to do with pycord then?
just asking because is about the model
how do i fetch a users avatar directly from the discord API?
b!rtfm pyc fetch_user
discord.Bot.fetch_user
discord.Client.fetch_user
discord.Bot.get_or_fetch_user
discord.Client.get_or_fetch_user
discord.ext.commands.Bot.fetch_user
discord.ext.commands.Bot.get_or_fetch_user
discord.Bot.fetch_premium_sticker_packs
discord.Client.fetch_premium_sticker_packs
discord.ext.commands.Bot.fetch_premium_sticker_packs
How do I check if a channel is a thread?
b!rtfm pyc thread
b!rtfm pyc channel
im guessing using that?
ig that's it, thx
anyone got a pip install for sqlite?
i have a question i found a website called rapidapi and they have this request thingy for python
url = "https://new-world-server-status.p.rapidapi.com/servers"
headers = {
"X-RapidAPI-Key": "",
"X-RapidAPI-Host": "new-world-server-status.p.rapidapi.com"
}
response = requests.request("GET", url, headers=headers)
print(response.text)
but i always use
async def Valostrat(self, ctx, map, side):
async with aiohttp.ClientSession() as cs:
async with cs.get(f"https://api.diah.info/valorant/roulette.php?format=json&map={map}&side={side}") as r:
res = await r.json()
name = res["name"]
embed=discord.Embed(title="Valorant strats", color=config.EMBED_COLOR)
embed.set_author(name="BBS", url="https://blackbullstudio.eu",icon_url="https://www.blackbullstudio.eu/wp-content/uploads/2022/06/Master-Black.png")
embed.add_field(name="Name", value=name, inline=True)
await ctx.send(embed=embed)
how would i use the above code in the below one ?
i think they are kinda the same
just a difrent way
how to show slash commands to only certain roles?
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/slash_perms.py at master Β· Pycord-Development/pycord
It is included in the standard library
np
You use two different methods for api requests. You should rewrite one of them
okey ill try
i got the module downloaded but the import couldnt be resolved
idk why it used to work then stopped
Error?
import discord could not be resolved
which version did you install?
Install pycord:
pip uninstall discord.py
pip install py-cord
Install pycord beta:
pip uninstall discord.py
pip install py-cord==2.0.0b7
Install pycord alpha from git:
pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord
i did same thing @slender lintel
matter of fact i uninstalled that to install the alpha
because it wasnt working
You have no other libraries installed?
ofc i do
*discord libraries
nope
ok
and i used to have it downloaded in an env (pycord) but idk what happened and i cant get in the env anymore
@slender lintel all good it was VScode i switched to pycharm and it works

thanks for the help!!
I tried xd
def get_guild(bot, command):
"""Gets the guild a command belongs to. Useful, if the command was sent via pm."""
if command.guild is not None:
return command.guild
for guild in bot.guilds:
for channel in guild.voice_channels:
if command.author in channel.members:
return guild
return None
that code will return
if command.guild is not None:
AttributeError: 'NoneType' object has no attribute 'guild'
what is going wrong here ?
i run this code
@commands.slash_command(name = "play", description= "plays music from spotify or youtube", Guild_ids=config.Guilds, pass_context=True, hidden = True)
async def _play_song(self, ctx, *, link: str):
current_guild = utils.get_guild(self.bot, ctx.message)
try current_guild = utils.get_guild(self.bot, ctx)
So for the purge
The respond from the ctx doesn't get sent by the bot
but deletes the message only
how do you disable a certain button in the same class from another button's callback?
for child in self.children:
child.disabled = True
await.....
That disables all the buttons in the class. I only want to disable 1 and 2 but leave 3
Does guild.get_member() make an API call each time?
Or is it cached?
Asking to avoid hitting a ratelimit
make it so that you compare the button label
and disable it that way
as it interates through the self.children compare it with the button label that you want to disable
Ah okie. Thanks
No fetch_member() is an API call
Has anyone used dynamic cooldown? I want to know if dynamic cooldown refreshes the cooldown each time a new value is given to the command
yes
Yes to both of the questions?
to three of them now
would you need any event to update it or does it do it on its own, I have not used it
so i'm quite lost
it's been a while since I've used it. Let me refresh my memory by looking at docs.
So you just put a function there instead of an actual number
the function should take a discord.Message and return a cooldown
or None
can you give an example please
def get_cooldown(message):
if message.author == 123:
return discord.ext.commands.Cooldown(1.0,1)
else:
return discord.ext.commands.Cooldown(5.0,1)
@bot.command()
@discord.ext.commands.dynamic_cooldown(get_cooldown, type=BucketType.user)
async def command_name(ctx):
pass
ofc bot has to be defined and discord and buckettype imported
Awesome I understand it!, Thank you!
Why is this happening to my test account, I am in a server with it, and i don't think bots can turn that on since they can't have friends
can someone help me? i want to deploy my bot to heroku but i got some error
Show your Procfile
You haven't entered correctly buildpacks
And also show your runtime.txt
what should i write
different tutorial different method
i dont have this
and also i got some error while run my bot(no error yesterday)
the error says raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
async def play (ctx):
try:
voice_client = await ctx.author.voice.channel.connect()
voice_clients[voice_client.guild.id] = voice_client
except:
print("error")
try:
url = ctx.message.content.split()[1]
loop = asyncio.get_event_loop()
data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=False))
song = data['url']
player = discord.FFmpegPCMAudio(song, **ffmpeg_options)
voice_client.play(player)
await ctx.reply(f"Playing {url}", mention_author=True)
except Exception as err:
print(err)```
and the only one code that i use loop is this
your main file (main.py instead of log.py)
oo ok
in my github i write it main.py
but same error
If you don't have runtime.txt it won't deploy on heroku
ah i see
so what should i write in the runtime
i've already used it
Search on yt how to host discord.py bot in heroku
You will get some tutorial
Nice then
i watch like 10 tutorial and all i got is same error
and i dont see they make runtime.txt file
Because you watch old tutorials
and also i got this error while i run my code in vsc today
How come printing the dm channel (ctx.channel) returns Direct Message with Unknown User ?
Full code
@commands.slash_command(description = 'Report Game')
async def report_game(self, ctx):
await ctx.respond("Please follow the instructions as they appear.", ephemeral = True)
def check(msg):
print(ctx.channel)
return msg.author == ctx.author and msg.channel == ctx.channel
await ctx.send("Please send your zip file with replays inside.")
message = await self.client.wait_for("message", check = check)
print("PASSED")
even u didn't provide the timeout
?
wdym
Do I have to set a timeout? Ive never had to before
If ur using wait_for then use a timeout & try except with asyncio.Timeout
Here's the wait for event example.
My issue is that ctx.channel is coming up as βDirect Message with Unknown Userβ
because you responded the app interaction use defer or use ctx.channel.send
i just succesfully deploy my bot to heroku but why my bot is still offline?
turn on ur dynos
sorry my brain too small i forget
still offline after i turn on
show me procfile, runtime.txt
from heroku deploy its say succes deploy to heroku
buildpack ?
from setting?
i use this
you have to provide the build pack in procfile also
Converts a message's components into a :class:`View`.
The :attr:`.Message.components` of a message are read-only
and separate types from those in the ``discord.ui`` namespace.
In order to modify and edit message components they must be
converted into a :class:`View` first.
Parameters
-----------
message: :class:`discord.Message`
The message with components to convert into a view.
timeout: Optional[:class:`float`]
The timeout of the converted view.
Returns
--------
:class:`View`
The converted view. This always returns a :class:`View` and not
one of its subclasses.```
Couldn't find documentation for discord.ui.View.refresh.
owh ok
how i write it
-
Uninstall
discord.pyor any other forks of discord.py you might have with the namespacediscord.
python -m pip uninstall discord.py discord -y -
Install
py-cord
python -m pip install py-cord
Installing other builds:
Note: You need to have git installed. Use !git to find out how to install git.
Updating the module to Alpha (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord
Updating to release candidate:
pip install py-cord==2.0.0rc1
!install
Install pycord:
pip uninstall discord.py
pip install py-cord
Install pycord beta:
pip uninstall discord.py
pip install py-cord==2.0.0b7
Install pycord alpha from git:
pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord
last one
heroku ps:scale worker=1
worker: python main.py
msg = await channel.fetch_message(message)
view = discord.ui.View.from_message(msg)
await db.buttonroles.insert_one({"guild": ctx.guild.id, "channel": channel.id, "role": role.id, "name":name})
view.add_item(RoleButton(role, name))
await msg.edit(view=view)
for child in view.children:
child.add_item(Role)
self.bot.add_view(view)
await ctx.respond("Done")
When i add button to a message the button will work but old buttons are stop why ?
if anyone knows help me
Yes
in dev
wdym ?
what changged in https://github.com/Pycord-Development/pycord
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - GitHub - Pycord-Development/pycord: Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API
it have fixed of older versions
no
How should the bot know what to do with the interaction. I do t think you save the custom ids somewhere
obsly it saves in db as well as custom_id
see
But when i restart all button working
Oh thatβs not my topic then.
@inland laurel care to explain him?
Thnx
