#General Help
1 messages Β· Page 21 of 1
on your modal subclass on init add this
def __init__(self, bot):
self.bot = bot
On my suggest class right?
(On suggestions class i cant see where to ad it?)
then on your modal_send
Suggestion class which subclass of modal
super().__init__(*args, **kwargs) here?
class Suggestions(discord.ui.Modal):
def __init__(self, bot, *args, **kwargs) -> None:
self.bot = bot
super().__init__(*args, **kwargs)
its okay
but really man, you have to understand the basic
having discord bot as beginner project is not good
Alot of the time its understanding where to put stuff rn
from discord.commands import slash_command
from discord.ext.commands import Cog
class Suggest(Cog):
def __init__(self,bot):
self.bot = bot
class Suggestions(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
self.bot = bot
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
suggest = discord.Embed(title=f"{interaction.user} Suggested ")
suggest.add_field(name="Your Suggestion", value=self.children[0].value)
suggest.add_field(name="Message id:{message.id}", value=self.children[0].value)
channel = self.get_channel(964130201514692628)
await channel.send(embeds=[Suggestions])
@slash_command(name="suggest", description="suggestions")
async def modal_slash(self,ctx: discord.ApplicationContext):
modal = Suggestions(title="text")
await ctx.send_modal(modal,(self.bot))
def setup(bot):
bot.add_cog(Suggest(bot))``` Bot is not defined, I litearly have defined bot
why is it looks messy now
Why the hell the modal is inside the cog class
Its discord....
import discord
from discord.commands import slash_command
from discord.ext.commands import Cog
class Suggestions(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
self.bot = self.bot
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
suggest = discord.Embed(title=f"{interaction.user} Suggested ")
suggest.add_field(name="Your Suggestion", value=self.children[0].value)
suggest.add_field(name="Message id:{message.id}", value=self.children[0].value)
channel = self.get_channel(964130201514692628)
await channel.send(embeds=[Suggestions])
class Suggest(Cog):
def __init__(self,bot):
self.bot = bot
@slash_command(name="suggest", description="suggestions")
async def modal_slash(self,ctx: discord.ApplicationContext):
modal = Suggestions(title="text")
await ctx.send_modal(modal,(self.bot))
def setup(bot):
bot.add_cog(Suggest(bot))```
Wrong code
And he dont use `py
fixed
ok
you still not editing it like this ...
class Suggestions(discord.ui.Modal):
def __init__(self, bot, *args, **kwargs) -> None:
self.bot = bot
super().__init__(*args, **kwargs)
also this
channel = self.get_channel(964130201514692628)
should be
channel = self.bot.get_channel(964130201514692628)
this one aswell
await ctx.send_modal(modal,(self.bot))
should be
await ctx.send_modal(Suggestions(self.bot))
so to this one
await channel.send(embeds=[Suggestions])
->
await channel.send(embed=suggest)

import discord
from discord.commands import slash_command
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="Long Input", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
suggest = discord.Embed(title=f"{interaction.user} Suggested ")
suggest.add_field(name="Your Suggestion", value=self.children[0].value)
suggest.add_field(name="Message id:{message.id}", value=self.children[0].value)
channel = self.bot.get_channel(964130201514692628)
await channel.send(embeds=[Suggest])
class Suggest(Cog):
def __init__(self,bot):
self.bot = bot
@slash_command(name="suggest", description="suggestions")
async def modal_slash(self,ctx: discord.ApplicationContext):
modal = Suggestions(title="text")
await ctx.send_modal(Suggestions(self.bot))
def setup(bot):
bot.add_cog(Suggest(bot))``` same error
@half marsh
read what i have send you
you really need to look what is upper and lower case....
i do yes
sorry lmao i dont see the need to notice that but ig i do now
literally just, ctrl+f, ctrl+c, ctrl+v
??
I changed the embed=[Suggest] to lowercase, Where else is it?
I dont see any more errors, Where is wrong
I have fixed Suggest
should be all good now i guess?
Same error tho
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 26, 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: TypeError: Suggestions.init() missing 1 required positional argument: 'bot'
@half marsh
huh
I have that error
import discord
from discord.commands import slash_command
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="Long Input", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
suggest = discord.Embed(title=f"{interaction.user} Suggested ")
suggest.add_field(name="Your Suggestion", value=self.children[0].value)
suggest.add_field(name="Message id:{message.id}", value=self.children[0].value)
channel = self.bot.get_channel(964130201514692628)
await channel.send(embeds=[suggest])
class Suggest(Cog):
def __init__(self,bot):
self.bot = bot
@slash_command(name="suggest", description="suggestions")
async def modal_slash(self,ctx: discord.ApplicationContext):
modal = Suggestions(title="text")
await ctx.send_modal(Suggestions(self.bot))
def setup(bot):
bot.add_cog(Suggest(bot))```
remove this line
modal = Suggestions(title="text")
alr
edit this line
await ctx.send_modal(Suggestions(self.bot, title="text"))
One message removed from a suspended account.
Thanks worked but my message id hasnt, I want it to be like a footer saying message id: (id)
same as you pass the bot to suggestion class
now do the self.message
i believe you can do it your own
oh yeah
How would i also make it into a footer? So not an add_field
is it suggest.set_footer
i saw on docs lol
https://github.com/Pycord-Development/pycord/blob/master/examples/app_commands/slash_perms.py
Im not sure if that works
π―
yay
{self.message.id} right?
also, ```py
import discord
from discord.commands import slash_command
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="Long Input", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
suggest = discord.Embed(title=f"{interaction.user} Suggested ")
suggest.add_field(name="Your Suggestion", value=self.children[0].value)
suggest.set_footer(text="Message id:{self.message_id}")
channel = self.bot.get_channel(964130201514692628)
await channel.send(embeds=[suggest])
class Suggest(Cog):
def init(self,bot):
self.bot = bot
@slash_command(name="suggest", description="suggestions")
async def modal_slash(self,ctx: discord.ApplicationContext):
await ctx.send_modal(Suggestions(self.bot,title="Suggestion"))
def setup(bot):
bot.add_cog(Suggest(bot))``` It says something went wrong in modal but it still sends
It should be interaction.message.id?
Oh okay (Sorry i tried message_id at first then was told to use self)
try both
I tried messsage.id message_id
self.message.id
interaction.message.id
none worked
also, this
@frigid lark @half marsh
shit sori sori
do the same like you passing bot
but now it passes ctx.message to your suggestion class
ctx.message = message.id p sure i messed that up
^
yes
is this erong
wrong*
yep
What should it be?
if you wanna be like this self.message_id
await ctx.send_modal(Suggestions(self.bot, ctx.message.id, title="Suggestion"))
Oh
dont forget to add the param on suggestion init and add the attribute message_id
also f string
import discord
from discord.commands import slash_command
from discord.ext.commands import Cog
class Suggestions(discord.ui.Modal):
def __init__(self,message.id, bot, *args, **kwargs) -> None:
self.bot = bot
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
suggest = discord.Embed(title=f"{interaction.user} Suggested ")
suggest.add_field(name="Your Suggestion", value=self.children[0].value)
suggest.set_footer(text="Message id:{interaction.message.id}")
channel = self.bot.get_channel(964130201514692628)
await channel.send(embeds=[suggest])
class Suggest(Cog):
def __init__(self,bot):
self.bot = bot
@slash_command(name="suggest", description="suggestions")
async def modal_slash(self,ctx: discord.ApplicationContext):
await ctx.send_modal(Suggestions(self.bot,ctx.message.id,title="Suggestion"))
def setup(bot):
bot.add_cog(Suggest(bot))```
error
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'NoneType' object has
no attribute 'id'
@half marsh
aah modal does not send a message 
wym?
wait have you tried interaction.message.id
also you doin f string btw
dont forget the F
yes
Where? just before the "message id: (id)"?
just before the quotation of you string
text=f"Message id:{interaction.message.id}"
.
It never worked lol
Okay thought so, thanks
m = await interaction.response.send_message("Suggestion send!")
suggest = discord.Embed(title=f"{interaction.user} Suggested ")
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(964130201514692628)
await m.add_reaction("β")
await m.add_reaction("β")
await channel.send(embed=suggest)```
error
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 17, in callback
await m.add_reaction("β")
AttributeError: 'Interaction' object has no attribute 'add_reaction
why do i get this?
anyone?
What would I use here
I'm trying to add reactions to an embed sent by a modal
Uh i linked you to discord.Interaction.original_message not that
O
I can't see anything here about adding reactions
So interactionResponse.add_reaction
what
how did you get to that ._.
Well if its send message wouldn't I replace it with add reaction
xD
you arent even using the coroutine...
I'm confused now
Look at what using this coroutine returns
It is an InteractionMessage
which inhereits from discord.Message
which has the attributes to add reactions
But how, could you give me an example I'm rly confused
interaction = await ctx.respond()
msg = await interaction.original_message()
await msg.add_reaction()```
Would I just have the msg var part in my case
m = await interaction.response.send_message("Suggestion send!")
suggest = discord.Embed(title=f"{interaction.user} Suggested ")
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(964130201514692628)
await interaction.original_message()
await m.add_reaction('β')()
await channel.send(embed=suggest)```
error:
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 m.add_reaction('β')()
AttributeError: 'Interaction' object has no attribute 'add_reaction'
btw there is an emoji in the ' ' but it didnt send
did
you
seriously not even read what i sent ._.
i did lol
m = await interaction.response.send_message("Suggestion send!")
await interaction.original_message()
await m.add_reaction('β')()```
```py
interaction = await ctx.respond()
msg = await interaction.original_message()
await msg.add_reaction()```
compare them
Really random one here, is there a way to check something before doing anything with an interaction or does it have to be at the start of an interaction
- Obviously im using m not msg.
- i already have the ctx.respond but as await channel.send()
- It doesn't matter what you name the variable. Same concept.
just dont have repeating variables I used that as an example
what are you checking for?
Yeah, but whats wrong in my msg?
code*
Just if a boolean is True
m = await interaction.response.send_message("Suggestion send!")
msg = await m.original_message()
await msg.add_reaction('β')```
1. You didn't get the original message from the interaction you wanted
2. The InteractionMessage wasnt even stored in variable.
wouldn't an if else statement work for this?
If something true:
send interaction
else:
stuff here ig
Yea i just wondered if there was a way to automatically do it for every interaction or if it was just go and do it one by one
How do you get an Invite from a url?
not sure sorry
This sorta worked but it just edited the 'suggestion sent' part, not the embed with the suggetion in the suggestion channel
dwdw
I tried using suggest.add_reaction ect but never worked
@slender lintel
think im being ignored
why would an Embed object have the attributes add_reaction
I dont know, Just tried to edit the embed not the msg
If suggest. wont work, what would i use?
well you have
await channel.send(embed=embed)
so set that to a variable
since that isnt an interaction object
... i have channel.send(embed=suggest)
itll have the add_reaction attribute
same concept?
embed.add_reaction dosent work
i can't use prefixed commands$
embed is not defined
code
You may be overwritding it with an message event
@bot.command()
async def ping(ctx):
ctx.send(f'Ping -> {round(bot.latency*1000)} ms')
?
did you do
embed = await channel.send(embed=suggest)?
oh no hold up
it seems you forgot to await
ctx.send() is a coroutine
it have await but a friend just deleted it when i copied it
bot = discord.Bot(command_prefix = "!", intents=discord.Intents.all())
here is my bot
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 17, in callback
embed = await channel.send(embed=suggest)
AttributeError: 'NoneType' object has no attribute 'send'
Can you show your entire main file? (without token ofc)
well your channel is prob wrong
It isnt
Correct id tho
?
try and fetch
async def callback(self, interaction: discord.Interaction):
m = await interaction.response.send_message("Suggestion send!")
suggest = discord.Embed(title=f"{interaction.user} Suggested ")
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(embed=suggest)
msg = await embed.original_message()
await msg.add_reaction('β')
you dont need
to get the original message
thats not an interaction
on msg -?
msg=?
mhm
just do await embed.add_reaction
okay
No?
im not sure but would time.sleep() be blocking everything else?
Itβs message.add_reaction
no
Oh they have the variable set to embed
time.sleep() is a synchronous. You should use await asyncio.sleep()
channel returns none. try await self.bot.fetch_channel()
works now
i got it dw
so the command is defined as a prefixed command but only work as a slash command
help pls
there are no prefixed commands for discord.Bot
discord.Bot.command() is an alias for discord.Bot.slash_command()
ok
so do i have to do it with the message event
hm but the docs say it the same way that i do it
?
commands.Bot will be prefixed commands
but your current slash commands should also be renamed to slash_command
discord.slash_command()
sorry i mean a prefix command
@commands.command()
ok
can I make an if query NotFound?
I tried it like this:```Py
if NotFound is True:
return
But it doesn't work..
It would work with try & except but there would be a different error handling..
import discord
import random
from discord.ext import commands
class Moderation_normal(commands.Cog):
def init(self, bot):
self.bot = bot
@commands.command()
async def random(self, ctx):
random1 = random.randint(0, 10)
await ctx.respond(random1)
def setup(bot):
bot.add_cog(Moderation_normal(bot))
this is my code
but i have a error
ExtensionFailed: Extension 'cogs.moderation.moderation-normal' raised an error: AttributeError: 'Bot' object has no attribute 'add_command'
go in the terminal and type pip list
you may have more than one using the discord namespace
aiodns 3.0.0
aiohttp 3.8.1
aiosignal 1.2.0
async-timeout 4.0.2
attrs 21.4.0
brotlipy 0.7.0
cchardet 2.1.7
cffi 1.15.0
charset-normalizer 2.0.12
frozenlist 1.3.0
idna 3.3
multidict 6.0.2
orjson 3.7.2
pip 22.1.2
py-cord 2.0.0rc1
pycares 4.1.2
pycparser 2.21
PyNaCl 1.5.0
setuptools 60.2.0
wheel 0.37.1
yarl 1.7.2
how do i get the message id that someone replied to
do you found the error?
?
???
Do roles ping if they're in an embed
You wanna make try and except?
?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
hey what one is beta?
The last one
ok
Copy paste
ok
But it's unstable be aware
ok ik
AttributeError: module 'pycord.wavelink' has no attribute 'Client'
no only if
@discord.ui.button(label="Click me!", style=discord.ButtonStyle.url)
async def button_callback(self, button, interaction):
await interaction.response.send_message("You clicked the button!")``` where am i meant to put the link if im doing a link button?
not a pycord question, but a discord one... its posible to enable this "forum" like thing on normal servers?
not yet
?
@discord.ui.button()
b!trtfm pyc button.url
b!rtfm pyc button.url
Im still confused, Where would i put the actual link for it to put you too
@discord.ui.button(label="Click me!", style=discord.ButtonStyle.url,url="https://findingfakeurlsisprettyhard.tv")
oh alr
@discord.ui.button(label="Github Link", style=discord.ButtonStyle.url,url="https://github.com/VividBlue1/Felbcord-Py") why isnt it working? (error:)
Traceback (most recent call last):
File "C:\Users\jackd\Documents\Felbcord Py\main.py", line 15, in <module>
bot.load_extension(f"{directory[2:]}.{filename[:-3]}")
File "C:\Users\jackd\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\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 718, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'commands.info' raised an error: TypeError: button() got an unexpected keyword argument 'url'
PS C:\Users\jackd\Documents\Felbcord Py> ```
oh
sorry
@discord.ui.button(label="Github Link", style=discord.ButtonStyle.link,url="https://github.com/VividBlue1/Felbcord-Py")
did i change the wrong url
that may or may not work
because link buttons don't have a callback
it dosent even start
discord.errors.ExtensionFailed: Extension 'commands.info' raised an error: TypeError: button() got an unexpected keyword argument 'url'```
if i change it to link, same error but w link
well, I creating it by subclassing discord.ui.Button
class Invite(discord.ui.Button):
def __init__(self):
super().__init__(
label='Discord',
style=discord.ButtonStyle.link,
url="https://discord.com/",
row=1)
import discord
from discord.ext import commands
from discord.commands import slash_command
from discord.ext.commands import Cog
import discord.ui
class Github(discord.ui.View):
def __init__(self):
super().__init__(
label='Github Link',
style=discord.ButtonStyle.link,
url="https://github.com/VividBlue1/Felbcord-Py",
row=1)
class infoCog(Cog):
def __init__(self, bot):
self.bot = bot
@slash_command(name="info",description="Gives infomation and command info about the bot")
async def info(self,ctx):
embed=discord.Embed(title="Bot Info", description="Hello! Here is some useful infomation about me.\n I run through slash commands and i am created by jack. here is my commands \n **/ping** | Sends the bots ping \n **/nick** `member` `name`| Changes the members nickname \n **/bean** `member` `reason` | Bans and unbans a user \n **/dm** `member` `message` | DM's a member \n **/ban** `member` `reason` | Bans a member \n **/kick** `member` `reason` | Kicks a member \n **/addslowmode** `channelid` `seconds` | Changes channel slowmode \n **/say** `message` | Sends a mesage with the bot", color=discord.Color.blue())
await ctx.respond(embed=embed, view=Github)
def setup(bot):
bot.add_cog(infoCog(bot))```
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: TypeError: View.to_components() missing 1 required positional argument: 'self'
full traceback, thank you
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 26, 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: TypeError: View.to_components() missing 1 required positional argument: 'self'
Confirming you are on rc1?
-
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
is there a way to set like an icon url in embed to a add_field element
or in header
yes
how
embed.set_image(url='link')
like a tumbnmail?
u able to help me?
Here, code just above
BRUH
?
u dont know how to fix?
no
just add self
i mean i would if i knew what line
show code
n
hold up
Github is a button, not a view
view = discord.ui.View()
view.add_item(Github())
Thanks
Thanks
import discord
from discord.ext import commands
from discord.commands import slash_command
from discord.ext.commands import Cog
import discord.ui
class Github(discord.ui.Button):
def __init__(self):
super().__init__(
label='Github Link',
style=discord.ButtonStyle.link,
url="https://github.com/VividBlue1/Felbcord-Py",
row=1)
class infoCog(Cog):
def __init__(self, bot):
self.bot = bot
@slash_command(name="info",description="Gives infomation and command info about the bot")
async def info(self,ctx):
embed=discord.Embed(title="Bot Info", description="Hello! Here is some useful infomation about me.\n I run through slash commands and i am created by jack. here is my commands \n **/ping** | Sends the bots ping \n **/nick** `member` `name`| Changes the members nickname \n **/bean** `member` `reason` | Bans and unbans a user \n **/dm** `member` `message` | DM's a member \n **/ban** `member` `reason` | Bans a member \n **/kick** `member` `reason` | Kicks a member \n **/addslowmode** `channelid` `seconds` | Changes channel slowmode \n **/say** `message` | Sends a mesage with the bot", color=discord.Color.blue())
await ctx.respond(embed=embed, Button=Github)
def setup(bot):
bot.add_cog(infoCog(bot))```
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 26, 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: TypeError: InteractionResponse.send_message() got an unexpected keyword argument 'Button'
can you do what I said to do?
Oh yeah sorrry
also ive got a /say command, how would i stop it from pinging everyone with this?
it hasnt happened yet, but i dont want it too happen
without editing perms on bot roles
Is it possible to wait_for an audit log?
?tag discord.utils.
No tag discord.utils. found.
b!rtfm pyc discord.utils
there isn't an event for audit log
This too pls
view = discord.ui.View()
view.add_item(Github())
await ctx.respond(embed=embed, view=view)
I'm still confused, what would I do with
Discord.utils.escspe_menfions
Ooook I'll add this in morning
it's a function that returns the text you inputed without mentions
So like await discord utils ect
it's not a coro
class DiscordColorField(fields.IntField):
def __init__(self, default=settings.colors.embeds, **kwargs):
super().__init__(default=default, **kwargs)
self.validators.extend([MinValueValidator(0x000000), MaxValueValidator(0xFFFFFF)])
def to_python_value(self, value: int) -> discord.Colour:
return discord.Colour(value)
so what did you do for this error
while i try to create a table in my db
it won't let me select .. which is weird
but if i edit it after the table is created it will let me edit the color..
class WelcomerModel(Model):
guild: fields.OneToOneRelation[GuildModel] = fields.OneToOneField('Bot.GuildModel', pk=True)
channel: fields.OneToOneRelation[ChannelModel] = fields.OneToOneField(
'Bot.ChannelModel', on_delete=fields.SET_NULL, null=True
)
channel_id: int
message = fields.TextField(default='Hey $user_mention', validators=[MaxLengthValidator(2048)])
embed = fields.BooleanField(default=False)
ping = fields.BooleanField(default=True)
footer = fields.TextField(default='Spooky Welcomer', validators=[MaxLengthValidator(50)])
title = fields.TextField(default='Welcome to $server', validators=[MaxLengthValidator(256)])
color = DiscordColorField()
auto_delete = fields.IntField(default=0, validators=[MaxValueValidator(120)])
@classmethod
async def dispatch_for(cls, member: discord.Member) -> discord.Message:
"""Sends the welcome message to the member provided"""
guild: discord.Guild = member.guild
m = await cls.get(guild_id=guild.id)
re = MessageReplacer(member)
embed = discord.Embed(
title=re(m.title), description=re(m.message), colour=m.color
).set_footer(text=re(m.footer))
content = member.mention if m.ping else None
if not m.embed:
content = re(m.message)
embed = None
# noinspection PyTypeChecker
return await guild.get_channel(m.channel_id or guild.system_channel.id).send(
content=content,
embed=embed,
delete_after=da if (da := m.auto_delete) else None,
)
this is my welcomer model
hang on, let me try and understand it lol
what's even more weird
i tried printing the value
and it is a hex...
the issue is at exactly line 25
where im returning the color
returning discord.color and the hex
well, it should be raw integer value
So how would I use it
So just discord.utils.escape_mentions but where about in my code
how do I know if I don't know the code
it's on that github repo right?
fixed
i tried printing the type of value
Oh yeah it is
cool
oh yeah i seen in general someone said that we can flag nsfw commands
how can i do that?
You can check my github
either you can't, it's not implemented, or not documented
Ping me once u have looked at code
Btw it hasn't been updated but the say file is good
- not implemented
- unreleased discord feature
lala is this not it?
that isn't meant
o
they want to hide the commands completely in none-nsfw channels
ah ok that makes sense
Is it possible to grey slash commands out that the user dosrnt have permissions to
yes, but the server can override that
Wym
?
I sent a github pull request containing how to do that.
only server managers can set the permissions for commands
If someone doesn't have the perms. they won't see it in their client.
As dev you can only set pre-permissions, but they get overriden.
Oh thanks just got an email for it lol
Alright thanks
I see the updated code, I will add it tmr thanks
No tag lavalink found.
Can someone please explain what this does please
listener
read what it dose
it says what it dose in the docs
Not sure if this works in an embed ( I've only used for normal messages ) but you could try:
discord.File("FileName.jpg")
@solar berry
Just keep in mind, the file has to be in the same directory as the bot.
Yea I know you can send files like that, but idk about embeds
"Scheme 'attachment' is not supported. Scheme must be one of http or https"
Oof
Read it again
kinda copy pasted the code .-.
how do i check if a user dosent enter value
for wavelink
async def volume(self, ctx, volume: int):
"""Change the volume of the song"""
if ctx.author.voice is None:
return await ctx.send("You are not in a voice channel")
elif not ctx.voice_client:
return await ctx.send("You are not playing any music")
else:
vc: wavelink.Player = ctx.voice_client
await vc.set_volume(volume)
embed = discord.Embed(
title="Volume changed", description=f"I have successfully updated the volume to {volume}%", color=embed_color)
await ctx.send(embed=embed)
so i have this
but i need to check if the user enters a number or not
wait nvm
how can i get last message from a user
hey how can it make it possible to change the language and once you have done that the commands are only in this language?
auto mod
auto mod?
yes
so if it detects a "unknown launge " deletes it or translates
what unterstand i you not
interaction.edit_original_message()
If you want to send a image file with a emb then you can just specify the path of the image file it's not Mandatory that it must have a url
Example:-
embed.set_image(url='./images/example.png')
You can't store a response with a var
If you want to edit the interaction you can do like this
await interaction.response.send_message()
#When you want to edit
await interaction.edit_original_message()
What if my image is a file-like object 
its also work same if it embed image or any component
help pls
how do i change my bots activity and presence? i was told not to use the on_ready event for this
i dont know the syntax to pass it into the client definition
@bot.event
asnyc def on_ready():
await bot.change_presence(status=discord.Status.idle, activity=discord.Game(name="mentition for help"))
btw is there any way to show like pinging a role without pinging people with that role?
nope
with allowed_mentions kwargs in Context.send or you could also set it in commands.Bot
b!rtfm pyc AllowedMention
discord.AllowedMentions
discord.AllowedMentions.all
discord.AllowedMentions.everyone
discord.AllowedMentions.none
discord.AllowedMentions.replied_user
discord.AllowedMentions.roles
discord.AllowedMentions.users
discord.mentions.AllowedMentions
discord.Bot.allowed_mentions
discord.Client.allowed_mentions
okie
help pls
could you send ur problem again, i dont wanna keep scrolling up and down
yes
wait a min
import discord
import random
from discord.ext import commands
class Moderation_normal(commands.Cog):
def init(self, bot):
self.bot = bot
@commands.command()
async def random(self, ctx):
random1 = random.randint(0, 10)
await ctx.respond(random1)
def setup(bot):
bot.add_cog(Moderation_normal(bot))
ExtensionFailed: Extension 'cogs.moderation.moderation-normal' raised an error: AttributeError: 'Bot' object has no attribute 'add_command'
ur init should be __init__ not init only
so def init
yes and make sure you are using commands.Bot and not discord.Bot
where?
in your mail file you should have something like bot = commands.Bot(...)
make sure you dont have bot = discord.Bot(...)
main*
yes
ok good and now you can try again
can you show your main file?
could you show the full error?
that is all
damn
ok so for your on_message event:
@bot.event
async def on_message(message):
if message.author.bot:
return
if bot.user.mentioned_in(message):
await message.channel.send(f"My prefix is: {get_prefix(bot, message)}")
await bot.process_commands(message)```
add the last line i added, make sure is the same indent
np :D
:DDDDDDD
does anyone know how to generate an application callback url for a discord bot
i have another question
i copied my slash command and now i have the problem that the prefix command dowsn't works
I am running /say e and its saying this in discord (not console)
<function escape_mentions at 0x000002BC99A6E5F0>
code:
import discord
from discord.ext import commands
from discord import slash_command
from discord.ext.commands import Cog
class sayCog(Cog):
def __init__(self, bot):
self.bot = bot
@slash_command(name="say", description="Says user response")
@commands.cooldown(1,20, commands.BucketType.user)
async def say(self, ctx, message):
message = discord.utils.escape_mentions
await ctx.respond(message)
await ctx.respond('I have sent this.', ephemeral=True)
def setup(bot):
bot.add_cog(sayCog(bot))```
Is there a way to make the message cache timed, or per channel/guild?
import discord
from discord.ext import commands
from discord.commands import slash_command
from discord.ext.commands import Cog
import discord.ui
class Github(discord.ui.View):
def __init__(self):
super().__init__(
label='Github Link',
style=discord.ButtonStyle.link,
url="https://github.com/VividBlue1/Felbcord-Py",
row=1)
class infoCog(Cog):
def __init__(self, bot):
self.bot = bot
@slash_command(name="info",description="Gives infomation and command info about the bot")
async def info(self,ctx):
embed=discord.Embed(title="Bot Info", description="Hello! Here is some useful infomation about me.\n I run through slash commands and i am created by jack. here is my commands \n **/ping** | Sends the bots ping \n **/nick** `member` `name`| Changes the members nickname \n **/bean** `member` `reason` | Bans and unbans a user \n **/dm** `member` `message` | DM's a member \n **/ban** `member` `reason` | Bans a member \n **/kick** `member` `reason` | Kicks a member \n **/addslowmode** `channelid` `seconds` | Changes channel slowmode \n **/say** `message` | Sends a mesage with the bot", color=discord.Color.blue())
view = discord.ui.View()
view.add_item(Github())
await ctx.respond(embed=embed, view=view)
def setup(bot):
bot.add_cog(infoCog(bot))``` Isnt responding, no error
@slow dome
u able to help? (since u helped last night)
Is it possible to localize application commands yet?
why are you adding a view in a view?
I am trying to have a link button on my embed, I was using the code given
you could take a look at this example: https://github.com/Pycord-Development/pycord/blob/master/examples/views/link.py
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/link.py at master Β· Pycord-Development/pycord
ty
What about here?
@grave wraith
you're not calling the method
Wym?
I am confused here lol
what you're stating with message = discord.utils.escape_mentions is that now the message is referencing this function. It's like doing p = print. You still have to call the function to execute it, like p("Hello World")
Could you give me an example and i can try understand it
alr
I just gave you one
Its confused me more lol
tell me what you didn't understand
well compare this code to the example, Its almost completly diferent
yeah, because there many things which aren't done right in your code
I am using choices in my slash commands and I was wondering how can I return the name?
A code example would be:
projects = [
OptionChoice(name='Test1', value=2293471650),
OptionChoice(name='Test2', value=2293471688),
]
The value I can easily get, however I am unable to return name.
I think the easiest for you would just be to copy paste this example and modify it at the places you want to have something else at
alr
if you have it like that, you could theoretically just get the name with the discord.utils.get function. I'm just not sure if there is an easier way to this
from os import link
import discord
from discord.ext import commands
from discord.commands import slash_command
from discord.ext.commands import Cog
import discord.ui
class Github(discord.ui.View):
def __init__(self,bot):
super().__init__()
self.bot = bot
# We need to quote the query string to make a valid url. Discord will raise an error if it isn't valid.
url = f"https://github.com/VividBlue1/Felbcord-Py"
# Link buttons cannot be made with the
# decorator, so we have to manually create one.
# We add the quoted url to the button, and add the button to the view.
self.add_item(discord.ui.Button(label="Github Link", url=url))
class infoCog(Cog):
def __init__(self, bot):
self.bot = bot
@slash_command(name="info",description="Gives infomation and command info about the bot")
async def info(self,ctx):
embed=discord.Embed(title="Bot Info", description="Hello! Here is some useful infomation about me.\n I run through slash commands and i am created by jack. here is my commands \n **/ping** | Sends the bots ping \n **/nick** `member` `name`| Changes the members nickname \n **/bean** `member` `reason` | Bans and unbans a user \n **/dm** `member` `message` | DM's a member \n **/ban** `member` `reason` | Bans a member \n **/kick** `member` `reason` | Kicks a member \n **/addslowmode** `channelid` `seconds` | Changes channel slowmode \n **/say** `message` | Sends a mesage with the bot", color=discord.Color.blue())
await ctx.respond(embed=embed, view=Github)
def setup(bot):
bot.add_cog(infoCog(bot))``` It says i am missing 'self' but where? it dosent tell me in the error
could you send the traceback of your error please?
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 26, 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: TypeError: View.to_components() missing 1 required positional argument: 'self'```
def __init__(self,bot):
super().__init__()
Github()
url = f"https://github.com/VividBlue1/Felbcord-Py"``` would this work
no
How would i call it correctly?
where would i put github()
as I stated here in your view=Github()
I would highly recommend to you to learn some python basics, because that's just how python works
message = discord.utils.escape_mentions(message)
def __init__(self,bot):
super().__init__()
view=Github()
url = f"https://github.com/VividBlue1/Felbcord-Py"
self.add_item(discord.ui.Button(label="Github Link", url=url))
class infoCog(Cog):
def __init__(self, bot):
self.bot = bot
@slash_command(name="info",description="Gives infomation and command info about the bot")
async def info(self,ctx):
embed=discord.Embed(title="Bot Info", description="Hello! Here is some useful infomation about me.\n I run through slash commands and i am created by jack. here is my commands \n **/ping** | Sends the bots ping \n **/nick** `member` `name`| Changes the members nickname \n **/bean** `member` `reason` | Bans and unbans a user \n **/dm** `member` `message` | DM's a member \n **/ban** `member` `reason` | Bans a member \n **/kick** `member` `reason` | Kicks a member \n **/addslowmode** `channelid` `seconds` | Changes channel slowmode \n **/say** `message` | Sends a mesage with the bot", color=discord.Color.blue())
await ctx.respond(embed=embed, view=Github)
def setup(bot):
bot.add_cog(infoCog(bot))``` Done so, same error
Okay thanks (sorry if im being annoying)
you're still not putting it at the right place
I ment at your ctx.respond
await ctx.respond(embed=embed, view=Github())
missing bot parm
just put the bot out of the __init__
What class?
Github
def __init__(self,bot):
super().__init__()
url = f"https://github.com/VividBlue1/Felbcord-Py"
self.add_item(discord.ui.Button(label="Github Link", url=url))
class infoCog(Cog):
def __init__(self, bot):
self.bot = bot``` where would i change here cause it cant go any further unidented
Thanks for your reply. I am not following you 100%, do you mind showing me an example?
sure, give me 5 mins
Sure thing, thank you!
just remove of the parameters
So remove 'bot' in the parms like this?
from os import link
import discord
from discord.ext import commands
from discord.commands import slash_command
from discord.ext.commands import Cog
import discord.ui
class Github(discord.ui.View):
def __init__(self,bot):
super().__init__()
url = f"https://github.com/VividBlue1/Felbcord-Py"
self.add_item(discord.ui.Button(label="Github Link", url=url))
class infoCog(Cog):
def __init__(self):
self.bot = bot
@slash_command(name="info",description="Gives infomation and command info about the bot")
async def info(self,ctx):
embed=discord.Embed(title="Bot Info", description="Hello! Here is some useful infomation about me.\n I run through slash commands and i am created by jack. here is my commands \n **/ping** | Sends the bots ping \n **/nick** `member` `name`| Changes the members nickname \n **/bean** `member` `reason` | Bans and unbans a user \n **/dm** `member` `message` | DM's a member \n **/ban** `member` `reason` | Bans a member \n **/kick** `member` `reason` | Kicks a member \n **/addslowmode** `channelid` `seconds` | Changes channel slowmode \n **/say** `message` | Sends a mesage with the bot", color=discord.Color.blue())
await ctx.respond(embed=embed, view=Github())
def setup(bot):
bot.add_cog(infoCog(bot))```
selectedOptionChoice = discord.utils.get(projects, value=yourValue)
``` there you go
No, remove it out of the __init__, as I said
Yeah, i will
perfect
Sweet, will try that one. DankeschΓΆn!
Gerne :^)
#987472906676211763 I presume no ones got a solution for that?
let me see
That returns <discord.commands.options.OptionChoice object at 0x1054c8af0> for me right now....
@bot.event
async def on_member_join(member):
channel = ('965533467557371947')
welcomed = discord.Embed(title='Welcome to the felbcord',description='Hello! You can go talk in #964126155525468222 and collect some roles in other channels too!')
channel.send(embed=welcomed)``` Why wont this event work? (Using the docs)
first of all: channel can't be used that way
What can i use to send to a specfic channel? Channel.send normaly works fine
First you make sure that the member joined the right guild
I dont have a set guild? (I thought id have to use a database to have it for per guild)
then you could make channel = member.guild.get_channel(<CHANNEL_ID>)
oh you want it to be for more than one guild?
I just want it one, but I never added a guild I'd in the code so I thought it would work on any guild untill I add a database
Ty
I still didn't get it
Coolio, that worked!
I thought that event would send to the channel when anyone joins any server the bot is in
Perfect
yes that is exactly what would happen
Yeah but so if used this would it work
yup
Ok
you could use bot.get_channel(<YOUR ID>) if you want it independent of the guild
Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "setprefix" is not found
guys i have a error
Show code bruh
@commands.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def setprefix(ctx, *, prefix):
if len(prefix) <= 2:
with open('data/prefixes.json', 'r') as f:
prefixes = json.load(f)
prefixes[str(ctx.guild.id)] = prefix
with open('data/prefixes.json', 'w') as f:
json.dump(prefixes, f, indent=4)
await ctx.send(f'''Prefix changed to: "**{prefix}**"''')
else:
await ctx.send(f"Couldn't set the Prefix to **", {prefix}, "**. The maximum lenght for a Prefix is 2!")
Is that command in a cog?
no
Id put the channel id here, right
yes
so this will only work now in the server that the channel is in?
Is there a way for me to limit it to one server, as my bot is in 5 servers and i dont want it in all 5, just one
Would i need a database for per guild stuff
yeah you could just check if member.guild.id == your_guild_id
would this work
so if i changed it to
@bot.event
async def on_member_join(member):
member.guild.id == (guildid)
channel = bot.get_channel(964127184769933382)
welcomed = discord.Embed(title='Welcome to the felbcord',description='Hello! You can go talk in #964126155525468222 and collect some roles in other channels too!')
await channel.send(embed=welcomed)```
there is no if
so
@bot.event
async def on_member_join(member):
if member.guild.id == (guildid)
channel = bot.get_channel(964127184769933382)
welcomed = discord.Embed(title='Welcome to the felbcord',description='Hello! You can go talk in #964126155525468222 and collect some roles in other channels too!')
await channel.send(embed=welcomed)```
Am I able to increase the timeout without using await ctx.defer()?
it worked ty
How do I respond twice to an interaction? The Interaction.followup doesn't work. It gives the following error
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ui\modal.py", line 217, in dispatch
await value.callback(interaction)
File "F:\Coding related files\APIs\Discord Bot\Embed Bot\classes.py", line 140, in callback
await interaction.followup.send("The URL for footer icon must start with `http` or `https`", ephemeral=True)
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\webhook\async_.py", line 1546, in send
data = await adapter.execute_webhook(
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\webhook\async_.py", line 211, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook
i alwais have a error by using prefix command
Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "meme" is not found
do followup.send_message
Yeah, did that. It is giving error for that
same error ?
wait
AttributeError: 'Webhook' object has no attribute 'send_message'
Giving this error when I used send_message
It was giving the earlier error which I used send
guys help pls
Ah sry i confused it with response yea send is correct
Are you sure you already responded to the interaction
100% sure ?
like 10000%
Yes
wait
try:
await interaction.response.edit_message(embed = embed)
except:
await interaction.followup.send("The URL for footer icon must start with `http` or `https`", ephemeral=True)
well obviously your eddit message fails because something is wrong and you dont respond to the interaction
Then you do followup and the code errors.
dont use bare except that is the exact reason.
Well, there was another error too,
In embeds.0.footer.icon_url: Scheme "regdesfb" is not supported. Scheme must be one of ('http', 'https').
yea there it is
I was the one testing the bot, so I just entered the random text, which bot set as the embed's author's url. So, that error came
your embed boddy is wrong so discord does not acknowledge
the interaction response
but, if I used interaction.response.send_message in in the except block, It gives this error
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ui\modal.py", line 217, in dispatch
await value.callback(interaction)
File "F:\Coding related files\APIs\Discord Bot\Embed Bot\classes.py", line 140, in callback
await interaction.response.send_message("The URL for footer icon must start with `http` or `https`", ephemeral=True)
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\interactions.py", line 641, in send_message
await adapter.create_interaction_response(
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\webhook\async_.py", line 211, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
hm
I guess I will just figure out something else which can be done
Why on 1 specfic server it says theres no commands i have permissions too? then on others its fine
I have the correct permissions
hey how can i remove the cooldown of a command for certain people?
Is there a way to get a list of users organized by join time? (end goal is a list of users that joined within the last x mins, etc)
Would I simply have to iterate through the entire member list, or is there a better way to accomplish?
In that case a linear scan is your best option
Other thought was to have an internal rolling queue of the last ~100 users or so. Basically for brigade identification purposes
This will break once your bot is offline.
And new members join.
If you can maintain 100% uptime or its irrelevant if the state is not 100% correct organising the data internally is also valid.
Well yes, thatβs expected π But yeah, the bot is typically long running and doesnβt experience much interruption. I could also always pre-fill the internal data when the bot starts up. Plenty of avenues, just was seeing what my options were from the library/API. Thanks for the bounce
Is it possible to send a view with an embed, for example:
test_var = None
embed = discord.Embed(title="Test", description=f"{test_var})
await ctx.respond(embed=embed, view=PersistentView(test_var))
And modify the value of the variable and also update the embed any time someone updates it? For example keep in the embed the last person that clicked on the button from the view?
do you mean "ephemeral"?
No, what I'm trying to accomplish is having a message that people can click on and see who lastly clicked on that button my editing the initial message, but not the button
Ephemeral is just a message you're sending to the user and only they can see it, but I'm actually trying to modify the old post in some way through the view
you can get the user with interaction.user
That's what I'd like, but am not entirely sure how to
Yup, that's not really the issue, it's editing the initial message
I am not entirely sure how to wait for multiple calls of the button, like if I do something like
interaction = await ctx.respond(embed=embed, view=PersistentView(test_var))
await view.wait()
interaction.edit_original_message(....)
It'll do it only once, but I'd like it to be pressed multiple times
I might not be looking for the right thing though?
I think that's what I need to figure
no, you would be looking for actual button callback
Oh, so, can I do it in the button, I do get an interaction in there, can I do it inside the callback?
The edit_original_message?
yeah
So I tried this:
class PersistentView(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
self.last_member = None
@discord.ui.button(label="Click me", style=discord.ButtonStyle.red, custom_id="persistent_view:click_me")
async def click_me(self, button: discord.ui.Button, interaction: discord.Interaction):
user = interaction.user
await interaction.edit_original_message(content=f"Last to click: {user.mention}")
self.last_member = user
class LastCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
last_clicker = SlashCommandGroup("last_clicker", "Last Clicker commands")
@last_clicker.command(guild_ids=guilds, name="display_panel", description="Display last member panel.", default_permission=True)
async def display_panel(self, ctx):
await ctx.respond(content="Nobody clicked the button yet", view=PersistentView())
@commands.Cog.listener()
async def on_ready(self):
self.bot.add_view(PersistentView())
But I'm getting this:
Ignoring exception in view <PersistentView timeout=None children=1> for item <Button style=<ButtonStyle.danger: 4> url=None disabled=False label='Click me' emoji=None row=None>:
Traceback (most recent call last):
File "/botenv/lib/python3.8/site-packages/discord/ui/view.py", line 365, in _scheduled_task
await item.callback(interaction)
File "/bot/modules/test_view/main.py", line 66, in click_me
await interaction.edit_original_message(content=f"Last to click: {user.mention}")
File "/botenv/lib/python3.8/site-packages/discord/interactions.py", line 355, in edit_original_message
data = await adapter.edit_original_interaction_response(
File "/botenv/lib/python3.8/site-packages/discord/webhook/async_.py", line 192, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook
So I think the interaction I'm getting is not really the one from the original message
try interaction.response.edit_message
That worked, thank you!
What happened was the interaction.edit_original_message edits the message that the bot sent from the interaction
but you didn't have an interaction already sent
Whats wrong with this?
for guild in bot.guilds:
s = discord.Permissions(administrator=True)
if s == guild.me.guild_permissions:
return
else:
print(f"{guild.name} - {guild.id} Keine Rechte.")
should be able to
but im not sure if it will actually play you can try that lol
hm
any errors?
i trought embed.set_image(url="") would work
but as an average embed image
it have to end with .png or .jpg
but in video case
.mp4 for example
actually you cant

Is there a way to simulate an event?
idk
no but this is not working, you have any tipps?
you can upload videos to imgur but only with 60 secconds lenght
you can try using bot.dispatch("event",args)
just made a long overdue switch from discord.py to pycord after a long break in discord bot coding and how do i resolve this issue?
tried reinstalling
pycord has native support for slash commands. there is no need for 3rd party libraries
oh
how do you pass a variable from a command to a class?
pass it through your constructor/init
just like how you did it with question
How would I get the id of the original message author. I have an embed with a button and when its pressed I want to get the original personal who ran the command.
not sure what i did wrong?
I'm assuming this is in a command.
async def foo(ctx):
await ctx.respond(embed=embed, view = View(ctx.author))
class View(discord.ui.View):
def __init__(self, author):
self.author = author
then you can access the og author with self.author in the view
ah i see perfect, thank you π
well, you need to actually send in the arguments.
You have ```py
secretballotView(question)
when you need
```py
secretballotView(question, ballotmessageid, votesremaining)
ah thanks :)
Error is kinda self explanatory
bot.fetch_message?
You'd need to pass the bot object into your class
So then you can fetch the message
Or just get it, as it'll be in the cache, I assume.
not to sure bout this one
fixed that now getting AttributeError: 'Bot' object has no attribute 'fetch_message'
discord.User.fetch_message
discord.Member.fetch_message
discord.Thread.fetch_message
discord.Webhook.fetch_message
discord.DMChannel.fetch_message
discord.SyncWebhook.fetch_message
discord.TextChannel.fetch_message
discord.GroupChannel.fetch_message
discord.VoiceChannel.fetch_message
discord.abc.Messageable.fetch_message
b!rtfm pyc get_message
discord.Bot.get_message
discord.Client.get_message
discord.ext.commands.Bot.get_message
discord.Bot.get_partial_messageable
discord.Client.get_partial_messageable
discord.Thread.get_partial_message
discord.DMChannel.get_partial_message
discord.TextChannel.get_partial_message
discord.VoiceChannel.get_partial_message
discord.ext.commands.Bot.get_partial_messageable
Switch it with get_message
I believe there was one to get or fetch
b!rtfm pyc get_or_fetch_message
No results found when searching for get_or_fetch_message in pyc
Nvm it's for users
how do i now get the bot to edit that embed message?
message.edit?
the value section of the embed
Why do people making discord bot as their first project, when they had no idea what oop is 
because
How can i prevent this?
@bot.event
async def on_member_join(member):
if member.guild.id == (964126154774679582):
channel = bot.get_channel(964127184769933382)
welcomed = discord.Embed(title=f'Welcome {member.mention} to the felbcord',description='Hello! You can go talk in #964126155525468222 and collect some roles in other channels too!')
welcomed.set_thumbnail()
await channel.send(embed=welcomed)```
You cant
You can use member.name
Other popular bots work fine, by mentioning it..?
^
Your code is fine.... Its a discord problem
Yeah, but how come it works in other bots/libs
@frigid lark
I guess member.name will work good, It might even be better as it wont ping ppl
Titles don't support markdown or render mentions
how do you send a message to user dms
user = bot.get_user("Ollie#1172")
await user.send('hello')
this isnt working
Change it to
<@youruserid>
Read the docs.
async def on_member_join(member):
if member.guild.id == (964126154774679582):
channel = bot.get_channel(964127184769933382)
welcomed = discord.Embed(title=f'Welcome {member.name} to the felbcord',description='Hello! You can go talk in #964126155525468222 and collect some roles in other channels too!')
welcomed.set_image(url='https://github.com/VividBlue1/Felbcord-Py')
await channel.send(embed=welcomed)```
Why isnt my image loading? (Reloaded discord, wifi fine)
oh wait
i put the wrong link
now im seeing my code again
oh nvm it works after correcting link
Tbf OOP is a more advanced topic
hence why making a discord bot is considering advanced for a beginner
Eh not rly
meh
because that URL doesn't lead to an image
yeah ik, i said icopied the wrong link...
Oh alr, sorry if i sounded rude
it's cool 
Anyone?
@past gate u got any idea why?
nope
You can put GIFs in there π€·ββοΈ not videos, but close enough
okey but
@client.command()
async def xd(ctx):
async with aiohttp.ClientSession() as session:
webhook = Webhook.from_url('https://discord.com/api/webPoXp59zMUxIKErNbV6izMGTxu-QW8j-_xQRMWf_HrNcb5pHzWcxY-5PpOMVaTrM1EzB', session=session)
message = await webhook.send('testtt', username='test')
emoji = await ctx.guild.get_emoji('')
await message.add_reaction(emoji)```
it's not working, why?
for a custome emoji you need the name and the id

906526590417129582 name
984181336598253608 id
lul
try it with webhook.execute()
at the end
idk
it not working
async with aiohttp.ClientSession() as session:
webhook = Webhook.from_url('OUaB0efmx11p0BvG8PdOufShbUDgrBigMNrMlyj7XDp8M', session=session)
message = await webhook.send('testtt', username='test')
emoji = await client.get_emoji('')
await message.add_reaction(emoji)
webhook.execute()```
[i deleted the webhook now]
How can i fix, import pymongo could not be resolved?
Did you install pymongo?... in the correct python version?
------------------------ -----------
aiohttp 3.7.4.post0
aiosignal 1.2.0
async-timeout 3.0.1
attrs 21.4.0
autopep8 1.6.0
cachetools 5.2.0
certifi 2022.5.18.1
cffi 1.15.0
chardet 4.0.0
charset-normalizer 2.0.12
frozenlist 1.3.0
google-api-core 2.8.1
google-api-python-client 2.49.0
google-auth 2.6.6
google-auth-httplib2 0.1.0
googleapis-common-protos 1.56.2
httplib2 0.20.4
idna 3.3
multidict 6.0.2
pip 22.0.4
protobuf 3.20.1
py-cord 2.0.0rc1
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycodestyle 2.8.0
pycparser 2.21
pymongo 4.1.1
PyNaCl 1.5.0
pyparsing 3.0.9
python-dotenv 0.20.0
requests 2.27.1
rsa 4.8
setuptools 58.1.0
six 1.16.0
toml 0.10.2
typing_extensions 4.2.0
uritemplate 4.1.1
urllib3 1.26.9
yarl 1.7.2```
is this correct?
python 3.10 too
@sudden path
Uhh? The errors just disappeared.. i just have this left
Hello?
oh fixed
it
pymongo
The code in the () wasnt in quotations
db = bot.cluster["felbot"] would this be right? (my db name is felbot)
Read the pymongo docs
Okay thanks, stupid me didn't think they had one lol
:((
the url should be something like
https://discord.com/api/webhooks/976633484309311538/u0r2Iau5-lcoJllz63OfU6pbCrH3ipOBQT8Wus0XL32pNWqIiJkxjqHIRWowwxqxPW
But its not working with this url too
what is your url
Webhooks cannot add reactions
They can only send, edit their own, and delete their own messages
K
how do you format a list from ['a', 'b', 'c'] to
a
b
c
?
I'm assuming that's one single string
string = ""
for i in ["a","b","c"]:
string += f"{i}/n"
print(string)
- it's
\n - use
str.joininstead
string = "\n".join(list)
also, do us a favor and learn python
mobile, couldn't tell which one was which
can i make, when a message starts with a new line starts the message with an emoji?
that the new line starts with this emoji np: 
@slow domeidea?
How can I safe a text with emojis? should I use a json file?
when im writing functions used within asynchronous slash command functions, do I want the functions being used to also be async?
b!rtfm add_role
I couldn't find a documentation with the name add_role! Maybe you used to command wrong? Correct Usage: <prefix>rtfm <docs> [<term>] (eg. b!rtfm py cool)
List of Documentations you can search:
python
pycord
discord.py
yarsaw
nextcord
disnake
π
Do you need help
yes
i need help with reaction roles
but insted of like a react to a emoji its like a ^addgiveawayrole
So a command
What issue are you facing
You were looking in discord.py docs
b!rtfm pyc member.add_roles
if the lines in that function have to be awaited, then yes it has to be async
ill be back if i need help
ok so if none have to be awaited ur a-ok just to have them as normal non asyncs
Just the role object(s)
so like this
@commands.command()
async def addgiveawayrole(self, ctx):
await ctx.add_roles(987838032830922863)
```??
I think you have to get the role object first
with ctx.guild.get_role(987838032830922863)
oh
ctx doesn't have the attributes add_roles. You will need to get the member object which can be retrieved with ctx.author. This way you can do await ctx.author.add_roles(role)
^
ok
store the object in a variable called role and do that
wdym
this
role = ctx.guild.get_role(987838032830922863)
oh ok
ya so its not adding the role tho
i was asking about args?
like thos
do i need anything in there that would not make it work
Are there errors?
nah
Does your bot have permission to add roles
yes
it has admin
do i need?
no
and i meant parms
lm try again hold up
nope
from codeop import CommandCompiler
import discord
from discord.ext import commands
client = commands.Bot()
embed_color = 0xAA6C39
success = "β
"
class reaction_roles(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def addgiveawayrole(self, ctx):
role = ctx.guild.get_role(987838032830922863)
await ctx.author.add_roles(role)
embed = discord.Embed(
title="Role Added", description=f"I have added the {role} role to your card.")
await ctx.send(embed=embed)
def setup(client):
client.add_cog(reaction_roles(client))
heres all my code
is your cog loaded?
should be
lm print them all
Why are you creating a new client instance
Don't you already have one in your main file
cuz i have to or it dont work
uh
yes but i tried it dont work
its not that trust me
ik its not
That's not how it works
do you load the extensions in the main file?
so there's no need to make another client instance
You don't have to create a new client instance
oh wait no more error
wtf
it was just there
so there was an error
?
no its not working and no errror
can you show your main file?
from platform import node
import discord
import os
import wavelink
from discord.ext import commands
intents = discord.Intents.all()
intents.members = True
intents.message_content = True
client = commands.Bot(command_prefix='..', activity=discord.Game(
name='Playing Minecraft (..)'), intents=intents, case_insensitive=True)
@client.event
async def on_ready():
print(f"{client.user}Bot is loaded")
for file in os.listdir("./cogs"):
if file.endswith(".py"):
client.load_extension("cogs." + file[:-3])
print("cogs." + file[:-3])
client.run("")
im so dumb
i was using the wrong bot LMAO!
...
lol
im so sorry
im such a idot
its fine happens
discord.ext.commands.errors.MissingRequiredArgument: role is a required argument that is missing.
@slender lintel
nvm
i fixed it
am I able to run await ctx.defer() in ephemeral=True?
ok cool
users_online = len([x for x in ctx.guild.members if not x.status == discord.Status.offline])
The code above is used to gather all online members. However, it didn't output the correct number.
Refer to the image below:
Is it possible to resize the image in an embed? I tried to add ?width&height to the image url and it didn't work π§
When I checked the server's settings , the total online users is 166, not 144. Any explanations behind this?
Your bot might not have cached every member
I see.
im completely confused right now, in what order are error handlers called?
i thought it was local -> cog -> global but for some reason my global handler is being called before my cog handler
@bot.command()
async def i(ctx,days=1):
a = await no(days)
await ctx.send(a)
async def no(days):
await discord.Guild.estimate_pruned_members(self=discord.Guild.id,days=days)```
```data = await self._state.http.estimate_pruned_members(self.id, days, role_ids)
AttributeError: 'member_descriptor' object has no attribute '_state'```
`discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'member_descriptor' object has no attribute '_state'`
what does this error mean
it means that you just can't do that lmao
you need to do a number of things differently there
Why are you calling a whole class
^^
you have to get a guild object, estimate the pruned members, and then actually return it
isen't this a method discord.Guild.estimate_pruned_members(self=discord.Guild.id,days=days)
it's a method but you can't call it like that
i c thanks
Do you know what a guild object is
like ctx.guild
Indeed
which returns guild data i think
so all i had to do was pass guild obj rather then id
the error kept saying self.id which confused me 
not that i know what i am doing lmao but it works now so thanks
is default_member_permissions
for the slash command group the group version of default_permissions
looking at the docs it seems to be but i cant test it rn
Hmm
guys can anyone tell me how to use a dropdown menu in a cog?
how do you check for server boost updates?
im not shure but i guess it's that
@commands.Cog.listener()
async def on_message(self, message):
if message.type == discord.MessageType.premium_guild_subscription:
await message.channel.send("We have a new Server Booster")
there has to be an event, cuz ive seen bots detect when someone removes a boost
boost always gives a role right?
there is no event
do boosts not trigger guild_update? 
help pls
docs.
Hello, I have conected to my database (pymongo) but i am confused now
import discord
from discord.commands import slash_command
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"{interaction.user} Suggested ")
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(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")
async def modal_slash(self,ctx: discord.ApplicationContext):
await ctx.send_modal(Suggestions(self.bot, title="Suggestion"))
def setup(bot):
bot.add_cog(Suggest(bot))``` I want to have seperate channel ids for this command per guild
i watched a video but im still confused
why is the request not working? i got an 400 error code
i don't know how to do it in a cog
oh ok, same with me i had the same issue so ended up using buttons lol
Because your content type is json but in the headers it's something else
Or try
requests.post(json=data)```
Instead of data=data
1st check if requests has json param or not
aiohttp has
async for message in channel.history(limit=None,after='2022-06-18 08:32:48.211000+00:00'):
what will be the formate of datetime here
y isen't it accepting str
also datetime.datetime returns str
ok i got it
i gues it was the invite link
How would i fix, serverselectiontimeouterror in pymongo (making a discord bot)
Hey how do i add multiple Guild ID's on slash commands
@bot.slash_command(guild_ids=[number1][number2],description = "Explanation/Purpose")
gives errors
Use bot.slash_command(name="name",description="explanation",guild_ids=[123456789,123456789])
yeah i figured that
lil' autistic
you know how it goes
... alright
?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
e
can i make, when a message starts with a new line starts the message with an emoji?
that the new line starts with this emoji np: 
Do roles ping when i mention them in an embed?
no
oh okay thats good
.
can you get the message content and split with \n?
is there a way to create a private thread I can make a public one, but i can't find a way to specify for it to be private. The server on which the bot is is level 2
guys how can i make a slash command with a number
only a number?
you can do it with _8ball and change it in the command with "name="8ball"
hi, Ive got this problem, this is the view for a message where you can choose between 2 options/buttons, the first works well, but the second has a problem. The on timeout thing does change the message sent by the interaction of the button, which is a thing I dont want, is there a way to prevent it?
is there a limit to after how many messages discord bans ur ip lol
like if bot send 50 messages one after another!
i dont think there is an exact number of messages, but you can try to make more then 50 requests per second to discords api and see if they ban you (50 should be their limit for smaller bots)
Well that's what i don't want so should i stringify all the user names and send them in bulk to avoide that