#General Help
1 messages · Page 17 of 1
yo
how do i make bot generate timestamp codes
like this <t:1654916400:d>
an then i just replace like this
await ctx.respond(f"<t:{tmstp}:d>")
but how do i generate these codes
theres an api for this?
Use the time module
?tag lp
Official Beginner's Guide: https://wiki.python.org/moin/BeginnersGuide
Official Tutorial: https://docs.python.org/3/tutorial/
Shortcuts:
https://wiki.python.org/moin/BeginnersGuide/NonProgrammers
https://wiki.python.org/moin/BeginnersGuide/Programmers
Learn Python:
https://automatetheboringstuff.com/ (for complete beginners to programming)
https://learnxinyminutes.com/docs/python3/ (for people who know programming already)
https://docs.python.org/3/tutorial/ (official tutorial)
http://python.swaroopch.com/ (useful book)
http://www.codeabbey.com/ (exercises for beginners)
Is there a way after reading a embed to send the same exact embed as an embed in a other Chat?
you mean it takes an embed from X and resends it to N?
yea
Yes
just grab the embed from message.embeds and send it into other channel
^
I get this (if i read the embed)
Huh lemme check
would it be for every embed sent in that channel/server?
Nah just for 1 Channel but i know how to filter out Channels
Is there a way to recreate the "to_dict()" to the orginal?
Actually it is:
embed=discord.Embed.from_dict(THE_DICT))
@ornate fog Thanks mate, i have everything i need to work with now :)
I got a slash command that im using @commands.guild_only() on to make it only work in guild.
When someone tries to use the command in dms it'll throw:
discord.ext.commands.errors.NoPrivateMessage: This command cannot be used in private messages.
I want the slash command respond with something like "use command in a server please". This is in a cogs
@commands.Cog.listener('on_command_error')
@commands.Cog.listener('on_error')
async def on_command_error(ctx, error):
if isinstance(error,discord.ext.commands.NoPrivateMessage):
await ctx.respond('Command only works in server',ephemeral=True)
I tried this but this doesnt execute
gotcha
No tag top_role found.
?rtfm top_role
b!rtfm pyc top_role
@slender lintel
Hey, is it possible to remove the cooldown of a command for certain players?
Is it possible to make the slash command name in of itself a slash command?
ie, if i have a slash command group where all the commands are /date XYZ, is it possible to make a command that is just /date?
that is part of that slash command group?
HELOHELP ME HERE: SO EONE PLS: https://discord.com/channels/881207955029110855/984744337629921291
is there a way to have more than 25 option choices?
Ye by auto complete
wym?
https://github.com/Pycord-Development/pycord/blob/master/examples/app_commands/slash_autocomplete.py
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/slash_autocomplete.py at master · Pycord-Development/pycord
ty
can i also not have optionchoices defined inside of my command?
``
import discord
import datetime
from discord.ext import commands
class auto_mod(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_message(self, message):
duration = 900
bad_words = []
for Shit in bad_words:
if Shit in message.content:
duration = datetime.timedelta(minutes=duration)
await message.author.timeout_for(duration)
embed=discord.Embed(title="Bad word detected ❌", color=discord.Color.dark_gold())
await message.channel.send(embed=embed)
def setup(client):
client.add_cog(auto_mod(client))
so i have this right but uhh how can i check for multiple words
in sted of 1
i mean by this whats the best way?
././.,/.,/
in the same line of if Shit in message.content add continue and i dont get what for Shit in bad_words and if Shit in message.content tbh
Why the self param of button class don't stores data?
from discord.ext.commands import Cog
class tags(Cog):
def __init__(self, bot):
self.bot = bot
@slash_command(name="verifyhelp", description="Sends bot ping")
async def verifyhelp(self, ctx):
await ctx.respond('If you are needing some help verifying with skykings, Heres some help! \n Use /verify hypixel then your username \n make sure to connect your discord account to hypixel ')
def setup(bot):
bot.add_cog(tags(bot))``` Why do i get interaction slash command or smth
interaction failed slash command
nvm
Hi, I am trying to use the @tasks.loop decorator but the function never runs, and I'm not sure why
@tasks.loop(minutes=2)
async def _gather_guilds_for_weekly_leaderboards(self):
print("task loops yay")
self.logger.info("Gathering guilds for weekly leaderboards")
This is my current setup and the print never prints (i have confirmed that my logger works)
Did you start it?
default_member_permissions does not work with SlashCommandGroup.command
it does not hide the slash command
Does it not start with the bot?
ConnectionResetError: Cannot write to closing transport Why am i getting this error?
Are you able to provide any traceback?
Yeah, one sec
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 21, in on_ready
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name='Over The Felbcord'))
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 1179, in change_presence
await self.ws.change_presence(activity=activity, status=status_str)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\gateway.py", line 667, in change_presence
await self.send(sent)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\gateway.py", line 627, in send
await self.socket.send_str(data)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\aiohttp\client_ws.py", line 150, in send_str
await self._writer.send(data, binary=False, compress=compress)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\aiohttp\http_websocket.py", line 687, in send
await self._send_frame(message, WSMsgType.TEXT, compress)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\aiohttp\http_websocket.py", line 598, in _send_frame
raise ConnectionResetError("Cannot write to closing transport")
ConnectionResetError: Cannot write to closing transport```
!tag on_ready
dont do shit in on ready
It used to work fine? I havent changed it at all
Its only a chance to be getting disconnected
Set your status on construction tto send it with identify payload.
It's pseudo-random, the error you are getting is caused by the activity update contained within on_ready, move it to the constructor and it'll be fixed.
alr, i moved it to the bot = part
Should work now
ok so my memory keep raising up, is that what memory leak mean? 
It might just be the cache and therefor not a memory leak
E.g. with each message, the client might store the message object and thus the memory rises
yo how do i add arguements / options in slash commands
i seen a video and they do from discord import Option
but that isnt a thing is it?
Here's the slash options example.
@lucid cove look at this example and if you have more questions ask them here again :)
shouldnt age be int?
or can arguements be str only?
That is either a typo or the option takes an int and converts it to a string. I think it should be int tho
yeah it should be int
hey guys
how can i give a button a time limit to be clickeed
and to be clicked only by the command OP
is the members property of a guild meant to return the entire list of members in a server? it seems like when I use it, it only returns the members that are relevant for the interaction, so the bot and the user that called it.
nevermind, found my issue. need the members intent
how many maximum embeds can i send in a paginator's single message ?
how to make a button unclickable?
disable it
um how?
i know i can disable it but i forgot
@discord.ui.button(label="Grey", style=discord.ButtonStyle.grey, custom_id="persistent_view:grey",disable=True)?
yes
okie
okie
we cant add more than 5 fields in modals
how do i solve that problem
i want more questions
api limitation. you cant do that
hm
i tryed to add more options by doing a command option then send the modal but i cant link them
like for example
/embed button_name: hello button_link: coollink.com
then it send's the modal with more options
my modal have the following options:
title, description, footer, color and thumbnail
for embed generator
how can i check the hierarchy to check if a user can ban another?
So you basically want to create a command to ban a user if their role is below the author (who ran command)'s top role?
Yeah.
b!rtfm pyc highestRole
No results found when searching for highestRole in pyc
b!rtfm roles.highest
I couldn't find a documentation with the name roles.highest! 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
b!rtfm pyc roles.highest
No results found when searching for roles.highest in pyc
hmm
gimme a sec
Basically:
-
grab author's roles
-
grab members role
-
You're grabbing the highest role. I believe this is the "first" thing in the list
-
However i think theres a rop role position
Compare with guild.roles which returns a list of roles but instead the list is lowest to highest
https://docs.pycord.dev/en/master/api.html#discord.Guild.roles
Okay, needed some help. How do I reply to a slash command?
b!rtm pyc slash commands
b!rtm pyc slash commands
Bru
@desert dagger will this work?
wdym by that?
do you mean like. Run command, it waits for a response?
Try it and see
In theory it should work
@ancient gazelle which one? i asked two questions XD
Like How to I make it respond to the command. Like it should show <bot> is thinking... and reply to it after that.
ctx.defer() and ctx.respond('message) or ctx.respond(embed=embed)
That's really basic stuff, check the docs
Here's the slash basic example.
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/slash_basic.py at master · Pycord-Development/pycord
Yeah, just switched from discord.py @desert dagger So a bit to take on.
@slender lintel
Oh sorry
Hi I just wanna ask how do I make / commands public and global because my command rn ```py
servers = [977632897840349204, 981237860734742539]
@client.slash_command(guild_ids=servers, name='ping', description='Macht pong und zeigt die Verzögerung an!')
async def ping(ctx):
embed = discord.Embed(
title="Pong!",
description=
f"{round(client.latency * 1000)} ms Verzögerung :slight_smile:",
color=0xA020F0)
await ctx.respond(embed=embed)```
only work in 1 server
even tho i set to 2
^
debug_guilds in your Bot() means all commands you make are going to be ran only in that guild and that your slash command will "refresh" quicker since you're using it for debug purposes not production
guild_ids=[] is what you use to restrict command to guild.. I think the command works in dms?
So I should just remove this line
[text](url here)
Yes
Normal messages are impossible sadly
its a Embed thing and must be done by a bot for obvious reasons
basically remove all of your guild_ids or debug_guilds unless you want the command to be restricted to that guild
ok
That'd make your command a GLOBAL one
Just remove it all as 5heu said then if you want a certain command to be guild only add the guild I'd part to it
^^
btw sorry for bad spelling, was on phone and it was rly annoying auto correct
it happens
Is it normal that after 20m i still don't have the cmds
Hey, ```import discord
from discord.commands import slash_command
from discord.ext.commands import Cog
class tags(Cog):
def init(self, bot):
self.bot = bot
@slash_command(name="tagverify", description="Sends bot ping")
async def tagverify(self, ctx):
embed=discord.Embed=(title='Verification Skykings', Description='You can use this Tutoiral to verify',color=discord.Color.blue())
await ctx.respond(embed=embed)
def setup(bot):
bot.add_cog(tags(bot))``` Why am i getting error, ( was not closed
btw the yt link is an unlisted video lol
Are you getting any errors? if not try re-inviting the bot (also make sure to restart ofc)
no errors, reinvited, restarted and my friends server gets the cmds for some reason
May you show me the code?
Oh bruh notepad somehow missed to replace 1
💀
fixed
nice
Anyone know?
what error?
also @commands.slash_command was gonna say you'd use it like this except you got the import
Its a cog
and the error is
( was not closed
i realised
ah i see
actually
embed=discord.Embed**=**(title='Verification Skykings', Description='You can use this Tutoiral to verify',color=discord.Color.blue())
yeah?
embed=discord.Embed=discord.Embed=(title='Verification Skykings',
me reliasing ive broke this
1 sec
why tf did i type that same thing so many times lmao
lul
The above exception was the direct cause of the following exception:
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: TypeError: Embed.__init__() got an unexpected keyword argument 'Description'``` Why do i get this error? (same code but removed the bit i typed too much)
@slash_command(name="tagverify", description="Sends tutoiral")
thats right isnt it?
one sec
em= discord.Embed(title='Verification Skykings',
description='You can use [this](https://youtu.be/ahUXZT5VyDY) Tutorial to verify',
color=discord.Color.blue())
ctx.respond(embed=em)
?
oh
I got the description part sorted, just confused what u mean about this
Hello, i wanted to create Options in my Slash command but for some reasons i'm getting this error at the start of the bot:
discord.errors.ExtensionFailed: Extension 'cogs.tests' raised an error: TypeError: object of type 'type' has no len()
CODE:
@slash_command(description="check")
async def checking(self, ctx, user:Option(discord.User, "User")):
await ctx.respond(f'{user}',ephemeral=True)```
Python is case sensitive.
you're doing embed = discord.Embed=()
as Dark said. A lot of this stuff is case sensitive
I usually avoid making my embeds be named embed but if you want to then fair. I prefer variables to mean something
Okay thanks
if your code gets bigger and you go "hey i want to find my embed for verification" you'd need to Ctrl F "embed" and scroll thru a ton of lines that use the word embed
whereas if you did "verificationEmbed" or "verify_embed" then you can find it quicker
ctrl+f the command name smh
Just pointing out why naming variables is a useful thing to do
Yeah good point
I still need help, if anyone knows an answer please tell me.
share full traceback (error)
Traceback (most recent call last):
File "C:\Users\Klaro\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 711, in _load_from_module_spec
spec.loader.exec_module(lib) # type: ignore
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "a:\dc bot\cogs\tests.py", line 6, in <module>
class TEST(commands.Cog):
File "a:\dc bot\cogs\tests.py", line 11, in TEST
async def checking(self, ctx, user:Option(discord.User, "User")):
File "C:\Users\Klaro\AppData\Local\Programs\Python\Python310\lib\optparse.py", line 570, in init
self._set_opt_strings(opts)
File "C:\Users\Klaro\AppData\Local\Programs\Python\Python310\lib\optparse.py", line 594, in _set_opt_strings
if len(opt) < 2:
TypeError: object of type 'type' has no len()
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "a:\dc bot\main.py", line 143, in <module>
bot.load_extension(f"cogs.{file[:-3]}")
File "C:\Users\Klaro\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 783, in load_extension
self._load_from_module_spec(spec, name)
File "C:\Users\Klaro\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 714, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.tests' raised an error: TypeError: object of type 'type' has no len()
hm
i'm using py- 2.0.0b7 btw
can you not use rc1?
pip install py-cord==2.0.0rc1
lemme do that
also heres my example
import discord
from discord.ext import commands
class Testing(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.slash_command(description="check")
async def checking(self,ctx, user: discord.Option(discord.User, "User")):
await ctx.respond(f'{user}',ephemeral=True)
def setup(bot):
bot.add_cog(Testing(bot))
i dont seem to get your len error from it
me 2, it is working now i guess it was an issue with my Version. Thank you a lot
well it looks liked you helped yourself out when u mentioned the version o7
use discord.Member
Yeah, i wasn't updating it for a while
Doesnt rly matter in this instance
he just wanted to print out the user when checking
which version is installed?
He was using one Version below rc1
Yeah for testing if it actually works, later in the cmd i just need the user id
Mk
Btw, Whats the difference between user and member?
isnt it the same
is it used for user id or?
User is basically Discord user
Member is User in guild
A Member is a User
Ohh alright
so for example if ur banning someone, you can use member to ban members outside of the server and member inside
discord.Member is probably the one you'd want to be ideally using
User would be better to use
yeah
Btw for a slowmode command im using channel_id but i want to use the name, i cant see how ive tried channel_name
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 channel_name
b!rtfm pyc channel
bot
Hey, why he give me not the role? He send only the text..
class Info_start(discord.ui.View):
@discord.ui.select(placeholder="🚢» Wähle eine Kategorie aus.", max_values=1, options=[
discord.SelectOption(label=f"» Meine Pings", emoji="📌", description="Wähle deine Pings aus, die Du erhalten möchtest.",
value="<@&938419719671783424>")
])
async def select_callback(self, select, interaction):
if "» Meine Pings" in interaction.data["values"]:
role = discord.utils.get(interaction.guild.roles, id=938419719671783424)
await interaction.user.add_roles(role)
a = interaction.data['values']
await interaction.response.send_message(f"{', '.join(a)}")
Is it possible to get every message a user send in a channel?
Thanks, Ive got 2 other issues thats been bugging me.. the commands still work but not how id want them
You can fetch upto 100 messages and filter it out to get theirs only ig?
So i can only fetch the latest 100?
so 1. ```@bot.event
async def on_message(message):
if bot.user.mentioned_in(message):
await message.channel.send('Hello! I am a personal slave bot who helps around moderating and providing fun into the felbcord! \n If you have any questions about me feel free to ask @tardy rune - my creator \n Join Felbcord here!')
@felbcord utils hi
@felbcord utils (this is what i want)
2. ```@slash_command(name = "nick", description = "Change nickname of a user")
async def nick(self,ctx, member: discord.Member,*, name):
if ctx.author.guild_permissions.administrator:
await member.edit(nick= name)
await ctx.respond(f"{member} has been nicked to {name} :white_check_mark:", ephemeral=False)
else:
await ctx.respond("You do not have the correct permissions to do this", ephemeral=True)``` How would i allow this to change to 1 name every time?
@desert dagger
i believe so
it still works fine, i just dont have it perfected to how i rly need it
:l
i think its fetch 100 at a time
ik id probs make a variable for nick but what after that?
Thing is i need to fetch a lot more then 100
i dont know ontop of my head but i think you need to loop fetch
i want to make the bot do this
any1
sorry. my brains not wanting to work rn xd
hey does pycord have a listener for when people join a vc? I've been looking through the docs and can't find anything for it
yes, its event on_voice_state_update(member, before, after)
if f"<@{bot.user.id}>" == message.content:
okay thanks
thanks, what about the 2nd bit
in the middle of class rn will look at it later
okay thanks
Can anyone help me pls? #985274218272935937
How do i edit this? I used:
await msg.edit_orginal_message(content="Test")
and:
await msg.edit("Test")
message = await ctx.interaction.original_message()
How do i use that? In the send or edit function
Edit
so i have this right but i wanna have it check all of the messgaes in bad_words
sorry for the bad words
them self
message = await ctx.respond('Loading...',ephemeral=True)
message = await ctx.interaction.original_message()
This does not work, am i doing something wrong?
i would remove if i could
yes
?
show code?
This is my code @slender lintel
message = await ctx.interaction.original_message(message)
Traceback (most recent call last):
File "C:\Users\Klaro\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\Klaro\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 357, in invoke
await injected(ctx)
File "C:\Users\Klaro\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: Interaction.original_message() takes 1 positional argument but 2 were given
that should work
try this
message = await ctx.interaction.original_message(message)
ok
why do u have message = await ctx.interaction.original_message()
why is it in a varible
@smoky path
thats not how this works
message = await ctx.respond('Loading...',ephemeral=True)
await ctx.interaction.original_message(message)
i think
1 sec
no
oh idk
then
interaction = await ctx.respond('Loading...',ephemeral=True)
message = await interaction.original_message()
await message.edit()
oh
Lemme try
whats the problem with the 2nd one? I don't understand what you mean by 1 name everytime
Thank you working
So right now, You choose the nickname its changed too, I want it to be changed to a name of my choice so there would be no name section
i still dont understand
????
you want to see how many curse words they sent inside 1 message?
no
i wanna check all those messgaes
seperatly
sorta like and
thats what the for loop is for tho
no?
idk
lmao
So instead of giving it a nickname to change to, in the name part, I want it to just have the member section and it will change the nickname to a variable basicly
does that help?
so you want the nick name to be preset
wym?
@slender lintel do u know how i can do that tho
like have a name already set
yes
b!rtm loops
i alrdy have a for loops
how do i check all them
so
@slash_command(name = "nick", description = "Change nickname of a user")
async def nick(self,ctx, member: discord.Member):
name = "put name here?"
if ctx.author.guild_permissions.administrator:
await member.edit(nick= name)
await ctx.respond(f"{member} has been nicked to {name} :white_check_mark:", ephemeral=False)
else:
await ctx.respond("You do not have the correct permissions to do this", ephemeral=True)```
oh cant i juts use or
Thanks, I thought it would be smth like that but i wasnt too sure (good to check ig)
i get tho
its like it dont see it
why need that when you are already looping through the entire list?
it checks every single word in the list
no it dont
just Shit
it dont check any other ones
uh...
S### it the element in the array
ik that
so S### == the first element then the 2nd element then the 3rd and so on
iterate through all elements in the list, if you find one in the message content, timeout and break the loop
shouldn't be too difficult?
idk
lol
i dont understand
@gilded widget
lol @slender lintel
wait
nvm
lmfao
look at this
Hello @icy sluice
wtf
i can do it too 😉 @slender lintel
its so cool
lol
very useful for trolling
anyways gn everyone, thanks xout for the help (confirmation*)
i can help u
they said they have i working??
lmao the reaction
L
@commands.Cog.listener()
async def on_message(self, message):
for word in filtered_words:
if word in message.content:
await message.delete()
embed=discord.Embed(title="Bad word detected ❌", color=discord.Color.dark_gold())
await message.channel.send(embed=embed)
i just did this
then created a list
with my words in it
I was trying to get the inputs from day, month, year but i'm getting errors because of "discord.context" when i take discord.context away the bot would crash also
Traceback (most recent call last): File "a:\dc bot\main.py", line 143, in <module> bot.load_extension(f"cogs.{file[:-3]}") File "C:\Users\Klaro\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\Klaro\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 'cogs.tests' raised an error: TypeError: issubclass() arg 1 must be a class
@commands.slash_command(description="check")
async def checking(self, ctx,
user: discord.Option(discord.User, "User",required=True),
day: discord.Option(discord.context,"Tag",required=True),
month: discord.Option(discord.context,"Monat",required=True),
year: discord.Option(discord.context,"Jahr",required=True)):```
shouldnt they be an int?
I got it nvm
So, you know how Discord.js has an easy way to send embeds? (Through objects)
Does Pycord have a simple way of sending embeds instead of updating embed values in each line?
you can chain the methods like in discord.js though?
how do i use ctx.defer() properly
by using it at the very first line of the command callback
nice
when the command in total takes more than 3 seconds to get a first response
how
you always get 15 minutes when you defer
oh
@bot.slash_command(guild_ids=bwc)
async def defer(ctx):
await ctx.defer()
await ctx.respond("Test defer")
i think i didnt understood
i got a couple millisecconds
ctx.defer is what makes that "Bot is thinking..." message appear
you cant change that it gives you 15 minutes to respond afterwards
go yell at discord
Anyone know why this doesnt work
"bot.py", line 131, in on_message
embed.set_footer(text=f'{message.author.name}', icon_url=f'{message.avatar_url}')
AttributeError: 'Message' object has no attribute 'avatar_url'```
message.author.avatar.url
how do i put a custom emoji in a embed?
how can i check if the slash command was sent in either dms or not
interactions.guild will return a discord.Guild or none
yea but like what if ur not using any interactions
im currently using this
ctx.interaction
but it doesnt seem to work
I think there is a ctx.guild as a shorthand
yes
coolio
also do you know how to make a shash command just disabled in dm channels but not in actual channels? @slow dome
whats the difference between that and the slash command parameter of guild_only
When i do a slash command and while the command is still going using the same command i get this error:
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction
is there a way to fix taht
nothing, probably
This doesn’t happen to anyone, maybe it’s with your implementation.
@commands.slash_command(description="check")
async def checking(self, ctx,user: discord.Option(discord.User, "User",required=True),day,month,year):
if Info.COOLDOWN is False:
Info.COOLDOWN = True
interaction = await ctx.respond("Loading...", ephemeral=True)
message = await interaction.original_message()
t = f"{day}/{month}/{year}"
did=time(t)
Info.DATE = TimestampToDiscordID(did)
Info.ID = user.id
loop = asyncio.get_event_loop()
loop.create_task(fast_interact(message,t))
else:
await ctx.respond(f"Dieser Command ist gerade im Cooldown. Du kannst ihn in {Info.SECOUNDS} wieder benutzen!", ephemeral=True)```
my code
yea no both @discord.guild_only() and guild_only parameter still doesnt disable the command from dm channels
also that implementation of if ctx.guild is None: also doesnt work
@slow dome any ideas?
Can you put two channelgroup decorators on a command to make that command part of those two channelgroups?
I want to have a few commands that have the same structure but do slightly different things and are in different channelgroups without writing redundant code
?tag missing-access
No tag missing-access found.
?tag missing_access
If you get a Missing Access (50001) error, you probably forgot to add the applications.commands scope.
To fix that, just replace YOUR_BOT_ID with your bot id and visit this link: https://discord.com/oauth2/authorize?client_id=YOUR_BOT_ID&scope=applications.commands
?tag tryitandsee
No tag tryitandsee found.
?tags t
youtube, virtualembed, vacant, tokens, timer, tias, tcr, tca, tags, tagrules, requests, replit, python, paste, objects, notpycord, nothingLMFAO, mybot, message-content, localization, learnpython, intents, install_slash, install_git, install, importerror, getalpha, get_x, exception, discord.Bot, client, buttons2, buttonlimit, bitwise, asset, applicationcommands-registration-delay, aiohttp, Timestamps
?tag tias
when using Context.send() , can I delete the message that initialized the command and then display the content of that message in the reference argument? When I try it it says it replies to a deleted message, which makes sense, but can I circumvent that somehow?
Can I create a new message object and pass that in there?
basically I'm trying to get the same effect as when using the slash command feature, but with traditional commands
just use slash commands
nah, but you can add that content in new message
you can like start with:
replied message: foo bar(which was deleted)
write whatever you want to(here)
alright. Is it a discord API limitation or a pycord limitation?
you can just try, reply to a message and delete the replied message, it will show original message is deleted, so ofc its discord's
Making a new message object doesn't work, does it? It has to be a message in a channel?
ig you can reply in same channel only

view = CountryApprovalView(timeout=None)
approval_channel = io.load_approve_queue_channel(interaction.guild_id)
if approval_channel:
channel = await interaction.guild.fetch_channel(approval_channel)
await channel.send(embed=embed, view=view)
await interaction.response.send_message(f"Claim successfully added! An admin will approve you in <#{approval_channel}>.")
else:
await interaction.response.send_message(embed=embed, view=view)
await view.wait()
if view.approved:
view.children[0].label = "Approved"
view.children[0].disabled = True
view.remove_item(view.children[1])
await interaction.edit_original_message(f"<@{interaction.user.id}> has approved this claim!", view=view)
await self._user.send(f"{self.children[0].value} has been approved in {interaction.guild.name}!")
io.register_country()
return
view.children[1].label = "Denied"
view.children[1].disabled = True
view.remove_item(view.children[0])
msgs = {
"deny_msg": f"<@{interaction.user.id}> has denied this claim",
"deny_dm": f"{self.children[0].value} has been denied in {interaction.guild.name}"
}
for k in msgs.keys():
if view.reason:
msgs[k] += f" for the following reason: {view.reason}"
msgs[k] += "."
await self._user.send(msgs["deny_dm"])
print(msgs["deny_dm"])
print(view)
await interaction.edit_original_message(msgs["deny_dm"], view=view)
WHY DO I KEEP GETTING TypeError: Interaction.edit_original_message() takes 1 positional argument but 2 positional arguments (and 1 keyword-only argument) were given
this is driving me insane
i only have two arguments in the function how could i possibly be passing in 2 positional arguments and 1 keyword-only argument
@analog elk try content=msgs["deny_dm"] in last line
I figured it out
that was a mistake on my part
the issue was that edit_original_message was responding to the wrong interaction
lol
how to make a button that can only pressed by author?
i THINK
author_id = 1234
if interaction.user.id == author_id:
interaction.response.send_message("You are the author!")
else:
interaction.response.send_message("You are not the author!")
i think this might work but i dont know, you should test it
with that being in the button callback function
okie
hey just a question
is there anyway to delete a message that the bot has sent in a specific channel that is like 30m old?
!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 have a check for @commands.check(), (how) can I provide a reason to be processed in the on_command_error handler?
Currently I am just sending a response from the check before return False with a pass in the on_command_error.
def level(*level):
async def predicate(ctx:commands.Context) -> bool:
if not ctx.guild: # Return False in a DM
await ctx.send("This command is only available in a server!")
return False
# some other checks
return False
return commands.check(predicate)
Commands are not working
import discord
from discord.ext import commands
with open('token.txt','r',encoding='utf8') as tokenfile:
token = tokenfile.read().strip()
bot = commands.Bot(prefix='.',intents=discord.Intents.all())
@bot.event
async def on_ready():
pass
@bot.command()
async def test(ctx):
print('test')
#await ctx.reply(file='maxresdefault.jpeg')
bot.run(token)
when I type .test it does nothing
no output to console
?tag message-content
As of Pycord Beta 5, Discord API v10 requires message content intent to receive message content. This affects the traditional commands. Not enabling this intent will result in the messages' content, embeds, and components being empty.
You will need to enable the intent on the developer portal, as well as in your code:
intents = discord.Intents.default()
intents.message_content = True
bot = discord.Bot(intents=intents)
Docs: https://docs.pycord.dev/en/master/api.html#discord.Intents.message_content
btw does background task can block main task?
idk why but i think it does
i think i need thread it myself then
If you do asyncronous background on your task, it wont, if dont, it do
I have a message_command like this:
@commands.message_command(name="Edit Message")
async def edit_message(
self,
ctx: discord.ApplicationContext,
message: discord.Message
):
print(message)
# do other stuff
```But when I try to use the command I get this error: `AttributeError: 'TextChannel' object has no attribute 'news'`.
Why?
print(message.author.avatar_url)
it was this
Hm it is fixed in the master branch but when I install pycord from the master branch using pip install -U git+https://github.com/Pycord-Development/pycord@master nothing changes...
it is enabled
@commands.command()
async def serverinfo(self, ctx):
total = len(ctx.guild.members)
humans = len(list(filter(lambda m: not m.bot, ctx.guild.members)))
bots = len(list(filter(lambda m: m.bot, ctx.guild.members)))
embed=discord.Embed(title='Server Info ', colour = discord.Color.from_rgb(0, 129, 193))
embed.add_field(name='Server Name:', value=f'`{ctx.guild.name}`', inline=False)
embed.add_field(name='Server ID:', value=f'`{ctx.guild.id}`', inline=False)
embed.add_field(name='Owner:', value=f'`{ctx.guild.owner}`', inline=False)
embed.add_field(name='Server Region:', value=f'`{ctx.guild.region}`', inline=False)
embed.add_field(name='Server Creation Date:', value=f'`{ctx.guild.created_at.strftime("%A, %B %d %Y @ %H:%M:%S %p")}`', inline=False)
embed.add_field(name='Text Channels:', value=f'`{len(ctx.guild.text_channels)} Text Channels`', inline=False)
embed.add_field(name='Voice Channels:', value=f'`{len(ctx.guild.voice_channels)} Voice Channels`', inline=False)
embed.add_field(name='Roles:', value=f'`{len(ctx.guild.roles)} Roles`', inline=False)
embed.add_field(name='Total Members:', value=f'`{total} Members`', inline=False)
embed.add_field(name='Humans:', value=f'`{humans} Humans`', inline=False)
embed.add_field(name='Bots:', value=f'`{bots} Bots`', inline=False)
embed.add_field(name='Boost Count:', value=f'`{ctx.guild.premium_subscription_count} Boosts`', inline=False)
embed.set_footer(text=f'{ctx.guild.name}')
embed.set_thumbnail(url=ctx.guild.icon_url)
embed.timestamp = datetime.datetime.utcnow()
await ctx.send(embed=embed)```
anything wrong in this code? coz the embed is not sending
too many fields i think
also
perms arent working with slash commands
for example
@bot.slash_command(name = 'deafen', description="Deafens a user for a specific amount of time")
@commands.has_permissions(mute_members = True)
@option("time", description="The amount of time to deafen the user for")
currently i have the administrator role but it returns an error
discord.ext.commands.errors.MissingPermissions: You are missing Mute Members permission(s) to run this command.
tried not giving admin
and instead just giving the mute_members perm
but still doesnt work
thrwos same error
Anyone know how to delete all messenges in one channel via the channel ID this is what I have right now
@bot.slash_command(guild_ids=[guild], name='nukeshops', description='Nukes all shops.')
async def nukeshops(
ctx,
):
if checkifroles(ctx) is True:
server = bot.get_guild(int(guild))
await ctx.respond('Nuking channels...', ephemeral=True)
for channel in config['channel']:
channell = server.get_member(int(channel))
#delete all messenges in the channel via purge command
await channell.clean()
else:
await ctx.respond('You are not an admin.', ephemeral=True)```
Ahh
change await channell.clean() to await channel.clean()
Might fix it idk
Maybe
hi I want to know how to replace if message.content.startswith with cleint.command
Docs
?
Can i get example of how to use auto complete please ?
i am okay with a basic example, i ll figure rest of the things
nvm found it
!docs
.clean() isn’t a channel method
And why are you using get_member if you’re trying to get a channel
greetings = bot.create_group("greetings", "Greet people")```
where exactly do I put this, when using cogs?
in the __init__? on_ready?
could someone help me with slash cmd groups within cogs
Here's the slash cog groups example.
If you have further questions fell free to ask :)
@foggy flax No, Do NOT have discord.py or discord installed as they will break pycord. Also please ask questions in this channel next time
my bad, just getting this after installing py-cord
try restarting pycharm, it gets mad when you uninstall d.py than install pycord for some reason
still didnt work, py-cord is not in pip list either
should I just install and run from cmd?
make sure you are in your venv when installing
ig their "Python Packages" Manager fixed it??? I dont know why
yet every other pip command worked
¯_(ツ)_/¯
To upload my bot to github, Is there a faster way than putting every file in the 'drag file section' like can i do anything in console
Did not work
Using git, search on the internet "how to use git with ..." replace ... with your IDE
So how do use git with discord.py?
ty
we are also pycord not discord.py
For me if i was experienced i'd be doing
- git add -a
- git commit -m "message"
- git push
which uploads everything
Yeah, but its discord.py the language and pycord is the librariy isnt it
you need to use purge() not clean()
basically
Pycord used to be a fork of discord.py
except we sorta diverged and became a library thats different.
Oh, So its a seperate language now? or
pycord was made because Discord.py abandoned but then discord.py came back
Python is the language
Pycord, discord.py are libraries
no Python is the language. discord.py is a library. pycord is a fork or discord.py meaning that at one point the code was the same but now it is very different
alright
Not very many after 2.0.0 though
for Discord.py? yeah ig so
A discord server im in wanted me to use a bot from github and it was in D.py and with a few changes it seemed to work smoothly
make a list with all of the letters for example
letters = "a b c".split(" ")
than use random
import random
random_letter = random.choice(letters)
that chooses a random letter from the list
Yeah the switch from d.py 1.7.3 and 2.0.0 to pycord 2.0.0 was not to bad. If you tried to switch from the current version of discord.py to current version of pycord it would be a pain.
import random
import string
x= string.ascii_letters
num = 15 # lenght of letters
print ( ''.join(random.choice(x) for i in range(num)) )
another way if you want @icy sluice
Ice's method will just do letters but this one will let you control length and so on
yours does upercase and !@#$%... right?
Dumb question but is it possible to:
- I create a cog
- in the main.py i create a bridge command
- some sort of code to call the cog?
cause i know bridge doesnt work in cogs
If not would it just be better to call the "cog"/function into the bridge command and pass args
Here's the slash basic example.
Its fine with me
Also just to be clear:
- never upload your .env to github
- make sure your main python file does not do "bot.run('token') and if it does then censor it before uploading to github
- Do not upload your venv to github
Yeah, Ive got a .gitignore is that right?
mhm
also whats venv
venv is a virtual enviroment
instead of installing python packages globally i prefer creating virtual environments so only one project uses it
Really useful if you need specific versions of a python package but need other versions in other projects/globally
You probably forgot to use bridge.Bot
oh so it does work?
Ye
i swear a while ago people say they dont. Ig thats what happens when you dont keep up with all the new changes hahaha
thanks
anyone know why this is happening?
it is the right token is the issue
from discord dev portal
How do i update a github rep
Thats not your token
Ive even reset it
... the client secret isnt ur token tho
xD
Please also look into using an env instead of in the main file. It is too easy to accidentally leak your token like this
yea was just about to do that, ty for the tip!
got a few different vars that I cant show, wouldnt be too good for them to be leaked
Ye
does the normal subclassing help methord work for slash cmds?
?
With some edits yes
What do you mean?
ah, which edits?
Like, My gitignore file shows i have added .gitignore to it
but how to i update that to my git page
git commit
git push
brings this up
I can't exactly remember :/
Personaly i think if you give a discription to all you your commands and option you don't need a help command becouse its all in the discord UI. Your choice tho
ah true, i just want a help cmd that lists out all available cmds, cause the end user, lets just say is slow
Here's the slash basic example.
ignore
a
You aborted the commit by not typing a commit message
isnt it git commit -a?
#app-commands 👀
I'm not exactly sure thats something you could look up. I use pycharm integration for it
alr
do u know if this works
I dont sorry :/
oof
git add -A adds everything that it "detects" from git status
git add . adds everything in the directory
^^
git commit -m "Message" is what you need to do
example:
- git add -A
- git commit -m "Created bot"
- git push
I got this but files r still there
git status?
?
check ur github
I have, I refreshed my page and git ignore and git attrubites still there
@desert dagger
Yeah, Its currently showing it and i dont want it too
What about the other one?
Sorry i havent used github in ages, even when i did i barley used it
i dont think you can ignore gitattributes either
alr
u can delete it if u want but its there for a reason
What about pycord folder
Does it change anything?
whats in the pycord folder??
i added it at the very start whilst having no idea what i was doing lol
ty
alright
How would i now update this to github? I tried git add . and git push
git add -a
git status
git commit -m "removed pycord folder"
git push
oops
I tried -A instead of -a
-A
Something that is unclear to me is what the allowed actions are with a Interaction.response object after .defer() has been called on it.
I have a modal interaction callback which does the following:
- Compute some stuff.
- Store stuff in a database.
- Use interaction.resp to send a message or update an existing post.
Step #2 is normally instantaneous, but I've seen it fail once due to IO load on the host and I'd like to avoid that. Here is an example of my callback (much simplified).
async def callback(self, interaction: discord.Interaction):
resp = interaction.response # type: discord.InteractionResponse
await resp.defer(ephemeral=True)
await self.doStuff(ctx) # normally this is sub millisecond but could take longer...
await resp.send_message('Did stuff', ephemeral=True)
return
Attempting to call the send_message method raises an exception discord.errors.InteractionResponded: This interaction has already been responded to before. Is there an pycord example that shows the use of defer() ?
Btw, Is it possible to prevent logging into the console? (Its logging a bunch of server info to console when the bnot is online) It logs it to both discord.log and console, I want just discord.log (or none of the spam messages of server info) in attached image
logging.log or print()
just remove them
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('discord')
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler)``` where
ook
Ive done this now to update the main file and it isnt updating it
@desert dagger
it takes time sometimes
for it to update on github
it wont always instantly update
oh okay
how to make the bot delete his last message instead of the whole channel
github slow lol get betr
this should help
ty
Traceback (most recent call last):
File "C:\Users\Davi\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\Davi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 357, in invoke
await injected(ctx)
File "C:\Users\Davi\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: 'NoneType' object has no attribute 'purge'
@slender lintel
bruh
async def ping(self, ctx):
if ctx.author.guild_permissions.administrator:
await channel.clone()``` How would i get the channel the user is sending the message in?
b!rtfm pyc channel.id
async def ping(self, ctx):
if ctx.author.guild_permissions.administrator:
await discord.TextChannel.id()
await channel.clone()``` channel is not defined?
@desert dagger
sigh
do "await ctx.channel.id"
You should be cloning channel before deleting
b!rtfm pyc clone
b!rtfm pyc clone channel
No results found when searching for clone channel in pyc
why’s this happening?
I am?
you are
just making sure u realise that
i dont get why ur trying to grab the channel id?
letme explain it better:
- your /deleteAll command needs to be ran in the channel u want to delete
- if thats the case then ctx.channel is all you need
I want to clone a channel and delete the orginal channel
Yeah, So i want to delete the channel its ran in
await ctx.channel.clone()
await ctx.channel.close()
simple
b!rtfm pyc cooldown
label:Cooldown
discord.SlashCommand.cooldown
discord.ext.commands.Cooldown
discord.ext.commands.Cooldown.copy
discord.ext.commands.Cooldown.get_retry_after
discord.ext.commands.Cooldown.get_tokens
discord.ext.commands.Cooldown.per
discord.ext.commands.Cooldown.rate
discord.ext.commands.Cooldown.reset
discord.ext.commands.Cooldown.update_rate_limit
maybe one of these?
any1
code?
The code would help lmao
says right there why its not working. indentation error
@commands.command(name="presence")
async def presence(ctx):
await bot.change_presence(activity = discord.Game(name=f"testing stuff"))
async def deleteall(self, ctx):
if ctx.author.guild_permissions.administrator:
await ctx.channel.clone()```
error:
Traceback (most recent call last):
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 126, in wrapped
ret = await coro(arg)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 852, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "C:\Users\jackd\Documents\Felbcord Py\commandss\deleteall.py", line 12, in deleteall
await ctx.channel.clone()
TypeError: 'int' object is not callable
The above exception was the direct cause of the following exception:
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 25, 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: 'int' object is not callable
from discord.commands import slash_command
from discord.ext.commands import Cog
class ClearAll(Cog):
def __init__(self, bot):
self.bot = bot
@slash_command(name="deleteall", description="Deletes every message in a channel")
async def deleteall(self, ctx):
if ctx.author.guild_permissions.administrator:
await ctx.channel.clone()
def setup(bot):
bot.add_cog(ClearAll(bot))```
@commands.command(name="presence")
async def presence(ctx):
await bot.change_presence(activity = discord.Game(name=f"testing stuff"))
kinda obvious no? functions require you to indent whatevers in it
e
Hello? @desert dagger
code seems right ¯_(ツ)_/¯
bit new to pyc, sorry, nd now the bot just doesn’t do anything, the status isn’t changing either
- I get no err
You sure the commands being ran?
well I’m running !presence nd I’m not getting my usual “Command not found." err so I’m pretty sure, yes
guys please help
texturas = [["Grounded 16x",
"https://www.mediafire.com/file/2klfun5y76nop7o/%2521_%25C2%25A7f%25C2%25A7LGrounded_%25C2%25A72%25C2%25A7L%255B16x%255D%25C2%25A70.zip/file",
discord.File("grounded.png", filename="grounded.png")],
["Pan Fancy Pack 16x",
"https://www.mediafire.com/file/5eftx6ctv3o9ak6/%2521_%25C2%25A7a%25C2%25A7lPan_Fancy_Pack%25C2%25A7r_%255Bx16%255D_%25C2%25A7eR%25C2%25A7ce%25C2%25A7da%25C2%25A7bl%25C2%25A79i%25C2%25A7as%25C2%25A76t.zip/file",
discord.File("panqueko.png", filename="panqueko.png")]]
@bot.slash_command(guild_ids=testbot)
async def txt(ctx):
rdm = random.choice(texturas)
embed=discord.Embed(title=rdm[][0], description=None, color=discord.Color.blurple())
embed.set_image(url=rdm[][2])
button = Button(label="Download", emoji=":download:", url=rdm[][1])
view = View(timeout=None)
view.add_item(button)
await ctx.respond(embed=embed view=view)
look
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
chaze
async def on_message(message):
if f"<@{bot.user.id}>" == message.content:
Welcome=discord.Embed(title="Felbcord Utils",url="https://github.com/VividBlue1/Felbcord-Py/tree/discord",description="Hello! I am a personal slave bot who helps around moderating and providing fun into the felbcord! \n If you have any questions about me feel free to ask @ignfoolish#0396 - my creator \n Join Felbcord here!",color=discord.Color.blue())
embed.set_author(name="FoolishBlue", url="https://github.com/VividBlue1/Felbcord-Py/tree/discord", icon_url="Felbcord Py/Images/felb.jpg")
await message.channel.send(embed=Welcome)``` Why do i get embed was not defined
capital sensitive probably?
i want to the bot choose a random variable, but it bring it's values too
tried that
wdym
.
I’m using bot method
Is your channel valid?
@bot.event
async def on_message(message):
if f"<@{bot.user.id}>" == message.content:
Welcome=discord.Embed(title="Felbcord Utils",url="https://github.com/VividBlue1/Felbcord-Py/tree/discord",description="Hello! I am a personal slave bot who helps around moderating and providing fun into the felbcord! \n If you have any questions about me feel free to ask @ignfoolish#0396 - my creator \n Join Felbcord here!",color=discord.Color.blue())
Welcome.set_author(name="FoolishBlue", url="https://github.com/VividBlue1/Felbcord-Py/tree/discord", icon_url="Felbcord Py/Images/felb.jpg")
await message.channel.send(embed=Welcome)
ty
variable = [["nest1 value1", "nest1 value2"] , ["nest2 value1", "nest2 value2"]]
rdm = random.choice(variable[#random nest][#preset value])
why not try what i gave u?
i want to it randomize the nest but also choose a value of that nest
As the image i have is a .jpg, Its not on google it dosent work (needs http/https)
How can i fix that?
what is this
what do you mean
oh
how can i use ctx.respond() so that only the user can see it?
of course
e
will make an drawing
ctx.respond('hi',ephemeral= True)
Why not upload image to imgur or imgbb
Oh yeah, Never thought of using imgur
ty
smh
still no reply
well it’s in a cog, could that be a reason why?
probably?
I’ll try put it in my main file
Did you load the cogs?
bot.load_extension()
Intents?
all enabled
Why dosent the image load? (I am using imgbb)
@desert dagger
send img url
use the direct url
wym?
variable = [["nest1 value1", "nest1 value2"] , ["nest2 value1", "nest2 value2"]]
rdm = random.choice(variable)
embed=discord.Embed(title=rdm[][0], description=rdm[][1])
await ctx.respond(embed=embed
How can I make it so that when I react, with a minimum of n reactions, to a message from a channel, a role is assigned to it? I do not control the clients
something like that
what should the activity parameter look like?
your code atm would return
['nest2 value1', 'nest2 value2']
import random
variable = [["1", "2"] , ["3", "4"]]
rdm = random.choice(variable)
print(rdm)
shows your code in an easier way
so you basically want 1 or 2 to be chosen but if 2 is chosen then 4 is chosen?
hm
almost there
ok will give you more examples
i want to make a minecraft texture randomizer
holdon
Ok why dont you dictionary
Is there an example that shows the usage for deferring an interaction and following up on it?

discord.DeletedReferencedMessage
discord.DeletedReferencedMessage.channel_id
discord.DeletedReferencedMessage.guild_id
discord.DeletedReferencedMessage.id
discord.Embed.footer
discord.Guild.preferred_locale
discord.MessageReference
discord.MessageReference.cached_message
discord.MessageReference.channel_id
discord.MessageReference.fail_if_not_exists
Was going to ask that tbh. Just still trying to wrap my head around what hes trying to do
I can see he makes the embed have the first array give a random value but then he hardwires the 2nd array
Its been 1h..
@bot.slash_command(guild_ids=testbot)
async def test(ctx):
#resource packs
resourcepack = [["Pack 1 name", "Pack 1 download link", "Pack 1 preview image"], ["Pack 2 name", "Pack 2 download link", "Pack 2 preview image"]]
# the pack that will be randomized
rdm = random.choice(resourcepack)
#title should be the name of the randomized pack, image should be it's preview image
embed=discord.Embed(title=rdm[][0], description=None, color=discord.Color.blurple())
embed.set_image(url=rdm[][2])
# url should be it's download link
button = Button(label="Download", emoji=":download:", url=rdm[][1])
view = View(timeout=None)
view.add_item(button)
await ctx.respond(embed=embed view=view)
that is what i want to do
use a dictionary and array
import random
pack1 = {'name': 'pack name1', 'url': 'download_link', 'preview_imge': 'link.png'}
pack2 = {'name': 'pack name2', 'url': 'download_link', 'preview_imge': 'link.png'}
pack3 = {'name': 'pack name3', 'url': 'download_link', 'preview_imge': 'link.png'}
resourcepacks = [pack1, pack2, pack3]
rdm = random.choice(resourcepacks)
print(rdm['name'])
pack1 is a dictionary.
resourcepacks is an array containing your dictionaries
rdm chooses a dictionary from array at random and you can use rdm[] to retrieve the values
you should try to learn more python if you wasnt rly aware of what a dictionary is
then you didnt do the stuff right ig lmao
whats not updating
I have, It said it had updated (Git add -A git commit -m (my msg) git push
https://github.com/Pycord-Development/pycord/tree/master/examples dont really know tbh
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/examples at master · Pycord-Development/pycord
do git status
and ss it
Doesn't work I tried that too
git remote -v?
It hasnt on my end? Is the logs bit there for you
I did lol
Didnt fix it
well its updated on everyones end but urs
at least its updated ig
ty
Yeah I tried checking there too... seems like none of them actually use it
Another different question. How does one output a full traceback with on_application_command_error? I see exception.with_traceback() but it requires a traceback argument that I can't figure out
https://docs.pycord.dev/en/master/api.html#discord.Bot.on_application_command_error
oh am dumb with_traceback() is a python function
Ok but I am still kind of confused how to get a traceback with on_application_command_error... it provides the exception but I can't figure out how to get the traceback from the excerption. So all I get is a one line error with no other info
any1?
Hi guys! How can I make it so that when I react, with a minimum of n reactions, to a message from a channel, a role is assigned to it? I do not control the clients
i installed pycord and copied one of the examples on the github but it's telling me AttributeError: module 'discord' has no attribute 'Bot'
can you check the lib version?
pip show py-cord
1.7.3
i did the command it said and it still installs 1.7.3
do you have multiple python versions?
idk i dont think so
it does keep telling me about not finding the microsoft store version tho
is installing it from python3 -m pip install -U py-cord --pre bad because that worked
Is there a way to use converters inside the code of the function (rather than in the args of the command)?
Can I make a view persistent for a view defined in the scope of a function?
One message removed from a suspended account.
One message removed from a suspended account.
anyone?
b!rtfm discord.Activity
I couldn't find a documentation with the name discord.activity! 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
b!rtfm pyc discord.Activity
it should have a type and a name
https://docs.pycord.dev/en/master/api.html#discord.Message.reference this might help you
discord.ext.commands.Context is your “ctx”
One message removed from a suspended account.
One message removed from a suspended account.
error is self explanatory, don't pass it with id=, just pass the ID without keyword
is it possible to do disable the button upon interaction and at the same time send a modal?
button typo sorry
o
we did go in this previously but this time i want to know if I can do it since I can't do the time_out
maybe callback?
async def button_callback(self,button,interaction):
for child in self.children:
if child.label == Flight_Authorisation[0][0]: pass
else: child.style = discord.ButtonStyle.gray
child.disabled = True
Reason = Reasoning(self.children,title="Reasoning")
await interaction.send_modal(Reason)
await interaction.response.edit_message(view=self)
don't mind the indents
do you get an error from this?
lemme get the error
raise InteractionResponded(self._parent)
discord.errors.InteractionResponded: This interaction has already been responded to before
i don't think i can do followup since those are for webhooks i believe
oh
you can do a followup tho
one sec reading docs
ok im not sure if followups can send modals or not
cause normally you send modals as
.send_modal(modal)
but there is no attributes of this in a webhook
I believe you can send interactions via followup?
well
await interaction.followup.send(...)
has view=
and you can add buttons like that
ig you can try it
so I found this. You can't do modals for followups
Idk how else to do it then sorry
Gmmm
lemme try if it can edit the view itself
since the interaction for the view is
await interaction.something.edit(view=self)
gl
