#discord-bots
1 messages · Page 13 of 1
lmao
wasn't that stella's og msg?
could you send your code please?
well it's very messy, do you think I can just explain what's going on?
just need to see the part where you edit the message
Don't remember who sent it first but i'm very thankful
it edits the message with the use of a dictionary:
# the dictionary
msg_attrs = {
'embed': PC_embed(interaction.user),
'view': PC_view(),
'file': None
}
# editing the message
await interaction.response.edit_message(**msg_attrs)
and you're responding withing 3 seconds of receiving the interaction?
Aka kwargs in a nutshell.
the embed and view change perfectly
mhm
i have another part of the code which uses file and it works
in edit_message?
!d discord.abc.Messageable.send.file
no..
No documentation found for the requested symbol.
same, its helpful
right, editing is different from sending so
oh
so, I should try doing attachments = []?
yep
Snow
same
who are we talking about bro
any body help me plz !!!!
py```
import discord
from discord.ext import commands
import music
import os
cogs = [music]
client = commands.Bot(command_prefix='?', intents = discord.Intents.all())
for i in range(len(cogs)):
cogs[i].setup(client)
client.run(os.environ['token'])
@royal bone We don't help with making music bots.
getting this error!
im not making a music bot i want to make a text to speech bot
how could i make a bot who can speak in channel by some text ??
it's .command not .commands
you can use the gtts library and save the text to speech voice in a file and pass the file through Opus and play it
im saving the file in mp3 but dont how to play this in channel ?
replit sucks
im creating a welcome command and idk why its not working, i have all intents on and the privalleged intents. Ik my cog has loaded but it still doesnt work
this snippet of code doesn't seem to be working, and I already checked the values of the variables and they are right. Am I doing embeds wrong or something?
emb = discord.Embed(description="Música adicionada à fila.", thumbnail=thumbnail, colour=0xc79604)
emb.add_field(name="Música",value=f"[{title}]({link})",inline=False)
emb.add_field(name="Duração",value=f"{duration}",inline=True)
await ctx.send(embed=emb)```
im creating a welcome command and idk why its not working, i have all intents on and the privalleged intents. Ik my cog has loaded but it still doesnt work
code:
from nextcord.ext import commands
GUILD_ID = 995268926197989396
INTRO_CHANNEL_ID = 1001024359047102514
RULES_CHANNEL_ID = 1001024359047102514
UNASSIGNED_ROLE_ID = 1002895305752190997
class WelcomeCog(commands.Cog, name="Welcome"):
"""Welcome users when they join"""
def __init__(self, bot: commands.Bot):
self.bot = bot
@commands.Cog.listener()
async def on_member_join(self, member: nextcord.Member):
"""Welcome members when they join"""
guild = self.bot.get_guild(GUILD_ID)
intro_channel = guild.get_channel(INTRO_CHANNEL_ID)
rules_channel = guild.get_channel(RULES_CHANNEL_ID)
# send welcome message
await intro_channel.send(
f"Welcome to the server, {member.mention}!\n"
f"Please read the rules in {rules_channel.mention} to gain access to the rest of the server!")
@commands.Cog.listener()
async def on_ready(self):
print("Welcome Cog has loaded!")
# setup functions for bot
def setup(bot):
bot.add_cog(WelcomeCog(bot))```
does anyone know why?
fixed ^
how i can play audio in channel by replit ?
Guys I need help
Can someone please help me code just a BASIC command that I can view all the roles in my server
@bot.command()
async def roles(ctx):
embed = discord.Embed(title=f'Roles in {ctx.guild}', description='\n'.join(i.mention for i in await ctx.guild.fetch_roles()))
await ctx.reply(embed=embed)```
Ok thanks
i made something that does this, but i forgot
you have an extra period when adding the guild object and you should use generators not map, its slower
no u
"\n".join(role.mention for role in await ctx.guild.fetch_roles())
ok
so you would do py source = await disnake.FFmpegOpusAudio.from_probe("song.mp3") channel = await ctx.guild.fetch_channel(int) connection = await channel.connect() await connection.play(source)
and black is gonna format you
class discord.VoiceClient```
Represents a Discord voice connection.
You do not create these, you typically get them from e.g. [`VoiceChannel.connect()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.VoiceChannel.connect "discord.VoiceChannel.connect").
Warning
In order to use PCM based AudioSources, you must have the opus library installed on your system and loaded through [`opus.load_opus()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.opus.load_opus "discord.opus.load_opus"). Otherwise, your AudioSources must be opus encoded (e.g. using [`FFmpegOpusAudio`](https://discordpy.readthedocs.io/en/latest/api.html#discord.FFmpegOpusAudio "discord.FFmpegOpusAudio")) or the library will not be able to transmit audio.
How is the installation command for my bot to work?
isn't there a command from github?
i wonder why discord doesnt have a feature that displays a few lines of code in the github link you send, it would really be helpful over using bots
why not? its helpful especially for devs
hey is there a way so it goes from top role to lowest like in order or impossible?
yes it is
could u please help me with that, i really need it
updated message
hmm, it still doesnt do it in order
await ctx.send(f"The highest role in this guild is {ctx.guild.roles[0].mention}")
thats all you need lol
not highest role
All roles in order?
The first item of the list is the lowest in hierarchy
The top role would be the last item of the list
so its inverted?
Yes
mhm cool
roles[-1]
anyways got to go, andy hes all yours🏃♂️
Who in the name of _ pinged and deleted
👀
zeffo pinged you and the messages got deleted
and i ghost pinged snow🗿
Bruh weirdos
dont say that to your best friend
No, the person who deleted
oh cool
okimii
help lol
lemme give u a example
server roles: ```
owner
co - owner
server manager
this is a example, currently this is what i get
server manager
owner
co - owner```
so i need in order
well in my method it just mentions all the roles in order you just need to customize it for your needs
idk how to do that
look it can be from top to bottom or bottom to top, as long as its in order idc which way.
await ctx.send("\n".join(role.mention for role in roles))
TypeError: 'NoneType' object is not iterable
btw i would just mention their names over pinging the roles, it can lead to spam pings or just put it in the description of an embed so it doesnt ping the roles but it mentions them
yes i dont mind i dont need it to ping, i need to copy to another server
oh right the method doesnt return anything
well im not sure how it would be done tbh
how does ur work?
await ctx.send("\n".join(role.mention for role in await ctx.guild.fetch_roles()))
or get_roles()

i just prefer api calls
you prefer chaos
you prefer something that isn't preferable
i prefer something that is
we are not the same
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Guild' object has no attribute 'get_roles'
@quaint epoch ?
await fetch_roles()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves all [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role") that the guild has.
Note
This method is an API call. For general usage, consider [`roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.roles "discord.Guild.roles") instead.
New in version 1.3.
hm?
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Context' object has no attribute 'fetch_roles'
brh
just run this code directly
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In content: Must be 2000 or fewer in length.
brhhh
just do this
caps moment
it works but its not in order..
no clue then
if someone knows how to solve this lmk
@obsidian flicker What is ur exact problem?
show it shows roles but i need them in order
@obsidian flicker
roles = ctx.guild.roles
order_roles = roles.reverse()
await ctx.send("\n".join(role.mention for role in roles))
that should would iirc
.reverse() mutates the original list so order_roles is None while roles has been reversed
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'NoneType' object is not iterable
You could just use the built in reversed()
yeah lol
!e print(reversed(range(10)))

