#General Help
1 messages · Page 33 of 1
but why we can't tho?
updating to the latest doesn't help too
discord limitation
I dont get any roles
import discord
from discord.ext import commands
from datetime import datetime
from msilib.schema import Class
from os import times
from time import time
from unicodedata import name
class Shurtsdc99(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_raw_reatcion_add(self, payload):
ourMessageID = 997623205076406342
if ourMessageID == payload.message_id:
member = payload.member
guild = member.guild
emoji = payload.emoji.name
if emoji == '':
role = discord.utils.get(guild.roles, name="| Champ")
elif emoji == '':
role = discord.utils.get(guild.roles, name="| Diamond")
elif emoji == '':
role = discord.utils.get(guild.roles, name="| Platinum")
elif emoji == '':
role = discord.utils.get(guild.roles, name="| Gold")
elif emoji == '':
role = discord.utils.get(guild.roles, name="| Silver")
elif emoji == '':
role = discord.utils.get(guild.roles, name="| Bronze")
elif emoji == '':
role = discord.utils.get(guild.roles, name="| Copper")
await member.add_roles(role)
@commands.command(pass_context=True)
async def bye(self, ctx):
embed = discord.Embed(
title="Rollen",
description="Gib dir die Rolle die du willst",
timestamp=datetime.now(),
color=ctx.author.color
)
msg = await ctx.send(embed=embed)
await msg.add_reaction('')
await msg.add_reaction('')
await msg.add_reaction('')
await msg.add_reaction('')
await msg.add_reaction('')
await msg.add_reaction('')
await msg.add_reaction('')
def setup(bot):
bot.add_cog(Shurtsdc99(bot))
There’s a typo over there: “on_raw_reatcion_add”
Having a bit of a crisis, bridge commands in cogs aren't working 😓
thx, but there is a new problem
*As in they aren't being detected (slash commands doesn't come up), and using the prefix version doesn't do anything
So it's not rlly an issue but just optimisation of code
Does anyone have any recommendation on like not using discord.SelectOption all the time
mostly so it's easier to read and efficient in space
Error is self explanatory. Basic python.
I have been thinking of using lamba, but again there might be easier way of optimising it without using lamba (since I have no idea how to use it in this instance)
Use list comprehend
I don't think you can use iterate in a list though?
you'd have to use lamba (not sure if I'm even spelling it correctly)
you can pass the options with list comprehend
ah those, right I'll try it out
would it be something like this?
after running it, um there's a problem where it
TypeError: issubclass() arg 1 must be a class
line 231, in <listcomp>
options=[discord.Option(x) for x in fruits]
discord.SelectOption
yeah just saw the error
With respect to my bot, why is ctx.guild.me.guild_permissions not equal to ctx.guild.self_role.permissions? (Or are they supposed to be equal, and I'm just doing something terribly wrong?) The only role my bot has is the one associated with its integration (and the one returned by ctx.guild.self_role), so I'm pretty sure these should be equivalent.
I'd have to define where the x value goes into as well
b!rtfm pyc discord.SelectOption
one sec
the label bit
yes
there's a slight difference here; self_role.permissions will return the specific permissions for the role, but ctx.me.guild_permissions is a bit different; it returns the permissions of all your roles combined
the hidden part: @ everyone is also considered a role
to illustrate this, if you completely reset @ everyone permissions in your guild (and ensure your bot role doesn't have admin), the values would now be the same
Oooooooooh, I see. That makes sense, thanks!
allgood
How can I make that multiple messages that are in a list are deleted immediately?
Without for message in message because that is extremely slow
I want to delete the messages direct, simultaneously
i think i found out a way to do it without this
you just need to insta delete the message after your code: ctx.message.delete()
also, may seem like a stupid question, but how do i timeout it?
if i have buttons assigned to one message, how do i send a second message after it and have the buttons of first message, for example, edit the text of the second?
ctx.pong() also ignore the interaction failed, but it can only be done once
ok guys, this may seem stupid
but how do i make a command
to reply balls when someone says ligma?
on_measage event
this might be a dumb question but how do i get my bot to send a message like '#channel' where you can click the message and it takes you to the channel
like how when i say #faq you can click it and go to the channel
<#channelid>
Does anyone know why my bot would randomly reboot by itself
By that I mean the "on_ready" gets triggered every once in a while
It shouldn't be a network issue as my other bots didn't reboot at the same time, running on the same machine
hi
i need help
@client.slash_command(name = 'Replit HackerPlan')
async def hackerplan(ctx, ,Username , Password):
async def hackerplan(ctx, ,Username , Password):```
how to make like input 3 things in a command?
how can I use typing.Union in slash commands options?
what 3 things u want to input?
use
async def hackerplan(ctx, Email: str, Username: str, Password: str)
how to make the command executableinonly 1 channel? @fringe hatch
like if message.channel.id = "ss
like this
On ready is supposed to be able to be triggered multiple times
try it:
if ctx.channel.id==your_id_channel:
is there a way to make a command on cooldown only if its executed correctly?
for example i have a command
.hi and it takes member as a arg
if the user just does .hi without the member thing it still times out the command
i cant go on my pc but i used the thing with buckettypes
and i cant log into my replit 😭
ctx.command.reset_cooldown(ctx)
@lament nimbus the solution ^^
if your missing argument is handled by your error handler you put it there
nope, it just removes the cooldown from the cache
nice ty
not an API call or anything
if member == None:
ctx.command.reset_cooldown(ctx)
return await ctx.reply("No member mentioned")
something like this then
thanks
That works too
use member is None
isnt it the same?
It's the same but is None is more generally used
if you use an IDE it will also tell you to change it to is None
IM TELLING FOR SLASH CMD. will it work?
you should try it before writing or reading the docs :)
?tag tias
Thnks it worked!@boreal arch
how can I fetch a guild's region using py-cord?
How to check the message if it mentioned a channel?
This might be what ur looking for: https://docs.pycord.dev/en/master/api.html?highlight=discord guild#discord.Guild.preferred_locale
does anyone have issues with the bot just not responding to commands?
Are they prefixed commands? If they are, make sure u have message content intents turned on in both the dev portal and in ur code
Carlbot has a feature where you can add emojis from other servers to your own. how could you implement this in pycord?
b!rtfm pyc guild.emoji
I know there is create_custom_emoji but I have to get the emoji as an image somehow, don't I?
it worked fine before with that off :(
You set 1 st param that takes discord.Emoji, then on image argument to create emoji put discord.Emoji.read() as it will convert the emoji from your command to byte
i dont get it, all my other bots work but this one doesnt
enable message_content intent
but i dont have it enabled on my other bots and they work?
Ok what about you try it first insteqd of ask to ask
Discord enforces it with API version v10
oh so i gotta do that on every bot now? fuckkk
And then how do I test if it's an emoji?
Yeah
but why does it randomly trigger though
It's not exactly random; your bot may reconnect with the gateway, which will fire on ready again
This isn't something you can really prevent, it's inevitable
Which is why you shouldn't rely on on_ready too much (and if you do, have checks in place to prevent duplicate executions)
Btw what's pycords version of dpy setup_hook ?
Uhhhh what does that do
I believe it's supposed to be used for bot startup stuff
Hm I don't think pycord implemented async startup functions
u mean the version of pycord that it uses from discord's hook?
You could just use tasks if you want something to run on startup
Here's an example of it being used: https://github.com/Rapptz/discord.py/blob/master/examples/app_commands/basic.py
It's basically on_ready but it only triggers once
Hmm yep we don't have that to my knowledge
It would probably be a good thing to implement here as well so that people don't use on ready for stuff that should only execute once
Throw it in #suggestions using the /suggest command or open a request on the repo
Yeah I think I'll do that
No, i didn't understand ur question
Hello, i am trying to get a list with with every guild name and ID that the bot is in. but for some reasons the guild name is always "None" (except one for some reason)
my code:
print(bot.guilds)
What i get:
[<Guild id=461592141521485824 name=None shard_id=None chunked=False member_count=None>,
<Guild id=837590922610737162 name='Rainbow Six [DE] | BOT Test' shard_id=None chunked=True member_count=19>]```
837590922610737162 Is a small guild with a view Channels and almost 30 Members
461592141521485824 Is a big guild with over 41000 Members and 200 Voice Channels
any solutions to fix this issue?
Have you overridden intents?
Wdym?
When defining your main bot object, did you set intents=...
No
@bot.event
async def on_ready():
print(
f"""{Gray()}
Bot Loggedin as: {Red()}{bot.user.name}
{Gray()}Bot is in {Red()}{len(bot.guilds)} Server/s
{Gray()}Prefix: {Red()}{data['prefix']}
{Gray()}Bot is running since: {Red()}{time.strftime('%H:%M %d.%m.%Y')}
{Gray()}Logs:
"""
)
try:
# guild = bot.get_guild(837590922610737162)
# memberList = guild.members
print(bot.guilds)
except Exception as err:
print(err)```
Yes since 4 days
Any ideas@crimson coral?
Hmmm I can't really see why this would be happening unless you disabled the guilds intent, but you haven't
What pycord version are you on?
My code fully works with other guilds (smaller ones) but with this it doesn't
2.0 b7
Wait so how many guilds are showing up as none
I tryed other versions too even discord.py same result
only this large one (the main reason of my current code)
with over 41000 Members and 200 Voice Channels
Hmm that shouldn't be causing any problems...
What if you print it outside of on_ready?
Like in a command or something
Then it works.... but for some features we need this to run in on ready
That's probably the issue
I mean on the Test server it worked
You need to do it after on_ready because the cache isn't complete fast enough
Either that or maybe await asyncio.sleep for a couple seconds
Before trying to operate on the guild
Oh that could be the reason... i'll try doing that
You're a genius thanks a lot
[<Guild id=461592141521485824 name='Rainbow Six [DE] :heavy_check_mark:' shard_id=0 chunked=True member_count=41108>, <Guild id=837590922610737162 name='Rainbow Six [DE] | BOT Test' shard_id=0 chunked=True member_count=18>]
All good
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 127, in wrapped
ret = await coro(arg)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 877, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "d:\Code\t2e-alpha\cogs\marketplace.py", line 216, in buy
await ctx.defer()
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 556, in defer
await self._locked_response(
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 956, in _locked_response
await coro
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\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
``` how can `ctx` be Unknown interaction
fixed nvm
how to make a command only be executed by a owner?
@commands.is_owner()
@bot.slash_command(name='reset')
async def test(ctx : commands.Context):
#ONLY FOR TESTING PURPOSES. DO NOT ABUSE THIS COMMAND
if ctx.message.author.id == 397437604880187403 or ctx.guild.id == 397437910888218635:
mPrint("WARN", "RESTARTING BOT")
await ctx.respond("WARNING, DO NOT ABUSE THIS COMMAND...\nplease wait...")
os.system(f"bot.py RESTART {ctx.guild.id} {ctx.channel.id} {ctx.message.id}")
sys.exit()
else:
await ctx.respond("You are not allowed to use this command.")
return```
i get this problem line 267, in test if ctx.message.author.id == 397437604880187403 or ctx.guild.id == 397437910888218635: AttributeError: 'NoneType' object has no attribute 'author'
it says my message has no author
ok, lemme test it
where do i set the owner id?
nope
It's whoever owns the bot
in Bot class
AttributeError: module 'discord.ext.commands' has no attribute 'ApplicationContext'
HMMMM, just what i needed
But you can override it by setting owner_id when defining bot
alr thanks
its discord.ApplicationContext
sorry
how to make a message send everytime someone joins?
is there a way to limit slash command use or visibility to a list of specific members?
b!rtfm pyc permission.checks
No results found when searching for permission.checks in pyc
b!rtfm pyc commands.checks
how do I send a DM message to the author who added my bot to a server?
At the moment, there is no way to get who added a bot to a server. However, you can fetch audit logs for bot additions and get the latest one (indexing it to 0), and so on.
b!rtfm pyc guild.audit_logs
There is no way on pycord or the whole of discord? Since the bot named Wick known for its anti nuke can DM you upon you adding the bot?
That would give you an audit log object then access the user with .user
It uses the audit logs I’m pretty sure.
ah hm, okay ty
I get the prompt as an argument in the slash command:
@slash_command(guild_ids = [], description = "...")
@discord.option("invite", type = discord.Invite, description = "...")
async def invite(self, ctx: discord.ApplicationContext, invite: discord.Invite): ...
And get this error:
File "...\LocalCache\local-packages\Python310\site-packages\discord\commands\core.py", line 851, in _invoke
arg = await converter.convert(ctx, arg)
TypeError: InviteConverter.convert() missing 1 required positional argument: 'argument'
InviteConverter.convert() Seems to get all the arguments, but an error occurs.
@bot.slash_command(name='reset')
@commands.is_owner()
async def reset(ctx : discord.ApplicationContext):
await ctx.defer()
#ONLY FOR TESTING PURPOSES. DO NOT ABUSE THIS COMMAND
mPrint("WARN", "RESTARTING BOT")
await ctx.respond("WARNING, DO NOT ABUSE THIS COMMAND...\nplease wait...")
os.system(f"bot.py RESTART {ctx.guild.id} {ctx.channel.id} {ctx.message.id}")
sys.exit()
@reset.error
async def reset_error(ctx, error):
if isinstance(error, commands.NotOwner):
await ctx.defer()
await ctx.respond(f"Você não manda em mim, {ctx.author.mention}! 😡")``` the command won't run, its thinking forever
works for me this way
```py
os.execv(sys.executable, ["python3.8"] + sys.argv)
exit()
yeah, but i need it to pass the args to the terminal before restarting
so it can respond to my message
and it won't timeout
Why should i write def setup instant of async def setup ???
can a msg be a view and ephemeral?
uhmm, why is this happening?
Didn't invite the bot with the application.commands scope
I did
Some guild didn't
no, i manually checked, it is
Code doesn't lie 
bruh, so is there any way to find out which server is raising this error?
Just get them to reinvite the bot
the bot is in 45+ servers...
the thing is that the code was working fine till now, and I just kicked it out of 1 server and then I restarted the bot, it has been giving this error since that only.
how to have aliases for group subcommands
@honor.command(name="history", aliases=["h"])
async def honor_history(self, ctx, member: Member = None):
pass
as this dont work, how do you do it?
which audit log entry would be for when my bot joins a server?
tying to add cog but keep getting this error
Traceback (most recent call last):
File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\cog.py", line 715, 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 "c:\Users\philc\Desktop\Ticket bot WIP\working folder\cogs\medbay.py", line 4, in <module>
class medbay(commands.Cog):
File "c:\Users\philc\Desktop\Ticket bot WIP\working folder\cogs\medbay.py", line 12, in
medbay
@discord.slash.command()
AttributeError: module 'discord' has no attribute 'slash'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "c:\Users\philc\Desktop\Ticket bot WIP\working folder\ticket bot.py", line 73, in <module>module>
bot.load_extension(f'cogs.{cog}') , in load_extension
File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\cog.py", line 787, in load_extension , in _load_from_module_spec
self._load_from_module_spec(spec, name)
File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\cog.py", line 718odule 'discord' has no attribute 'slash', in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.medbay' raised an error: AttributeError: module 'discord' has no attribute 'slash'
The last one
what
Just index the last entry
will that always work?
@bot.event
async def on_guild_join(guild):
audits = guild.audit_logs()
inv_audit = discord.audits.AuditLogEntry.bot_add[0]
author = inv_audit.id
await author.send("ello")
something like that?
i have no clue what I’m doing
hey guys, having a TypeError i need help solving in my command error handler, something about ctx?
@commands.Cog.listener()
async def on_command_error(self, ctx: commands.Context, error: commands.CommandError):
if isinstance(error, commands.CommandOnCooldown):
embed = discord.Embed(title="Command Execution Error")
embed.add_field(name="commands.CommandOnCooldown Error", value="The command `{}` is still on cooldown! You have to wait {} more seconds before using this command.".format(ctx.command, round(ctx.command.get_cooldown_retry_after(), 1)))
await ctx.reply(embed=embed)
else:
raise error
Traceback (most recent call last):
File "C:\Users\pin\Desktop\VSCode\pinbot-sharpened\.venv\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "c:\Users\pin\Desktop\VSCode\pinbot-sharpened\modules\Core\Core.py", line 51, in on_command_error
embed.add_field(name="commands.CommandOnCooldown Error", value="The command `{}` is still on cooldown! You have to wait {} more seconds before using this command.".format(ctx.command, round(ctx.command.get_cooldown_retry_after(), 1)))
TypeError: Command.get_cooldown_retry_after() missing 1 required positional argument: 'ctx'
been looking at the api and on google but i can't figure it out
Make sure rhat the bot does not try to register guild specifc commands to the server you just kicked it from
You can get retry after by using error.retry_after
Its there
Check out exception hierarchy
ah thanks, that was the issue.
👍
Can someone explain @client.on_member_join usage to me, documentations are always confusing
what part you referring to?
on_member_join is when a member joins a server, should be self explanatory.
b!rtfm pyc on_member_join
anyone know why this doesnt wanna work?
Any error?
Well then that means the author isn’t the guild owner.
And are you using the command in a guild?
there is an else statement tho?
yup
Try adding print statements after the if statements and see where it doesn’t work.
ighty
@bot.event
async def on_member_join(member):
await member.add_roles(bot.get_role(997906313776467969))
await bot.get_channel(997926619761098842).send(member.mention)
anyone know why this doesnt add the role?
oh nvm
AttributeError: 'Role' object has no attribute 'Role'
@bot.event
async def on_member_join(member):
await member.add_roles(get(member.guild.roles, Role=member.get_role(810264985258164255)))
await bot.get_channel(997926619761098842).send(member.mention)```
Uhhhh
Your old code made way more sense
You probably want member.guild.get_role
Instead of bot.get_role
async def on_member_join(member):
role = discord.utils.get(member.guild.roles, id="12345")
await member.add_roles(role)
is there a way to limit a on_member_join to a specific guild?
Has anyone got bridge commands working in cogs?
Check for the guild id inside on_member_join?
okie
@bot.slash_command()
async def work(ctx):
u = discord.ClientUser.mfa_enabled
print(f'{u}')
returns <member 'mfa_enabled' of 'ClientUser' objects>
does anyone know why prefix commands would be working in 2.0.0b1 but not 2.0.0?
I am using a cog approach and have the following handler in the Bot:
async def on_message(self, message: discord.Message) -> None:
if message.author.bot:
return
await self.process_commands(message)
this works in 2.0.0b1 but not 2.0.0 
def __init__(self, specfile_path: str) -> None:
intents = discord.Intents.default()
self.settings = self.load_settings(specfile_path)
self.set_intents(intents)
self.configure_logging()
commands.Bot.__init__(
self,
command_prefix=self.settings.command_prefix,
intents=intents,
)
init function if it matters
how do you get a role from an id in a slash command in a cog?
ctx.guild.get_role
you need message_content intent added
i take it that you cant use ctx and interaction in the same command?
it doesn't really matter which
as long as you get the guild
ctx.guild is just a shortcut for ctx.interaction.guild
I have it
yeah but you didn't set it, you only set default which doesn't include it
intents = discord.Intents.default()
intents.message_content = True```
because discord.ClientUser is just a generic object, it doesn't refer to anything in particular

what are you trying to do
this is the issue i keep running into
thank you 
allgood
yeah i know but i cant get the role with out ctx
but you have ctx defined already...
where?
yeah i added that in to get the role but then i get error
is there a way to get the role without ctx?
?? the error is coming from your interaction argument
which you literally don't need
all commands require ctx
using interaction for the message author id for slash commands
you get interaction from ctx.interaction
ah
but realistically in commands you should just be using the ctx shortcuts for convenience
like ctx.author, ctx.respond and so on
i was but i didnt think you could use interaction and ctx together
thank you :)
all good, i think you're misunderstanding their purposes
ctx is Context or ApplicationContext, and typically has everything needed to "contextualise" where and how a command was used
for prefix commands, Context typically includes a message object since that gives you all the info you need to know; guild, author etc.
and for Application commands, Context includes the interaction data since it also delivers the same data you need
it's because of context that stuff like permissions can be checked fairly easily
so how do i pass ctx.user to discord.Clientuser since member object has no atttribute mfa_enabled for some reason
that makes more sense. thank you
mfa_enabled is only available for the authenticated user... which is the bot
i.e. bot.user
would be rather worrying if you could check if any random user had 2fa enabled
so i can't check if other members have 2fa enabled with thi?
mhm
ok but how do i use discord.ClientUser if i don't call it it just returns <member 'mfa_enabled' of 'ClientUser' objects> for any attribute
and when i call it it want's me to pass instate and data what are those suppose to be
the ONLY discord.ClientUser you will get is bot.user

fdskljafjdnfkljansdlknfljkdsanflkjsnd
i have this in my code:
from discord.ext import commands
@commands.command()
async def ping(self, ctx: commands.context) -> None:
await ctx.send("Pong!")
and with literally no changes to my code, now i am getting:
0|devbot | Ignoring exception in command None:
0|devbot | discord.ext.commands.errors.CommandNotFound: Command "ping" is not found
oh it's silently failing to load my cog now
okay then
no it's something else entirely, there is a deep failure in a dependent package i have an editable install of
how can i get embed from a message?
this is my snippet:
@bot.event
async def on_message(msg):
if msg.author.id == 23789456879236582365:
print(msg.Embed)
oh thanks
how do I require parameters in slash command?
this is the code and I want the user to type his gamertag
gt = xbox.GamerProfile.from_gamertag()
await ctx.respond(f'O usuário tem {gt.gamerscore}g!')
async def command(ctx, argument: str)
Thank you
did not work
to be more specific: I want the user to input something in the command
I have a bot in a guild but when I run
serverList = client.guilds print(str(serverList))
it returns a empty list.
Yes.. that's how it works
Intents?
Intents = discord.Intents.default()
Intents.message_content = True
still returns empty
When are you printing that
Well there are no guilds cached, lol. You can run it after on_ready
TY
Can we make user inputs on views?
Do you mean something like modals?
Yes
I'm making a command that when executed by an admin, the bot will list all of the channels in a specific category (Or whole Guild) with the CORRECT order as we see them on discord. I tryed to sort the mess that we get from discord by Channel position but i just can not get this to work...
Can anyone help me with this one?
No you can’t
Okie thx
iirc, it returns them in order of how we see it.
Thank you, but can you give me a quick example of how i use iirc?
It’s just as simple as sending the list of text channels
What ctx.channel.category.text_channels returns
And how would i get the right order of the whole guild channels?
Look at the “position” value from what Nziie sent
hello
@bot.command
async def on_member_join(member):
await member.send("Welcome, Happy Trails! ")
this doesnt work and there are no errors
CategoryChannel = bot.get_channel(707534097626693717)
for name in CategoryChannel.channels:
print(name)```
This is mostly right but some channels are in the wrong order.......
This is not a command buddy, you need to use listener
Well i use Cogs for me it is:
@commands.Cog.listener() for you it is @bot.event (i think)
that doesnt work
TypeError: event() missing 1 required positional argument: 'coro'
@wheat topazAnyways should that even happen? Or am i doing something worng?
What do you get from that print?
Send your new code
@bot.event()
async def on_member_join(ctx, member):
await ctx.send("Welcome, Happy Trails! ")
I don’t know what to tell you they are appended into a list in correct order.
It doesn’t take ctx, only member. So do await member.send()
@bot.event()
async def on_member_join(member):
await member.send("Welcome, Happy Trails! ")
@bot.event()
TypeError: event() missing 1 required positional argument: 'coro'
Perhaps the bot doesn’t have access to some channels…
There are more then that channels that are in the incorrect order
@bot.event
async def on_member_join(member):
await member.send("Welcome, Happy Trails! ")
Forgot the coro was there
remove trailing parentheses for the decorators
Well tbh that’s odd
Show code in a SS please
In order to test it you need another user (or you) to leave and join the server back; plus that user needs to have DMs enabled (just letting you know if you don’t)
intents?
So i think this shouldn't happen?
I am on Version 2.0.b7 if this matters
@bot.event
async def on_member_join(member):
await member.send("Welcome, Happy Trails! ")
no shit sherlock
Haven’t been using my pc on like a month, so I’m a little out of date :p
aight
I mean it’s a bit outdated
What can I say… You typed @bot.command to an event ¯_(ツ)_/¯
2.0 stable is out
Thanks for your Help anyways, i think this is "good enough" for now ;v
?tag intents
import discord
from discord.ext import commands
# Get specific intents for fine control
intents = discord.Intents()
intents.emojis = True
intents.guilds = True
intents.messages = True # Required for prefix commands!
...
# Get all non-priveliged intents; this excludes presences, members and message_content
intents = discord.Intents.default()
# Set priveliged intents: these must be enabled on dev portal
intents.members = True
intents.presences = True
intents.message_content = True # Required for prefix commands >= 2.0.0b5
# Get all intents; all intents must be enabled on dev portal.
intents = discord.Intents.all()
# Apply intents when creating your bot
bot = commands.bot(prefix="?", intents=intents)
enable the guilds intent
i did and it doesnt work
wait
nvmd
it works
how do i make it send in the channel tho
bot.get_channel(id)
channel.send
I want to print the text channels and get this error everytime
AttributeError: 'TextChannel' object has no attribute 'news'
The channel does not even exist on my test server
b!rtfm pyc textchannel.news
it doesn’t exist
I know
What’s your code?
@client.command()
async def test(ctx):
liste = [channel for channel in ctx.guild.channels]
print(liste)
show full trace back please and thank you
Traceback (most recent call last):
File "C:\Users\Zerra\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 181, in wrapped
ret = await coro(*args, **kwargs)
File "c:/Users/Zerra/Desktop/Stuff/Bot/Brynhild/test.py", line 15, in test
print(liste)
File "C:\Users\Zerra\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\channel.py", line 190, in __repr__
attrs = [(val, getattr(self, val)) for val in self._repr_attrs]
File "C:\Users\Zerra\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\channel.py", line 190, in <listcomp>
attrs = [(val, getattr(self, val)) for val in self._repr_attrs]
AttributeError: 'TextChannel' object has no attribute 'news'
What version are you using?
rc1
@client.command()
async def test(ctx):
liste = ctx.guild.channels
print(liste)
Try that
Since ctx.guild.channels is already a list.
same error
@client.command()
async def test(ctx):
print(ctx.guild.channels)
I was also trying it on my Pi but still the same error and also with a different bot at a different server
Install pycord:
pip uninstall discord.py
pip install py-cord
Install pycord from git repository: (alpha)
pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord
Bottom one
?tag install
- Uninstall discord.py or any other forks of discord.py you might have with the namespace
discord.
python -m pip uninstall discord.py discord -y
2a. Install py-cord
python -m pip install py-cord
2b. Update py-cord
python pip install -U 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
2b
so uh my bot randomly died, process says it's still online but the bot is offline and won't reconnect, nothing in logs, anyone know what could've happened?
hey yall i am trying to make a simple prefix command but the bot never responds to the prefix but only to the mention, above is a screenshot and below is my code
import os
import discord
from dotenv import load_dotenv
from discord.ext import commands
load_dotenv()
token = os.environ['TOKEN']
bot = commands.Bot(command_prefix=commands.when_mentioned_or("?"))
@bot.event
async def on_ready():
print(f"{bot.user} is logged in!")
@bot.command(name="hello", aliases=['hi'])
async def hello(ctx):
await ctx.send("Hi!")
bot.run(token)
youre missing two required intents for prefixed commands to work (messages and message_content (privileged))
Idek what I'm doing anymore
I have my max message cache limit set to a a decently high number, but the bot starts lagging really bad (like 2-3 second delay) at 200,000 messages cached which is only 1.5mb
Anyone know why
AttributeError: 'NoneType' object has no attribute 'id'
Ignoring exception in on_guild_join
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/discord/client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "/home/container/main.py", line 47, in on_guild_join
await added_me.send ("Tests!")
File "/home/container/.local/lib/python3.9/site-packages/discord/abc.py", line 1428, in send
channel = await self._get_channel()
File "/home/container/.local/lib/python3.9/site-packages/discord/member.py", line 390, in _get_channel
ch = await self.create_dm()
File "/home/container/.local/lib/python3.9/site-packages/discord/member.py", line 194, in general
return await getattr(self._user, x)(*args, **kwargs)
File "/home/container/.local/lib/python3.9/site-packages/discord/user.py", line 499, in create_dm
data: DMChannelPayload = await state.http.start_private_message(self.id)
File "/home/container/.local/lib/python3.9/site-packages/discord/http.py", line 359, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50007): Cannot send messages to this user
Hey, I’m confused why I’m getting this error? My DMs are open to anyone and my bot has all intents enabled?
?tag install
- Uninstall discord.py or any other forks of discord.py you might have with the namespace
discord.
python -m pip uninstall discord.py discord -y
2a. Install py-cord
python -m pip install py-cord
2b. Update py-cord
python pip install -U 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
??
i have this problem raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed\
what would be the best way to store specific member ids(add and remove) in an exterrnal file and check if a member id in in there?
Code smh
Db
okie thanks
bump
a simple code :
import discord
from discord.ext import commands
intent = discord.Intents.all()
bot = commands.Bot(command_prefix="-",help_command=None,intents=intent)
help_command = None
@bot.command
async def he(ctx):
await ctx.send("hehe")
bot.run("Otoken")
@slender lintel
Otoken has no value
man i hidded it
Is it in env
So u deleted the line of code that had ur token right
yes
Can u send full code but change the string so it dosent have ur token just random letters
import discord
from discord.ext import commands
intent = discord.Intents.all()
bot = commands.Bot(command_prefix="-",help_command=None,intents=intent)
help_command = None
@bot.command
async def he(ctx):
await ctx.send("hehe")
bot.run("degwuidhuwejhfiwjeofwoefpw")
that's the full code
@slender lintel
i think you should create a thread
okay
ohok
anyoneee?
who is added_me
well yeah that'd be useful
sorry, one sec
@vivid nacelle can u help me I'm waiting for more than 20 minutes I'm wasting time
don't ping me, I'm not doing support
but you're a core dev man just help me
I’ve been waiting for 70 mins bud, it’s all about who’s available
🤷🏽♂️
try printing added_me, and how consistently do you get the error?
i think using target is the issue, should probably be user
because if im not mistaken, target will be the bot that was added
yep https://docs.pycord.dev/en/master/api.html#discord.AuditLogAction.bot_add
A bot was added to the guild.
When this is the action, the type of target is the Member or User which was added to the guild.
arent message content intent not enforced until august?
you still need the intent regardless
oh
so i just need to add the intent lines and the on_message event for it to work right?
event is not necessary
oh ok
uhh ```python
discord.Option(int, "The time before the invite expires in seconds", required=False, max_value=604800)
`AttributeError: Option does not take min_value or max_value if not of type SlashCommandOptionType.integer or SlashCommandOptionType.number`
tysm, this worked :)
if i need to pass those types, it raises another attribute error saying the object is missing the attribute input_type
is this a bug or is this intentional, if so how do i use it now?
How to go about detecting when a member is kicked?
there isn't a specific event for kick, as it is considered the same as the member leaving
you could use on_member_remove and then check the audit log to see if someone actually kicked
how can i see who added my bot in a server?
i mean how can i make my bot check who added it in a server so it can dm the person "thanks for adding me" or something
I dont think that is made available by discord.
oh
Hi, is it possible to for interaction to remember how many times someone clicked it?
I have a button inside a view, and I need to make it so when you first click the button, it does something, but when you try to click it second, third, ... time, it says you: you already used this button.
This is my current code, it does work, but with one problem, if there are multiple messages containing this view, and you click the button on one of those messages, you cant click it on the others.
def __init__(self, ctx, em):
super().__init__(timeout=config.get('defaults').get('default-timeout'))
self.ctx = ctx
save_button_users = []
@discord.ui.button(label="DMs", style=discord.ButtonStyle.secondary, emoji=":floppy_disk:", disabled=False, custom_id="save_to_dms")
async def save_to_dms_callback(self, button, interaction):
vi = b.View_cancel_message(ctx=self.ctx)
if interaction.user not in self.save_button_users:
await interaction.response.send_message(content=":white_check_mark: Image has been saved to your
DMs!", delete_after=15)
await interaction.user.send(content=" ", embeds=interaction.message.embeds, view=vi)
self.save_button_users.append(interaction.user)
else:
await interaction.response.send_message(content=":x: You have already saved this image!", delete_after=15)```
For what do you need the function anyways?
Each button needs its own custom_ID it can be the same for all of the buttons. You can leave it blank and the lib will cerate a random one for you.
so when someone clicks the button, it sends the content of the embed to users dms
oh, ok
ill try
btw this save to dms button was not my idea, but a feature request by 2 of my friends
How do I do a data base for discord bots could I use a google sheets?
What is the easiest way to do that
Ah that you mean. I would just look if a dm already exist with the image name
You could name the image maybe in a special way to determine it
Like embed_id-author_id-img_name.ext
I think the best ways are real databases. I use postgres but if you want nosql i have heard mongoDB is good
removing the custom id, so the bot generates a new one for each works well
Oh yes
Do I need to download that?
I’m using deploy
Replit*
replit has there own builtin no-SQL database
on the sidebar it will tell you how to do it
Do they really?
Oh wow
Very cool
I’ll be back with question
Just got to work
Cant vouch for it being good becouse i have never used it but its worth a try.
It's about the same speed as a mongodb database
Cuz it's not hosted natively
It's on a seperate server which makes it slower
So every time u make a change it sends a request to the db url
import discord
from discord.ext import commands
from datetime import datetime
from os import times
from time import time
class Shurtsdc992(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_raw_reaction_add(self, payload):
ourMessageID = 998217970478219274
if ourMessageID == payload.message_id:
member = payload.member
guild = member.guild
emoji = payload.emoji.id
if emoji == 998212715858382938:
role = discord.utils.get(guild.roles, name="| PC")
await member.send(f"{member.mention} Du hast dir die **PC** Rolle gegeben.", delete_after=15)
elif emoji == 998213297172135956:
role = discord.utils.get(guild.roles, name="| Playstation")
await member.send(f"{member.mention} Du hast dir die **Playstation** Rolle gegeben.", delete_after=15)
elif emoji == 998213312099651645:
role = discord.utils.get(guild.roles, name="| Xbox")
await member.send(f"{member.mention} Du hast dir die **Xbox** Rolle gegeben.", delete_after=15)
await member.add_roles(role)
@commands.Cog.listener()
async def on_raw_reaction_remove(self, payload):
ourMessageID = 998217970478219274
if ourMessageID == payload.message_id:
member = payload.member
guild = await(self.bot.fetch_guild(payload.guild_id))
member = await(guild.fetch_member(payload.user_id))
emoji = payload.emoji.id
if emoji == 998212715858382938:
role = discord.utils.get(guild.roles, name="| PC")
await member.send(f"{member.mention} Du hast dir die **PC** Rolle entfernt.", delete_after=15)
elif emoji == 998213297172135956:
role = discord.utils.get(guild.roles, name="| Playstation")
await member.send(f"{member.mention} Du hast dir die **Playstation** Rolle entfernt.", delete_after=15)
elif emoji == 998213312099651645:
role = discord.utils.get(guild.roles, name="| Xbox")
await member.send(f"{member.mention} Du hast dir die **Xbox** Rolle entfernt.", delete_after=15)
if member is not None:
await member.remove_roles(role)
else:
print("Member nicht gefunden")
@commands.command(pass_context=True)
async def bye2(self, ctx):
embed = discord.Embed(
title="Selfroles",
description="Wähle deinen Rang aus.\n\n⌨ | Du spielst auf dem PC\n\n | Du spielst auf der Playstation\n\n | Du spielst auf der Xbox",
timestamp=datetime.now(),
color=ctx.author.color
)
embed.set_footer(text=self.bot.user.name, icon_url=self.bot.user.avatar)
embed.set_thumbnail(url=self.bot.user.avatar)
embed.set_image(url="https://cdn.discordapp.com/attachments/883805723807588423/901580387950686259/zerotwo_ist_scheie.gif")
msg = await ctx.send(embed=embed)
await msg.add_reaction('⌨')
await msg.add_reaction('')
await msg.add_reaction('')
def setup(bot):
bot.add_cog(Shurtsdc992(bot))
What shoud i do?
alr
so i see how to do it
how would i create a new thing
from my doc
like when someone joins the server it adds their user to the database
Anyone an idea what could cause this?
future: <Task finished name='Task-341000' coro=<ApplicationCommandMixin.on_application_command_auto_complete.<locals>.callback() done, defined at /var/discord/venv/lib/python3.9/site-packages/discord/bot.py:739> exception=TypeError("'NoneType' object is
not iterable")>
Traceback (most recent call last):
File "/var/discord/venv/lib/python3.9/site-packages/discord/bot.py", line 742, in callback
return await command.invoke_autocomplete_callback(ctx)
File "/var/discord/venv/lib/python3.9/site-packages/discord/commands/core.py", line 1177, in invoke_autocomplete_callback
await command.invoke_autocomplete_callback(ctx)
File "/var/discord/venv/lib/python3.9/site-packages/discord/commands/core.py", line 904, in invoke_autocomplete_callback
choices = [o if isinstance(o, OptionChoice) else OptionChoice(o) for o in result][:25]
Is it possible to somehow use for loop when generating buttons inside a view? I have i view that has different number of buttons every time. I found somewhere, that every button has to have its own unique callback. In my last script i used a way around that like this:
Class view(view)
def __init__(self, number_of_buttons, ...)
self.number_of_buttons = number_of_buttons
if number_of_buttons >= 1:
@discord.ui.button(...)
async def button_1_callback(...):
some code
if number_of_buttons >= 2:
@discord.ui.button(...)
async def button_2_callback(...):
some code
--- i repeated this thing up to 20 (that is i think the discords maximum)
My question is, if it is possible somehow to use for loop or something, bcs else this would be many more lines of code (all the buttons are doing basically the same thing, the only difference is one variable, which could be stored as parameter im function)?
why my bot send more than 1 embed?
async def on_member_join(member):
guild = bot.get_guild(998188595372367913)
channel = guild.get_channel(998218612848459877)
embed = discord.Embed(
color=0x3498db
)
embed.add_field(name=f"Someone Just Joined This Server !", value=f"**Welcome To Server {member.mention} !**")
embed.set_image(url="https://media.giphy.com/media/AFdcYElkoNAUE/giphy.gif")
await channel.send(embed=embed)```
the code
Traceback (most recent call last):
File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 126, in wrapped
ret = await coro(arg)
File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 852, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "c:\Users\philc\Desktop\Ticket bot WIP\working folder\cogs\utils.py", line 16, in add
cursor.execute(f"SELECT DutieID FROM Duties WHERE DutieName = {duty}")
sqlite3.OperationalError: near "Security": syntax error
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\bot.py", line 993, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 357, in invoke
await injected(ctx)
File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 126, in wrapped
ret = await coro(arg)
File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 1126, in _invoke
await command.invoke(ctx)
File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 357, in invoke
await injected(ctx)
File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 134, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: OperationalError: near "Security": syntax error```
dont understand the syntax error
any ideas?
its sends like 3 or 4 time
You added two different bots.
I see mee6 and dankmemer. So two are def send
while people join my bot also send 3 or 4 embed too
You need to put quotes around the duty argument in your SQL
Are you sure the users is not leaving and rejoining?
so all arguments need to me in quotes
The only way ot would be sending multiple times is if you have multiple on_member_join events that send an embeds.
Your DutieName column has a string type so you need to specify the thing you are passing is a string.
'{duty}' otherwise it assumes you are looking for a column or table named whatever the duty variable is
Traceback (most recent call last):
File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 126, in wrapped
ret = await coro(arg)
File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 852, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "c:\Users\philc\Desktop\Ticket bot WIP\working folder\cogs\utils.py", line 26, in add
cursor.execute(sql, val)
sqlite3.InterfaceError: Error binding parameter 1 - probably unsupported type.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\bot.py", line 993, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 357, in invoke
await injected(ctx)
File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 126, in wrapped
ret = await coro(arg)
File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 1126, in _invoke
await command.invoke(ctx)
File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 357, in invoke
await injected(ctx)
File "C:\Users\philc\Desktop\venvs\artybot20\lib\site-packages\discord\commands\core.py", line 134, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: InterfaceError: Error binding parameter 1 - probably unsupported type.```
import sqlite3
import discord
from discord.ext import commands
from discord import option
class Duties(commands.Cog):
def __init__(self, bot):
self.bot = bot
duties = discord.SlashCommandGroup('duties', description='Add or remove duties from members.')
@duties.command(guild_id=[988177984299081748], name='add', description='Add a duty to a member.')
@option('duty', description='The duty to add to the member.', choices=["ARF Instructor", "Battalion Security Officer", "Doc Logistics", "Droid Technician"])
async def add(self, ctx: discord.ApplicationContext, member: discord.Member, duty: str):
db = sqlite3.connect('Artemis.sqlite')
cursor = db.cursor()
cursor.execute(f"SELECT DutieID FROM Duties WHERE DutieName = '{duty}'")
dutyID = cursor.fetchone()
cursor.execute(f"SELECT MemberID FROM MemberDuties WHERE MemberID = '{member.id}' AND DutieID = '{dutyID}'")
result = cursor.fetchone()
if result is None:
sql = (f"INSERT INTO MemberDuties (MemberID, DutieID) VALUES (?,?)")
val = (member.id, dutyID)
cursor.execute(sql, val)
db.commit()
await ctx.respond(f"{member.mention} has been added to {duty}", ephemeral=True)
elif result is not None:
await ctx.respond(f'{member.name} has already been assigned to {duty}')
def setup(bot):
bot.add_cog(Duties(bot))```
Hello, i want to make a list of permissions a User has in a Channel (not Server). The Permission value code i get isn't helping me really... Is there a way of printing out all Permissions i have with the value code?
permission_for maybe
You need to pass the arguments individually and not as a tuple
i thought u had to go
I use that but i get the Value code in like: 1089647486161
Just for a few minutes I'm back now
Yes. That’s correct
how do i make it so when the person dms the bot their username, it gets the members database and adds there user
Learn how to translate this / convert it. Read the docs for permissions
Hm... but how do i use this code?
Do you have other bots running or other on_member_join events?
Isn't there a library for this
Try and see 
Read the docs. No need for a lib. It’s integrated.
i am trying
how do i do like command doesnt exist function
no
just one on_member_join
You would need to use the on_message event. And check if the channel is the DM channel for that user.a
it looked normal before i changed the embed color
ive tried making dm commands but it doesnt work
i dont know why
how do i make dm commands that work when dming the bot
ive done way more advanced stuff than this
ive never really done THIS
the stuff i have found is bad
Are you 100% sure there is not more than 1 bot running. One of the embeds is different. So it means more than 1 bot is running or you have multiple on_member_joins
how do i change it from a tuple?
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
embed = discord.Embed(
title="Hmmmmm",url="", description="There is no command with this given Aircraft name, try checked for Capital letters.",
color=0x0033ff
)
embed.add_field(name="Example", value="!F14",inline=False)
await ctx.send(embed=embed)
this doesnt work
for some reason
That means you had multiple bots running somewhere. Resetting the token logs them out.
Have you ever used a external host that you kept running
i think you should send your code
just solved
cool
val is a tuple but you need to pass member.id and dutyID to cursor.execute separately.
ice wolf
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
embed = discord.Embed(
title="Hmmmmm",url="", description="There is no command with this given Aircraft name, try checked for Capital letters.",
color=0x0033ff
)
embed.add_field(name="Example", value="!F14",inline=False)
await ctx.send(embed=embed)
```
this not working
idk why
do you? i have other commands that work that way and they work perfectly
@worthy basin ive looked everywhere
i cant find dming the bot
only the bot dming the user
Does it have the bot.event decorator?
oh yeah
i fuixed it
that was the problem
but how do i make it posible for a user to be able to dm the bot
ive looked everyhwere
Are you sure that it is exactly the same?
I would understand if this worked. (?)
but this (?,?) would need 2 arguments
What do you mean make it possible?
cursor.execute(f'SELECT MemberID FROM Detentions WHERE MemberID = {member.id} AND Released = 0')
results = cursor.fetchone()
if results is None:
message = await ctx.send(f'Transfering...')
roles_list = []
for role in member.roles:
roles_list.append(role.id)
try:
await member.remove_roles(role)
except:
print(f"Cant remove role {role.name}")
roles_list_str = ','.join(str(x) for x in roles_list)
sql = (f'INSERT INTO Detentions(MemberID, RoleList, Released) VALUES(?,?,0)')
val = (member.id, roles_list_str)
cursor.execute(sql, val)
await message.delete()
await member.add_roles(suspended)
await ctx.respond(f'transfered {member.mention} to {channel} because {reason}', ephemeral=True)
elif results is not None:
await ctx.respond(f'{member.mention} is already in the detention list.')
db.commit()
cursor.close()```
this is a different command and works perfectly with no errors
but i cant find how to do it
Commands should work in DMs automatically
Ah I read the error wrong the first time check to make sure the values you are passing are the correct types for the column
they should be all ints
And the columns both except ints?
yep
ik im doing something wrong
author = message_author
how do i get the author of the message
ctx.message.author
alr thx
stupid question
i should know that lol
how do i get a item in my database, and then edit it
db["key"] = "value"
The excuse above that has the 2 IDs being checked against strings. If they are ints they should not be doing this. I do t think thats the error but something I will catch so it dosent cause issues later.
ah so when i print the dutyID variable i get (1,) it needs to be just 1 think thats what is causing the error
Yes that would be it
how do i format it to get the 1?
I would assume just getting the 0th index [0]
perfect, thank you
what does the 0 index do?
compared to [1] etc
So it returns a tuple so you need to get the first item of that tuple.
Programing counting starts at 0 so 1 is the second item in a normal counting system
Nope it only creates a new one if the key does not already exist otherwise it just updates it. The repl db works very similar to a dictionary
im having trouble displaying all the users and their values
You could loop through like this
for key in db.keys():
print(f"{key}: {db[key]}")
My bad, updated
does that list all of the keys?
can i manually delete keys?
db.keys() is all the keys than it will print this format for all keys
key: value
cause its keeping old keys that have the wrong stuff
Look up how to delete a value from a dictionary. In python that should tell you how to delete it
@slender lintel you ask pretty much. Consider using an own thread from now on. General help should be more like “help with problems which could be quickly resolved”
Advanced stuff spams this thread
Not in repl I dont think
No not permanent but you can open a new one for each new problem
i did it its ok
can't see your thread
i didnt make it yet
couple more questions
how do i see how long a member has been in the server
and send it
through code
https://docs.pycord.dev/en/master/api.html?highlight=member#discord.Member
There is a method in there for join date i think
i created the post
How can I make him take all the sentence
Put the hello world in quotes
Or
In the function declaration
async def example (ctx, *, random):
Make sure to have the asterisk
That will make it take the rest of the msg
Okay tnx
(probably)
Yw
And how can I make a command accessible for admins only
@commands.has_permissions
yo
how do i get the profile picture of a user
@bot.command()
async def User(ctx):
author = ctx.message.author
embed = discord.Embed(
title=f"{author}", url="", description=f"Joined On{author.joined_at}", color=0x03fc07
)
embed.Set_image(url = f"{author.avatar_url}")
embed.add_field(name="Sky Warriors Username", value=db[f"{author}"],inline=False)
await ctx.send(embed=embed)
that doesnt work
author.display_avatar.url
?tag tias
and also rtfm
it doesnt work
?tag idw
Saying it doesn't work or asking what's wrong with this code? is not helpful for yourself or others.
Describe what you expect and/or tried (with your code), and what isn't going right.
Please provide any errors you get for optimal assistance.
tag tias edited.
i want it to display the player's pfp
you have your own thread, use it please
nobody responds to it
Tnx alot
Tag nohelp created.
@slow dome ^ use that next time
?tag nohelp
Nobody helps you? See #help-rules §2, then you know why.
ok