lol
@pliant gulch :white_check_mark: Your 3.11 eval job has completed with return code 0.
<range_iterator object at 0x7f5b88698720>
this is fun to watch
I’m on mobile at the moment
its not easy
!e print(*(reversed(range(10))))
@pliant gulch :white_check_mark: Your 3.11 eval job has completed with return code 0.
9 8 7 6 5 4 3 2 1 0
never even knew reversed was a built in method lol
Unpacks the iterable
@obsidian flicker this should work lol
await ctx.send("\n".join(reversed([role.mention for role in ctx.guild.roles])))
reversed is a pretty cool method ngl
Won’t work
join expects an iterator of strings
This will error
right map needs to be used
No?
Note the word at the end
Unless you mean using map to str them all
ik, but a list comp would be better either way
what then
yeah, e.g mention but a generator would be faster
btw no need for the extra parenthesis
now it should work, jeez mobile coding is hard
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In content: Must be 2000 or fewer in length.
lmfao
make the message shorter
how shorter
await ctx.send("\n".join(reversed([role.mention for role in ctx.guild.roles])))```
i have this.
ye i dont need mentions
well then change .mention to .name
how add reaction on message that webhook send
there only delete and edit
fetch the message to get the message obj
but i dont have the id too
you can also get the last message with history iirc
It's a bet
@commands.command()
async def promote(self, ctx, user: discord.User = None):
if user is None:
await ctx.send("Please choose a user to promote")
else:
for role in user:
print(role.name)```How do I list all roles in a user?
Traceback (most recent call last):
File "C:\Users\llVll\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\llVll\Desktop\Projects\Lunar Vigil Bot\cogs\utils.py", line 94, in promote
for role in user:
TypeError: 'User' object is not iterable```
for role in user.roles:
still errors
What error?
Traceback (most recent call last):
File "C:\Users\llVll\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\llVll\Desktop\Projects\Lunar Vigil Bot\cogs\utils.py", line 94, in promote
for role in user.roles:
AttributeError: 'User' object has no attribute 'roles'
The above exception was the direct cause of the following exception:```
Might be because you're casting it as a User object and not a Member object
Try it with
user: discord.Member
@commands.command()
async def promote(self, ctx, user: discord.User = None):
if user is None:
await ctx.send("Please choose a user to promote")
else:
for role in user.roles:
print(role.name)```
that's the full code
oh it works, thanks
why does discord.User not work?
a User object just represents a normal discord user, with their id, name, identifier, stuff like that. a Member object inherits from User, but includes more guild-specific information, such as roles, nicknames, etc.
ah
!d discord.Member
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User").
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.
hash(x) Returns the member’s hash.
str(x) Returns the member’s name with the discriminator.
I see
if user is None:
await ctx.send("Please choose a user to promote")
else:
for role in user.roles:
list.append(role.id)
if scout in list:
removerole = discord.utils.get(ctx.guild.roles, scout)
addrole = discord.utils.get(ctx.guild.roles, battle)
await user.remove_roles(removerole)
await user.add_roles(addrole)``` ```Traceback (most recent call last):
File "C:\Users\llVll\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\llVll\Desktop\Projects\Lunar Vigil Bot\cogs\utils.py", line 113, in promote
removerole = discord.utils.get(ctx.guild.roles, scout)
TypeError: get() takes 1 positional argument but 2 were given``` Can someone help?
ctx.guild.get_role when
do it instead of discord.utils
oh nice
guys, what if instead of a json OR some kind of db,
i store stuff in dict format in .py file? 👀
i was thinking of creating a table that has 1 item for every column but that means if i want to add 50 items to the game that means 50 columns in the table which will make the table too long in a ridiculous way and the table inside the database will look sth like this :
user_id | sword| shield| potion| etc...
10 | x 1 | x1 | x5 | ..
is there any short way of doing it?
class remyclient(discord.Client):
def __init__(self):
super().__init__(intents=intents)
self.synced = False
async def on_ready(self):
await self.wait_until_ready()
if not self.synced:
await tree.sync()
self.synced = True
print("Succesfully logged in & synced commands")
remy = remyclient()
tree = app_commands.CommandTree(remy)
is this a bad way of doing slash commands?
yes, bad way of syncing
What's better
Sync when you...
- Added/removed a command
- Changed a command's...
- name (name= kwarg or function name)
- description (description= kwarg or docstring)
- Added/removed an argument
- Changed an argument's...
- name (rename decorator)
- description (describe decorator)
- type (arg: str str is the type here)
- Added/modified permissions:
- guild_only decorator or kwarg
- default_permissions decorator or kwarg
- nsfw kwarg
- Converted the global/guild command to a guild/global command
Do not sync when you...
- Changed anything in the function's body (after the async def (): part)
- Added or modified a library side check:
- (@)app_commands.checks...
- (@)commands...(.check)
- @app_commands.checks.(dynamic_)cooldown(...)
This is the same for hybrid commands
Why's it so bad?
@bot.command()
@commands.guild_only()
async def sync(
ctx: Context, guilds: Greedy[discord.Object], spec: Optional[Literal["~", "*", "^"]] = None) -> None:
if not guilds:
if spec == "~":
synced = await ctx.bot.tree.sync(guild=ctx.guild)
elif spec == "*":
ctx.bot.tree.copy_global_to(guild=ctx.guild)
synced = await ctx.bot.tree.sync(guild=ctx.guild)
elif spec == "^":
ctx.bot.tree.clear_commands(guild=ctx.guild)
await ctx.bot.tree.sync(guild=ctx.guild)
synced = []
else:
synced = await ctx.bot.tree.sync()
await ctx.send(
f"Synced {len(synced)} commands {'globally' if spec is None else 'to the current guild.'}"
)
return
ret = 0
for guild in guilds:
try:
await ctx.bot.tree.sync(guild=guild)
except discord.HTTPException:
pass
else:
ret += 1
await ctx.send(f"Synced the tree to {ret}/{len(guilds)}.")```
`commands.Greedy`
`discord.Object`
`typing.Optional and typing.Literal`
Works like:
`!sync` -> global sync
`!sync ~` -> sync current guild
`!sync *` -> copies all global app commands to current guild and syncs
`!sync ^` -> clears all commands from the current guild target and syncs (removes guild commands)
`!sync id_1 id_2` -> syncs guilds with id 1 and 2
I'm too lazy to do that and I wont re run my bot a thousand times so I wont get rate limited
@bot.command()
async def banlist(self, ctx):
bans = await ctx.guild.bans()
loop = [f"{u[1]} ({u[1].id})" for u in bans]
_list = "\r\n".join([f"[{str(num).zfill(2)}] {data}" for num, data in enumerate(loop, start=1)])
await ctx.send(f"ini\n{_list}")```
discord.ext.commands.errors.MissingRequiredArgument: ctx is a required argument that is missing.```
how can i fix this?
are you using a cog?
wdym
oh
oke
ok so the command works like this:
how can i remove the [1] [2]
and the other numbers
and how can i make the bot send this command into an embed
!d discord.Embed
class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
x == y Checks if two embeds are equal.
New in version 2.0...
yea i know that but i want the bot to send this code:py @bot.command() async def banlist(ctx): bans = await ctx.guild.bans() loop = [f"{u[1]} ({u[1].id})" for u in bans] _list = "\r\n".join([f"[{str(num).zfill(2)}] {data}" for num, data in enumerate(loop, start=1)]) await ctx.send(f"ini\n{_list_}") in an embed
Exactly,
a simple way would be to take what the bot is sending and put it as the embed description, assuming that's what you want
thats why im asking u guys
Just make the embed variable and do add_field
!d discord.Embed.add_field
add_field(*, name, value, inline=True)```
Adds a field to the embed object.
This function returns the class instance to allow for fluent-style chaining. Can only be up to 25 fields.
@novel prairie ^
oke
I mean it's preference, I like discord.py but some may prefer py-cord instead
I think discord.py is used most though
Yeah
okimii is typing...
most popular is discord.py, hikari is very modular and has pretty good implementations, if you want a wrapper that is the best for you, just make one for yourself, youll know each and every corner of it
how can i tag a specific user in an embed command?
If you have the user/member object you can do user.mention, else you just do <@useridhere>
How can I take in a file as an option for a slash command?
Discord.py
I think you would typehint the parameter with discord.File
that wouldn't actually mention the user
thx i have
Does anyone know any free lavalink servers I can use that isn’t ssl/https/wss? I’ve heard that http/ws works fine but I don’t know any
Does anybody know how to fix this
ERROR: No matching distribution found for yaml
i tryed to do pip install yaml and it dosent work
Ha, great I’m not using my laptop rn
I remember that I had discord.Intents.default or something
@maiden fable How do I add adding a file as a option in slash commands?
No idea, but I think u gotta use the discord.File typehint or smth?
ModuleNotFoundError: No module named 'fade'
when i try to install fade it says this
Requirement already satisfied: fade in c:\users\tcale\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (0.0.9)
i dont understand
It's already there
Read this 😳
It says this after i try running the py though
Traceback (most recent call last):
File "C:\Users\tcale\Desktop\NITRO REDEEMER\redeemer.py", line 3, in <module>
import fade
ModuleNotFoundError: No module named 'fade'
After i already installed fade
What's tha name of your file ?
Is it fade?
Redeemer.py is the file name
pip freeze to check u have this or not
that seems weird what does that do?
Import efoundation
I have database entrys 1) id 2) economy , how can I add money only to a specific role 🤔
Anyone?
Isn't lavalink ytdl but server based
That's the crux, yea
i need help with doing pip install it wont work
Hello can you suggest me any bot which give auto role to bots only not members?So i dont need to remove member role always
$pip install
i do the moneysign?
'$pip' is not recognized as an internal or external command,
operable program or batch file.
lol what do you mean you geuus
Nvm.. Try it.
this is what it says when i do pip install
ERROR: You must give at least one requirement to install
Do you have a variable called print? Anyways, i would ask in #python-discussion
Hello can you suggest me any bot which give auto role to bots only not members?So i dont need to remove member role always
lemme check
py -m pip install fade
py redeemer.py
Ye
Also for non discord bot related issues check out #❓|how-to-get-help
oh. i had that variable.. thanks man
ModuleNotFoundError: No module named 'yaml'
Install it then
Fine.. But atleast tell me.. The bot name
ERROR: Could not find a version that satisfies the requirement yaml (from versions: none)
ERROR: No matching distribution found for yaml
The package is pyyaml or something
Check on pypi, and don't you have a requirements.txt or something?
Some sort of dependency management
ModuleNotFoundError: No module named 'yaml' after i installed it
I can tell you how to make your own bot for it, not sure of any pre-made bots thougj
How did you install it
Lol..ik how to code a little and host a bot.. But i still suck at coding
I can copy and paste lol
pip install pyyaml
Install it the same way you installed fade
^
ERROR: unknown command "pyyaml"
send me the way i should install it
py -m pip install pyyaml
ModuleNotFoundError: No module named 'colorama'
@vocal snow we slowly fixing it
whats the install for colorma
You can google these
i cant find it do you know the colorma install thanks yo
whats colorma
a python library
Do you know the install commands for it
i need the install for this ModuleNotFoundError: No module named 'colorama'
ERROR: Could not find a version that satisfies the requirement colorma (from versions: none)
ERROR: No matching distribution found for colorma
do any of you know how to do autocomplete for hybrid commands in discord.py?(it'll only work if the command is invoked via slash of course)
how do you get the bot's username+tag 💀 I forgor
@client.command(intents=intents)
async def tmm(ctx):
await ctx.send(embed=discord.Embed(title="check", description=f"{len(client.guilds)} servers, {len(set(client.get_all_members()))}"))
Why members command is not working?
!d discord.User._str_
oop
str(user)
The user’s username.
Or that, yea
ah ok
this wont give discrim i think
Anyone?
Also, @vocal snow dunder methods ain't supported by Python iirc
!intent
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
You're correct @vocal snow
@maiden fable
Done but not working
what code did u use to enable intents
Wait
you can just do discord.Intents.all() I believe
intents = discord.Intents.default()
intents.members = True
intents.guilds = True
I want to create a help for on selfbot but his always tells me impossible to send an empty embed that can give me a little help please
we don't help with selfbots
The question regarding "self bots" has come up here and there, and we'd like to make our stance clear:
Discord's API provides a separate type of user account dedicated to automation, called a bot a...
ERROR: Could not find a version that satisfies the requirement colorma (from versions: none)
ERROR: No matching distribution found for colorma
i need help whats the command for colorma
!pypi colorama
!pypi embed
!discordpy embed
Does not work
when i try to do pip install colorma it dont work any other commands can someone help
@maiden fable what would I do with the file object after type hinting it?
slash command to take in file option
No idea
ModuleNotFoundError: No module named 'colorama'
still dont work
U didn't install it
Yes i did lol
Then probably u installed in the wrong Python version
How do i check my version
because i have the newest one
U have multiple
Check in control panel
!d discord.Embed ?
class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
x == y Checks if two embeds are equal.
New in version 2.0...
how come I can't generate a bot invite url?
skill issuue
Bruh
How do i fix this i install colorama but when i run my .py it says no module named colorama
It's pip install colorama
yea i already did that and this what it says
Make sure it's correct colorama
? what do you mean how do i make sure its the correct colorama isn't there only 1 command for it?
There can be others with same name
oooo what are the others commands do you know?
.
I've got another problem with my py-cord bot. I'm sure that there is an error somewhere in my code, but it isn't showing up. My cog isn't loading and the only time I've had that happen to me before is when there is an error in the cog. However, I'm not getting any traceback to where the error might be.
do you have an error handler?
wdym
like some event listener for on_command_error?
no
so what part do you think errors out
honestly I don't know
maybe there is something wrong with the intents
I've confused myself with all this tangled code
it's like 1 part of the code links to another and that links to something else which makes it a nightmare to debug
hmm, try to use commands and see which commands don't work
would this code be right before i run it? I’m trying to make it so whenever there’s an error with a command, the full traceback sends to my dm and I’m using hikari-lightbulb
@errors_plugin.listener(lightbulb.CommandErrorEvent)
async def on_error(event: lightbulb.CommandErrorEvent) -> None:
exception = event.exception
users = [
event.context.cache.get_user(user) for user in [690631795473121280, 994738626816647262]
] # 1: main, 2: second
if isinstance(exception, lightbulb.CommandInvocationError):
await event.context.respond(
f"Something went wrong during invocation of command `{event.context.command.name}`."
)
for user in users:
await event.context.respond(
embed = hikari.Embed(
title=f"An unexpected `{type(exception).__name__}` occurred",
description=f"`/`/`py\n{''.join(format_exception(exception.__class__, exception, exception.__traceback))}`/`/`"
)
)```
the whole cog doesn't get loaded
does the cog have a setup function?
why 
yes
can u show how you are loading your cogs
you are not really meant to run that file individually, its set in such a way that everything is imported relative to the main file
def setup(client):
client.add_cog(PokemonRed(client))
if you want to run it, you might have to make a relative import https://stackoverflow.com/questions/72852/how-to-do-relative-imports-in-python
bot.load_extension('game')
is game.py in the same folder as the file you are loading cogs in?
it was working just fine before i made some changes, nothing to do with the file's placement or how it's loaded. It's just an error that doesn't show up.
...
if its for example in folder cogs this'll definetly cause error
!paste can u send the faulty cog here
Pasting large amounts of code
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
gimme a min
is there a way to make a discord bot appear offline?
!BucketType
change_presence
look
@client.event
async def on_ready():
print(f"{client.user.name} - cached & loaded in 3s")
activity = discord.Game(name=",help", type=4)
await client.change_presence(status=discord.Status.online,
activity=activity)
python -m pip install colorama
C:\Users\tcale\Desktop\NITRO REDEEMER>-m pip install colorama
'-m' is not recognized as an internal or external command,
operable program or batch file.
Why my client is not running?
import discord
from discord.ext import commands
client = commands.Bot(command_prefix = ".")
@client.event
async def on_ready():
print("Bot is ready!")
@client.command()
async def ping(ctx):
await ctx.send(f"pong! {round(client.latency * 1000)}")
client.run = ("")
python -m
bro these people are gonna make me go crazy
he didnt even type in python 😭
wtf is client.run = ("")
@slate swan
client.run("TOKEN")
I TYPED THE TOKEN
wonder what that is too 🤣
answer to my question would be interesting
dude it still says this after i put python at the start
then fix yo shit lil bro
oh he didnt even gget it
LMFAOOO
Thats what im tryna do? but colorama still aint on here
@slate swan i typed the token
It didn't work
client.run = ("") replace that line with client.run("TOKENINBETWEENQUOTES")
@slate swan this is the funniest shit ever
🗿
The actual bot token
It didn't work
well yeah what other token..???
:painnn:
Bro it says i still dont have colorama when i already tryed every install command for it
im trying to make my bot appear offline ```py
@client.event
async def on_ready():
print(f"{client.user.name} - cached & loaded in 3s")
activity = discord.Game(name="discord.com", type=4)
await client.change_presence(status=discord.Status.online,
activity=activity)
It didn't work
use some common sense here
Bro it says i still dont have colorama when i already tryed every install command for it
Hey @slate swan! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me
Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!
HAISFHOHADSOHSAJDK
GG
Nice IQ there pal
done

Post your code without the token..
Bro it says i still dont have colorama when i already tryed every install command for it
Hi guys in todays video I teach you guys on how to create a discord bot using discord.py 2.0
============= Links =============
Discord.py 2.0 - pip install git+https://github.com/Rapptz/discord.py
Discord Developer - https://discord.com/developers/applications
Main Channel - https://www.youtube.com/c/CivoProHD
============= Time Stamps ====...
please please just watch this
yo y9
utub is trash but i agree in this situation
is it possiable to make
?
a bot appear offline
Is there any other install commands for colorama ive tryed them all
but still be working?
!d discord.Status.offline
The member is offline.
await client.change_presence(status=discord.Status.offline)
@client.event
async def on_ready():
print(f"{client.user.name} - cached & loaded in 3s")
activity = discord.Game(name="discord.com", type=4)
await client.change_presence(status=discord.Status.online,
activity=activity)
``` this my code
python --version
I believe.
whats ur python ver
Python 3.10.5
well here your making it appear online
Its just prototype anyway
ik
Replace that last line with the line I said
i did
try it?
LMAO
lemme test it rq
Python 3.10.5
send SS
yea i see
bro check your bot
the console has nothing to print...
?????
Idk let me see the code your using
without the token though
python redeemer.py
...................
ModuleNotFoundError: No module named 'selenium'
replace the last line with
client.run("TOKEN")
so do i do pip install selenium
probably
🤯
dude im new to this quit tryna be all weird
How am I being weird Mr. Boost seller
How is me being a boost seller weird lol?
I already DID
no i understand you think its funny because we dont know basic python but its hard to just "learn"
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
= is absolutely still here and you have to replace "TOKEN" with your bot's token (not showing it here)
I get that but it gets annoying after providing help multiple times on the same exact thing
to the same person
Ohhhhh
I forgot
Yeah forgot.
Im such a dumb person
Yeah I forgot how to walk home
lets go baby
we can all learn
where am i supposed to go
now you can go use your shitty nitro sniper
its to generate nitro tokens you toxic anime fuck lol
Sorry for being dum
you don't need to be so toxic
if it uses selenium for this it's not gonna be too good
who cares anyway lmao
does that break tos ? id ont even know
who reads tos anyway lmao
bruh i have my own problem and im sitting here and laughing
how'd you do that?
what is it?
i didn't delete it
i know
if you want to make a relative import, you have to run the file as a module with -m arg (https://stackoverflow.com/a/11537218)
you also need a __main__.py which will be run when you run the dir as a module
or if the files in tests dir is relative to the main script, just make a new file in the same directory and import the tests
@client.event
async def on_ready():
print(f"{client.user.name} - cached & loaded in 3s")
activity = discord.Game(name="discord.com", type=4)
await client.change_presence(status=discord.Status.offline,
activity=activity)```
2nd last line
last word
embed = discord.Embed(
timestamp=ctx.message.created_at,
title=f"{user}'s Balance",
color= 0xF7C906,```
i want 3-4 colors rendomly
umm, like, here?
yea, and now you import db_test.py in __main__ and do python -m tests
make a list of the colors and use random.choice
what?
do .db_test
color= random.choice(0x0847F7, 0xF7C906 , 0xF90651 , 0x08FC08) this no working
not a list is it?
color= random.choice[0x0847F7, 0xF7C906 , 0xF90651 , 0x08FC08] this way ? like its same
import random
colors = ['0x0847F7', '0xF7C906', '0xF90651', '0x08FC08']
random.choice(colors)
make no difference
like this..
ohhh got it
Lists start with []
invalid syntax
huh? i meant import .db_test intead of db_test
oh wait
you might have to import something from db_test
thats what i did
you have to do something like from .db_test import this
easier option would be #discord-bots message
lol
ok you will have to change the file structure a little
main.py
DB/
tests/
and in main.py you import stuff from tests
and in tests you just import as from DB import ... or from DB.file import ...
@client.listen()
async def on_command_error(ctx, error):
error = getattr(error, "original", error)
if isinstance(error, commands.CommandNotFound):
return
if isinstance(error, commands.DisabledCommand):
await ctx.send("This command has been disabled." , delete_after= 2)
return
if isinstance(error, commands.CommandOnCooldown):
await ctx.send(f"This command is on cooldown, please retry in {math.ceil(error.retry_after)}s.")
return
else:
raise error```
why CommandOnCooldown not working
🤔
@silk fulcrum help him
what do u need from me
Assist LUC with his issue
why me(
@balance.error
async def sm_error(self,ctx , error):
if isinstance(error, commands.DisabledCommand):
await ctx.send("This command has been disabled.")
return
# if isinstance(error, commands.CommandOnCooldown):
# embed = discord.Embed(
# title="Cooldown",
# description=f"This command is on cooldown, please retry in {math.ceil(error.retry_after)}s.",
# color=0xFF0000,
# )
# await ctx.send(embed=embed , delete_after = 2)
# return
else :
raise error```
command error handling
it's commented?
that's probably why it's not working
@silk fulcrum i want this run not commented one
get my point ?
🤔 or i explain again
yes i guess
what exactly doesn't work?
so:
what is a traceback? if you got one
if not:
what did you expect to happen?
and what happened instead?
traceback = discord.ext.commands.errors.CommandOnCooldown: You are on cooldown. Try again in 3.81s
uhm
so what happened is else triggered
so isinstance(error, commands.CommandOnCooldown) is False
i have no idea why
maybe its commands.errors.CommandOnCooldown
so choice = await bot.wait_for("message", check=check, timeout=None) doesnt return anything when a message is sent can someone tell me what is wrong
what's your check?
return not(ctx.author == "[BAD]OO_BOT [WIP]#0274") and ctx.channel == "bots" or ctx.channel == "🤔preview-bots🤔"```
it worked yesterday but i edited it today and it stopped working so i changed it back and now idk what happened
first ctx.author != "..." is better than not(stuff)
oh yeah lmao
Ignoring exception in on_message , whats this
what's the full error?
also you cannot check if ctx.channel is "bots" or "preview-bots" because ctx.channel returns the Channel object, not string. so you can check if ctx.channel.name == "bots" or ctx.channel.id == ID. And third: and statement is higher in hierarchy so it will be not if author is someone then check if channel is something or something, it will be if author is someone AND channel is something1, or instead of that all it can be just channel is something2
bruh what is that i just typed?
noone will read message that long
And also check doesn't give you ctx, it gives message object
yeah i noticed the and or thing when rereading my message but now ik why my bot works in all channels
so i guess it would be thispy def check(m): return m.author.name + "#" + m.author.discriminator != "[BAD]OO_BOT [WIP]#0274" and (m.channel.name == "bots" or m.channel.name == "🤔preview-bots🤔")
tysm
how can i deal with command is on cooldown , at once for reach cog
on_command_error
can i make that my bots changes his status every 24 hours?
but i heard you can get banned for that. is that true?
want to ignore
Traceback (most recent call last):
File "D:\ph\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\Kamal kishore\Desktop\Project 0\main.py", line 98, in on_command_error
raise error
File "D:\ph\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "D:\ph\lib\site-packages\discord\ext\commands\core.py", line 855, in invoke
await self.prepare(ctx)
File "D:\ph\lib\site-packages\discord\ext\commands\core.py", line 788, in prepare
self._prepare_cooldowns(ctx)
File "D:\ph\lib\site-packages\discord\ext\commands\core.py", line 772, in _prepare_cooldowns
raise CommandOnCooldown(bucket, retry_after)
discord.ext.commands.errors.CommandOnCooldown: You are on cooldown. Try again in 3.34s```
this error
nah
every 24 hours is fine
then catch it in the error handler
and already have
@balance.error
async def balance_error(self,ctx , error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.send(f"This command is on cooldown, please retry in {math.ceil(error.retry_after)}s." , delete_after = 2)
return
what if its higher-lower?
@vocal snowi have this but still
and its working too
but i dont know why terminal showing that
I think once every half an hour is the minimum
ty
this is only for the balance command
put the CommandOnCooldown error in on_command_error event
is it possible to add the game status and a picture of the game in discord.py?
@fierce crag 😎
No, bots can't have rich presence
i seen video he was do it
Got it
I want bot read message after every 1 min and change database data but don't react , how can I do ?
@commands.cog.lisner ?
tasks loop ig
are u on discord 2.0 or 1.7
replit lmao
ception: TypeError: add_field() got an unexpected keyword argument 'description'```
!d discord.Embed.add_field use the value kwarg
add_field(*, name, value, inline=True)```
Adds a field to the embed object.
This function returns the class instance to allow for fluent-style chaining. Can only be up to 25 fields.
oke
um... py ception: TypeError: add_field() got an unexpected keyword argument 'icon_url'
I want a on_message function which react to each and every message 😳
read this
Not to a specific
that isnt recommended because you can get ratelimited
yes but you can use in the shell the kill 1
💀 not everyone uses replit like u
that's just abusing replit
lmao
Like not react but level up shit
!d discord.on_message
discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") is created and sent.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Warning
Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
!d discord.Message.add_reaction
await add_reaction(emoji, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Adds a reaction to the message.
The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Emoji "discord.Emoji").
You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.
Changed in version 2.0: `emoji` parameter is now positional-only.
Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") instead of `InvalidArgument`.
idk how you're gonna handle with ur db
Got it
^^ you can use it like await message.add_reaction("😳")
Ya ya , like how i know user sends some message and i have to add it into db
how can i get a list of all the permissions a guild member has?
!d discord.Role.permissions
property permissions```
Returns the role’s permissions.
@odd mango
thanks buddy
dont need role permissions
need member permissions overall
[k for k,v in (dict(member.guild_permissions)).items() if v == 'True'] gives them all, but i just need the key ones
like
Administrator, Manage Server, Manage Roles, Manage Channels, Manage Messages, Manage Webhooks, Manage Nicknames, Manage Emojis, Kick Members, Ban Members, Mention Everyone
If you spam the api and break ratelimits often they ban you yeah
How long?
Run kill 0
Replit shell
That's unfortunate
Where i can find it @vocal snow
I don't know, I don't use replit
I was just sharing what I've heard in this channel before
If i spam running bot i get banned?
huh
he most likely means ratelimited
genius avoid of missing perms
Why is the member param's default value None
Why do you have roles and author as params?
Might want to learn a bit of python first
remake it
burh
💀
I told you but you didn't understand, so
I thought it was real thing
💀
i mean i use kill 1 in shell and then it works fine
No its not its an html code
Huh
Its a paragraph code
oof
Just try this if it works
Where is the shell?
Press the Commands first in the bottom right corner
press enter when you type the kill 1
Ye
How many hours?
💀
What should be message.content == ? , So it conten everything , so I can use it as level up thing
lmao?
lmao
Because im already fucked up
bruh
Is it my ip?
probably
congrats
How can i make my bot online 24 or forever like carl bot
.
get a vps man stop using replit
right
TIL
and what was the cmd to check a piece of code ??
!source source
Display information and a GitHub link to the source code of a command, tag, or cog.
@bot.command()
@commands.has_permissions(manage_messages=True)
async def purge(ctx, amount=5):
await ctx.channel.purge(limit=amount + 1)
await ctx.channel.send("**Cleared `" + str(amount) + "` Messages**",
delete_after=1)
``` the bot would be deleting the msgs but wont send the "cleared +str " stuff
use f strings ;-; and what's the point of even sending if u are deleting in 1 sec
Ur just slow at reading Asher 
does the event even work? @scarlet aurora
like, try printing something when someone joins
if it doesn't you may have to activate intents
nvm I figured it out
oh
for role in member
? 😳
there's no way other than a for loop
What is that...
😳
Ohh k
You can freely use any amount
And how can I take any message as message.content
take as in
For db like i want to give them some xp if they type anything
???
use an on_message event
On_message ?
What will be the message ?
!d discord.on_message
discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") is created and sent.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Warning
Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
a Message object of the message sent
Dose on_message work in commands.cog.listener() ?
Ohhh k k , and how can I take 1 min gap in between 2 message , so level think work
Last question 😂
!d asyncio.sleep
coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.
If *result* is provided, it is returned to the caller when the coroutine completes.
`sleep()` always suspends the current task, allowing other tasks to run.
Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.
Deprecated since version 3.8, removed in version 3.10: The `loop` parameter. This function has been implicitly getting the current running loop since 3.7. See [What’s New in 3.10’s Removed section](https://docs.python.org/3/whatsnew/3.10.html#whatsnew310-removed) for more information.
Example of coroutine displaying the current date every second for 5 seconds:
huh
Its a public IP, nothing private.
ohkay
!d discord.on_voice_state_update
discord.on_voice_state_update(member, before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") changes their [`VoiceState`](https://discordpy.readthedocs.io/en/latest/api.html#discord.VoiceState "discord.VoiceState").
The following, but not limited to, examples illustrate when this event is called...
I am intrigued what the IP is for though @slate swan ? What is it actually doing?
it's in error. so nothing in code
who knows what is it doing in that html code
Try?
@client.command()
async def purge(ctx, amount: int):
await ctx.channel.purge(limit=amount)
await ctx.send(f"**Cleared {amount} messages**")
dpy should make it so that lets you don't have message_contents intent and you try to get the content atleast warns
yea i fking forgot f string 
How can i put permission?
where
To the command?
Me when going to school
💀
!d discord.ext.commands.has_permissiond
No documentation found for the requested symbol.
ahhhhh
💀
hhhhha
@discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.
Note that this check operates on the current channel permissions, not the guild wide permissions.
The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions").
This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingPermissions "discord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
better to use has_guild_permissions though
Wdym?
lmao
Tnx!
Imagine someone is hidden mod
yea lol
Bon
Nvm
No time for simping

Hey how can i make bot say the amount of deleted messages
Hello I am trying to add slash commands and the old regular message commands into 1 file but I cannot do it. When I setup the regular client stuff to use only slash commands but include @client.command() it gives me object has no attribute command How can I set up my bot to be able to use both regular message commands and slash commands?
Guys i want that when someone use the comamnd /image it extracts the text from image
How can I do that?
de = await channel.purge(...)
await ctx.send(f"Deleted {len(de)} messages")```
class aclient(discord.Client):
def __init__(self):
intents = discord.Intents.default()
intents.message_content = True
super().__init__(command_prefix="!",intents=intents,help_command=None)
self.tree = app_commands.CommandTree(self)
self.synced = False
async def setup_hook(self):
self.tree.copy_global_to(guild=discord.Object(id))
await self.tree.sync(guild=discord.Object(id))
self.synced = True
print(f"Synced Slash commands for {self.user}")
async def on_ready(self):
print(f"Logged in as {self.user}")
client = aclient()
@client.tree.command(name="join")
async def my_command2(interaction: discord.Interaction):
await interaction.response.send_modal(Join(),ephemeral=True)
@client.command()
async def ping(ctx):
ctx.channel.send("pong")```
I'm getting error object has no attribute command. How can I get my bot to use both slash commands and regular message commands?
check the second pinned message in this channel, scroll down and you'll see a Hybrid Commands topic
both?
As in for example the ping command it would appear as slash command and a regular message command
it's just message and slash commands but under one function
I just want to be specifically slash or message command
hm alright, use commands.Bot then
What do you mean how would I put that in my code above?
hi how can i remove an dropdown from the view with remove_item?
That then gives me error This client already has an associated command tree, does that mean I have to pick between all regular commands, or all slash commands?
also i have a same dropdown im just passing new param like remove it first and replace with new one . Any better possible way out there?
ded chat 😔
i guess that's not supposed to be in only 1 commit
what's the problem?
!d discord.ui.View.remove_item
remove_item(item)```
Removes an item from the view.
This function returns the class instance to allow for fluent-style chaining.
i literally posted
ik but what to put in item
also is there any better way
.
probably no
oh lol sorry my bad
i haven't coded in a while i forgot everything 😂
thanks :D
@bot.command(
name="ping",
)
async def poo(ctx, channel: discord.TextChannel, message):
await channel.send(message)```
currently, if two channels have the same name it will just choose the highest one and send it to that one. How do I change it so that it will ping all the channels that have that name
wdym?
your code isn't pinging any channels so
no it sends a message into a channel
right
but if there is two channel with same name
it only sends into one, but i want to send into all
so you want the channel parameter to collect all channels with that name
yes
then in the command callback, you can iterate over ctx.guild.text_channels, and if the textchannel name == channel argument name, send message to it
oh right good idea
@bot.command(
name="ping",
)
async def poo(ctx, channel: discord.TextChannel, message):
if channel.name in ctx.guild.text_channels:
await channel.send(message)```
if this is what u meant it does not work
Can i use return to print de?
that if statement makes no sense
That's not what I meant
I meant, use a for loop
Ok
@bot.command(
name="ping",
)
async def poo(ctx, given_channel: discord.TextChannel, message):
print(given_channel.name)
for channel in ctx.guild.text_channels:
if channel == given_channel.name:
await given_channel.send(message)```
is this what u meant??
yesnt
you should be using channel.send instead of given_channel.send else it will keep sending the message in same channel multiple times
I wonder why the variable work even its not printed
Is it because of await thing?
await has nothing to do with printing...
you should learn async/await before trying to use these async libraries
print is not a coroutine, there's no need to do it
how do i log when a user comes to my server in a specific channel?
!d discord.on_member_join
discord.on_member_join(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") joins a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
listen for ^ event
i sweae half my messages are getting deleted by autocorrect
rip
nice, that's absolutely what i wanted to see
Damn cool!
And The Award For The Best Error Goes To..... Master32!