#discord-bots
1 messages · Page 581 of 1
it should work if the user is in a guild with u
?
here
no not the guild part
whatchu talking about
let me get code
even when no one react
do if payload.user != client.user
i think it is reacting to itelf
you did the exact opposite
error
what
replace == with !=
i did
same i get error
this
use payload.member
?
does anyone have any emotes for desktop status'? like the ones in this screenshot
im trying to have desktop emotes that actually display a colored desktop, similar to the mobile emotes
how put buttons and menu then ?
? help
10-4
we still dunno what you're talking about
actully it doesn't mater just the pring is bellow the prevous task
and in your task @echo wasp
put
client.wait_until_ready at the top
!d discord.Client.wait_until_ready
await wait_until_ready()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits until the client’s internal cache is all ready.
That's what I'm talking about
https://docs.mongodb.com/drivers/motor/
10-4
what's the question
what does that mean
@steady flume do you know?
what?
no
look it up
how put buttons and menu then?
look it up
also still same error after adding both
like do I need to use it or not
it's ur choice
stop saying 10-4 and just say "okay" so everyone understands
Should I use json to store data or should I learn databases?
ok
depends what you are storing in your db
I mean, for example, names, ids, images, and some scores
how often are you reading/writing to this?
just so you know the same error is still there
@bot.command()
@commands.is_owner()
async def nick(ctx, member: discord.Member, nick):
await member.edit(nick=nick)```
hello this cmd is not working
not changing the nickname
I wonder why
because with json files, everytime you write you have to read and write the whole new file again
can u help me?
I wonder why it doesn't idk anything about that kind of stuff i haven't experimented with profile edits
how to make a xp system for the users who AFK in voice
What would be an easy way to welcome people back to the Discord if they already joined before? And what's also an easy way to only say "Welcome to the server" once. So they can't rejoin the Discord Server and spam it with welcome messages.
then it's maybe a wrong id
Or like once / username
database
lol that is my id lol
user.send send had not object
user is NoneType
your get_user didn't find the user
send the code now, how did you replace everything?
let me recopy and paste
my id
Depending on the command
Say for example, a register team command
okay so a couple times, then db is more useful because it scales so muc h better
Alright, I'll learn that then
copy paste your code that u have now
For on_member_join event is there a way to only run it once/user? So when rejoining the server it would only do it on their first join. I don't wanna welcome them more than once. Or can I put a cooldown on it so it won't welcome back to back?
store their id
ok here
not really since discriminator and username can be changed so people could outsmart the system
# bot.py
import discord
import asyncio
import os
from discord.ext import commands
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
GUILD = os.getenv('DISCORD_GUILD')
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix='&', intents=intents, case_insensitive=True)
async def my_background_task():
await client.wait_until_ready()
user = client.get_user(786788350160797706)
await user.send("Test")
await asyncio.sleep(1)
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
client.loop.create_task(my_background_task())
client.run(TOKEN)```
idk how to do databases
its not very hard, there are very good tutorials on youtube for something simple like this
Link?
u didn't even use it correctly
Could I just make a json and add them into the json?
what do you mean
!d discord.Client.wait_until_ready
await wait_until_ready()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits until the client’s internal cache is all ready.
and what is this
bot = client
a define
for what
i also use that in my other bot
bruh
.
you fixed it but it only went once
that is what the line on the bottem is for and it worked fine for in channels
it is supposted to repeat
Is their an first join attribute?
@slate swan can you help me with that issue now it only runs once not multiple times
so how do i rewrite it? that doesn't make a lot of sense #discord-bots message
how put buttons and menu then ?
I think this might help idk i didn't watch it is just a title i saw https://www.youtube.com/watch?v=-85tDSlfb3w
github: https://github.com/elixss
You NEED discord-components:
pypi: https://pypi.org/project/discord-components/
also, please join their discord server: https://discord.gg/s52WKb56pk
the music used for the video is: https://youtu.be/xDUsAK3TndI
this file inspired me and might help you, if you dont understand it:
https://gitlab.com/discord.py-...
@slate swan how do i write that in then that doc didn't make much sense
its d-components
but i made 2.0
ok idk how to help
if len(reaction.message.attachments) == 0:
embedVar = discord.Embed(title="** **", color=discord.Colour.gold(), description=str(reaction.message.content))
embedVar.set_author(name=str(reaction.message.author.name), icon_url=reaction.message.author.avatar_url)
embedVar.add_field(name="Original", value=f"[Jump!]({reaction.message.jump_url})", inline=False)
time = reaction.message.created_at
embedVar.set_footer(text=str(time))
await schannel.send("ID: " + str(reaction.message.id), embed=embedVar)
else:
for attachment in message.attachments:
await attachment.save(attachment.filename)
attname = attachment.filename
embedVar = discord.Embed(title="** **", color=discord.Colour.gold(), description=str(reaction.message.content))
embedVar.set_author(name=str(reaction.message.author.name), icon_url=reaction.message.author.avatar_url)
embedVar.add_field(name="Original", value=f"[Jump!]({reaction.message.jump_url})", inline=False)
time = reaction.message.created_at
embedVar.set_footer(text=str(time))
file = discord.File(str(attname))
Error in the last line:
Variable attname referenced before assignment
I know what the error is about but I have no idea why it'd throw that. Can anyone help?
i think you apply it to early it is hard to tell with discords ```py
yeah
When the error is raised it means you defined something to early in a function
I defined it at the right time though
If you did you wouldn't get the error
exactly
I think I did
yet I'm still getting the error
but I can't figure out where I'm wrong
Try putting it lower
I can't lol
Why so
It will say its not defined?
it's already lower enough. I mean it gets defined before it gets used. as you can see, it gets defined above the last line. and the last line is the only line that uses the variable
Hi, I can't make a command that makes all channels be blocked (disable messages)
@bot.command(name = "raid-on")
async def raidon_(ctx):
await ctx.message.delete()
for channel in ctx.guild.channels:
try:
await ctx.channel.set_permissions(ctx.guild.default_role, send_messages=False)
except Exception as e:
print(e)
help please c:
error?
There is no error
It only disables the channel where I made the command
Put the var under the ember var
I'll have to put the whole for loop there
alright then
how to loop something i didn't understand what @slate swan said to do
What do you want to look exactly?
then?
read about loops in python
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
never been there
help please
@slate swan can I just do
file = discord.File(attachment)
?
wondering if an attachment object can be passed to discord.File
use step by step debugging
for example, print "works" after every line
that way you can figure out what's causing the error
Idk
You can not construct a File object directly with an attachment object
!d discord.Attachment.to_file
await to_file(*, use_cached=False, spoiler=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Converts the attachment into a [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") suitable for sending via [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send").
New in version 1.3.
what if I do discord.File(url=attachment.url)?
Have you read the docs for File?
No but I saw that example in a stackoverflow post
Yeah its better
thanks!
not what i am trying to do is what you supplied
What do you want to do exactly
@pliant gulch
at_obj referenced before assignment
I want to repeat that part that says background _task but when he fixed it for me it only goes once the way it ws setup for channels that loop that i have in there rn worked now it doesn'
t
for attachment in message.attachments:
at_obj = attachment
break
embedVar = discord.Embed(title="** **", color=discord.Colour.gold(), description=str(reaction.message.content))
embedVar.set_author(name=str(reaction.message.author.name), icon_url=reaction.message.author.avatar_url)
embedVar.add_field(name="Original", value=f"[Jump!]({reaction.message.jump_url})", inline=False)
time = reaction.message.created_at
embedVar.set_footer(text=str(time))
file = discord.File(at_obj.to_file)
last line
you define at_obj in the for loop
learn about scoping
it's basic python
I do not know what you mean
aren't scopes only for functions and classes
and there's a global scope
define at_obj before the for loop
in the function
as None maybe
curious - what do scopes have to do with loops?
look at my code i want it to send a message every second and it only goes once how do i set it up to loop constant
scoping has everything to do with every statement you're using
You want it to loop a message?
at_obj = None
for attachment in message.attachments:
at_obj = attachment
break
embedVar = discord.Embed(title="** **", color=discord.Colour.gold(), description=str(reaction.message.content))
embedVar.set_author(name=str(reaction.message.author.name), icon_url=reaction.message.author.avatar_url)
embedVar.add_field(name="Original", value=f"[Jump!]({reaction.message.jump_url})", inline=False)
time = reaction.message.created_at
embedVar.set_footer(text=str(time))
file = discord.File(at_obj.to_file)
but loops are supposed to be in the same scope as the surrounding code, no?
yes
just... try it
if it doesn't work I'm dumb
and I vanish
if not, how does this code work
count = 0
for i in range(10):
count += 1
print(count)
ok
because you define count before the for loop
that's exactly what I'm telling you to do here
So you dont know how to do a loop?
I can't find it 😦
but it is able to change count's value
in the loop
that means it is in the same scope as the outer code
not in the way i have it in rn
but if you define it in the for loop, you can't use it outside of it
unless you've defined it there before
find what?
Show?
The error
what line does the code stop at?
that's not true
hmm, interesting stuff
never had to go through that
only if you define it before the for loop
that's how it is
The code does not stop, it blocks the permission of the channel where I make the command but I want the bot to block all permissions of all channels
check this out
it's not like that
it doesn't work @slate swan
!e
for i in range(10):
count = 1
print(count)
same error
@slate swan :white_check_mark: Your eval job has completed with return code 0.
1
bro what
then I'm the problem
what if
nah
YES
what if message.attachments doesn't contain anything
the code knows that you wanted to assign it a value but it can't go in the for loop
since there's nothing to iterate through
I used an if to check that lol
bruh
The code does not stop, it blocks the permission of the channel where I make the command but I want the bot to block all permissions of all channels
full code @slate swan
if reaction.emoji == "⭐" or reaction.emoji == "💀":
if count_reacts(reaction.message) == breaker or count_reacts(reaction.message) > breaker:
messages = await schannel.history(limit=None).flatten()
for message in messages:
if str(reaction.message.id) in message.content:
return
if len(reaction.message.attachments) == 0:
embedVar = discord.Embed(title="** **", color=discord.Colour.gold(), description=str(reaction.message.content))
embedVar.set_author(name=str(reaction.message.author.name), icon_url=reaction.message.author.avatar_url)
embedVar.add_field(name="Original", value=f"[Jump!]({reaction.message.jump_url})", inline=False)
time = reaction.message.created_at
embedVar.set_footer(text=str(time))
await schannel.send("ID: " + str(reaction.message.id), embed=embedVar)
else:
at_obj = None
for attachment in message.attachments:
at_obj = attachment
break
embedVar = discord.Embed(title="** **", color=discord.Colour.gold(), description=str(reaction.message.content))
embedVar.set_author(name=str(reaction.message.author.name), icon_url=reaction.message.author.avatar_url)
embedVar.add_field(name="Original", value=f"[Jump!]({reaction.message.jump_url})", inline=False)
time = reaction.message.created_at
embedVar.set_footer(text=str(time))
file = discord.File(at_obj.to_file)
you sure you have intents enabled and you're not using a userbot?
message is defined there?
I'm sure
for attachment in message.attachments:
🗿
No
feelsbadman.jpg
thank you for sending the whole code
so I also learned something today
why didn't it say "message is not defined"

¯_(ツ)_/¯
but atleast the new code shouldn't have thrown the same error
it just shouldn't have worked because at_obj was None
@slate swan
guys, how do I check, in how many servers my bot is
!d discord.Client.guilds
property guilds: List[discord.guild.Guild]```
The guilds that the connected client is a member of.
thenx
check the amount with len()
print(guild)
?
one minute
I found it thanx
what i need put instead values??
what do you event what to send
how do you create a loop with my setup so it sends a message more than once
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
it's a decorator which you can use on your task
so how would i set it up with my setup i didn't really understand it
you can start this later with task_instance.start()
@tasks.loop(seconds=5)
async def my_background_task():
await client.wait_until_ready()
user = client.get_user(786788350160797706)
await user.send("Test")
then you use
my_background_task.start() somewhere
maybe in on_ready
ok
@slate swan i did what you said just having trouble with the start on ready i got the top done just how do i do the bottem?
can you show me example
lemme get ur previous code
import discord
import asyncio
import os
from discord.ext import commands
from dotenv import load_dotenv
from discord.ext import tasks
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
GUILD = os.getenv('DISCORD_GUILD')
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix='&', intents=intents, case_insensitive=True)
@tasks.loop(seconds=5)
async def my_background_task():
await client.wait_until_ready()
user = client.get_user(786788350160797706)
await user.send("Test")
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
my_background_task.start()
client.loop.create_task(my_background_task())
client.run(TOKEN)```
I think
I also hope, since I haven't worked with tasks yet
but I got some idea
wait
now it doesn't even work
is there an error?
nopde
damn lemme research it then
from discord.ext import tasks
@tasks.loop(seconds=5.0, count=5)
async def slow_count():
print(slow_count.current_loop)
slow_count.start()
this is from the docs
in a cog, they start it in __init__
wait count
but in the main file...
i'm a dummy
{discord.utils.format_dt(member.created_at, style = 'R')}```
`discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.utils' has no attribute 'format_dt'`
the count doesn't matter
it's optional
others say the start doesn't have to be in on_ready
import discord
import asyncio
import os
from discord.ext import commands
from dotenv import load_dotenv
from discord.ext import tasks
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
GUILD = os.getenv('DISCORD_GUILD')
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix='&', intents=intents, case_insensitive=True)
@tasks.loop(seconds=5)
async def my_background_task():
await client.wait_until_ready()
user = client.get_user(786788350160797706)
await user.send("Test")
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
my_background_task.start()
client.run(TOKEN)
just like this
lesgo
well yes
that's API spamming
Hi ! I found a really cool bot online that i would like to tweak and use on my server. The only issue is that..the code looks like this and i'm 60% sure that it contains a token grabber or some kind of backdoor. How can i see the code ?
Lmao what the hell
This is encrypted, not the best encryption but we're not allowed to help decrypt it for you.
Don't they call it rate limit or something?
Api abuse*
Rate limit is in discord when you try to do a action to many times it limits you while api abuse is when you call the api to much
can discord do anything about api abuse?
I think they just limit your api key idk
how can i get nsfw gifs without reddit?
one can easily get a new one
webscraping
@commands.command()
@commands.has_permissions(ban_members=True)
async def ban(self, ctx, member: discord.Member,*,reason):
await member.ban(reason=reason)
embed = discord.Embed(title=f"{member} a été bannis || `{reason}` ✅", colour=discord.Colour.green())
await ctx.send(embed=embed)
en = discord.Embed(description=f"vous avez été bannis du serveur `{ctx.guild.name}` || `{reason}`", colour=discord.Colour.red())
await member.send(embed=en)
Wdym get a new one
but like do you know any api?
beautifulsoup, google, requests
using reddit is easier
The bot does not want to send a message to the person who will be banned
Command raised an exception: Forbidden: 403 Forbidden (error code: 50007): Cannot send messages to this user
I mean yes you could but they will just limit it idk never has happened to me
since they're no longer in the server, the bot can't send a message to them
Thats what the reddit api does it limits your api key for like a day
send a message to them before banning them
Oh ok
i have a very good bot coded all by myself, but i neet to "borrow" some events from this one :)
guess i'll decrypt it myself
Did you downloaded it or sm?
what ? the code encrypted with pyarmor ?
Yes i know but how did you get the code?
From where?
i think it was a replit..i don't remember, i downloaded it a few weeks ago
u sure u got the emoji id and not the message id ?
😭
Just add the emoji as a str
doesn't work for custom emojis
rate limit u
if u keep doing it, ban your bot
Oh yeah its a custom
I mean your application
how do big bots like carl bot get by then? they must be dealing with a ton of requests at a time
Well in the api reference it says the errors and why so just look for it
but you can easily just copy your code to another bot so it's not worth much
Big bots get a bigger ratelimit
Makes sense
Cooldowns also exists
And whatever wrapper they use should be handling bucket depletion and global ratelimiting
What if a whole server spams commands on a bot does the bot not respond to that guild?
how does discord decide what counts as a big bot and what doesn't?
someone has the list of the guild regions?
E.g POST MESSAGE ratelimit is 5/5s
You open a ticket on the support website
Ah i see
Yeah ik
Give me a sec
ok
"For questions and discussions relating to Discord bot development with discord.py and other relevant Python libraries."
a?
mmhm
its a question to make the bot put emojis instead of europe
i need to know the regions to put emojis for them xd
it failed to react did you put the right id?
hm
how do you even get the regions
ctx.guild.region
!d discord.Guild.region
The region the guild belongs on. There is a chance that the region will be a str if the value is not recognised by the enumerator.
in my case returns europe
thanks
this has all of them
so what do
:D
check if you have the right id
yea i have good
have you checked again?
Anybody has some ideas for some bot features?
i need help, i try running my bot and it says settings.json doesn't exist. But it's literally right there.
that's not even your code
Have you considered saving the file. What the interpreter sees is not what is shown on line 11.
also what you told us is not what the error even says…
the other detective, I'm not the only one
To many detectives 
Forgot*

.*
do I change the
with open("settings.json") as file: settings = json.load(file)
to the folder the code is in?
audit log, developer commands, starboard, moderation, developer audit log
chess with buttons
My bot isnt about moderation🤷♂️
I dont know how to play chest😭
wtf
then
4 players 3D chess
with discord_components's buttons
learn
the py chess library seems pretty good
@discord.ui.select(placeholder=None, custom_id='3', min_values=1, max_values=1, options=menus, row=1)
async def menu_page(self, menu: discord.ui.Select, interaction: discord.Interaction):
if menu == "Moderation":
await interaction.response.edit_message(embed=self.embeds2[self.embed_count], view=self)
why bot doesnt change anything ? (if so i made it in discord.ui.View)
imma show all code
class Pages(discord.ui.View):
menus = [
discord.SelectOption(label="Currency", default=True),
discord.SelectOption(label="Moderation")
]
def __init__(self, author: int, embeds: list, embeds2: list):
self.author = author
super().__init__(timeout=15)
self.embeds = embeds
self.embeds2 = embeds2
self.author = author
self.embed_count = 0
self.response = None
async def on_timeout(self):
for child in self.children:
child.disabled = True
child.style = discord.ButtonStyle.grey
self.children[0].emoji = ":dl_arrow:"
self.children[1].emoji = ":dr_arrow:"
await self.response.edit(view=self)
async def interaction_check(self, interaction: discord.Interaction):
if self.author == interaction.user.id:
return True
else:
await interaction.response.send_message(f"This menu is not for you", ephemeral=True)
@discord.ui.button(label=None,
custom_id='1',
style=discord.ButtonStyle.red, disabled=True, emoji=":l_arrow:", row=2)
async def back_page(self, button: discord.ui.Button, interaction: discord.Interaction):
if self.embed_count > 0:
self.embed_count -= 1
self.children[1].disabled = False
if self.embed_count == 0:
button.disabled = True
await interaction.response.edit_message(embed=self.embeds[self.embed_count], view=self)
@discord.ui.button(label=None,
custom_id='2',
style=discord.ButtonStyle.red, disabled=False, emoji=":r_arrow:", row=2)
async def last_page(self, button: discord.ui.Button, interaction: discord.Interaction):
if self.embed_count < len(self.embeds) - 1:
self.embed_count += 1
self.children[0].disabled = False
if self.embed_count == len(self.embeds) - 1:
button.disabled = True
await interaction.response.edit_message(embed=self.embeds[self.embed_count], view=self)
@discord.ui.select(placeholder=None, custom_id='3', min_values=1, max_values=1, options=menus, row=1)
async def menu_page(self, menu: discord.ui.Select, interaction: discord.Interaction):
if menu == "Moderation":
await interaction.response.edit_message(embed=self.embeds2[self.embed_count], view=self)
🇬🇪
What is a good plant ID Api
in pycord do i call discord.VoiceClient.cleanup inside a discord.VoiceClient.disconnect?
delete the part where it checks if its the ctx user
user.id == ctx.author.id this ig
then idk sorry
embed = discord.Embed(title = "Currently Playing", colour = discord.Colour.blue())
embed.add_field(name = "Song", value = title, inline = False)
embed.add_field(name = "Length", value = str(datetime.timedelta(seconds = length)), inline = False)
embed.add_field(name = "Link", value = url, inline = False)
msg = await ctx.send(embed=embed)
await msg.add_reaction("\u23F8")
await msg.add_reaction("\u25B6")
await msg.add_reaction("\u23F9")
while True:
try:
reaction, user = await client.wait_for("reaction_add", check=lambda reaction, user: reaction.emoji in ["\u23F8", "\u25B6", "\u23F9"], timeout = length)
except asyncio.TimeoutError:
return await msg.clear_reactions()
async def process():
if reaction.emoji == "\u23F8":
await msg.remove_reaction(reaction.emoji, ctx.author)
ctx.voice_client.pause()
elif reaction.emoji == "\u25B6":
await msg.remove_reaction(reaction.emoji, ctx.author)
ctx.voice_client.resume()
elif reaction.emoji == "\u23F9":
await msg.remove_reaction(reaction.emoji, ctx.author)
ctx.voice_client.stop()
asyncio.create_task(process())
This is a message that is sent after a song is played, the message has reactions that pause, play or stop, every time one is reacted to the bot automatically deletes the reaction so that the reactions can be used more than once by the same user. The only problem is that the person that invokes the command is the only one who will get his reactions deleted, if anyone else reacts the bot responds by pausing, playing, or stopping, but their reaction will not be deleted and therefore they can only pause, play, or stop once. For the line containing await msg.remove_reaction(reaction.emoji, ctx.author) it requires a member argument but I do not know what to replace the argument with.
Replace it with the user who reacted
tried to use the already defined user variable but seemed to have no effect, is there any other way I can obtain the user?
how to get image url of a sent message by the bot?
@bot.command()
async def clear_messages(ctx):
await ctx.message.delete()
for channel in ctx.guild.channels:
if channel.type == discord.ChannelType.text:
await channel.purge(limit=None)
print(f"{channel} history cleared")
await ctx.send("**Done**")
class discord.TextChannel```
Represents a Discord guild text channel.
x == y Checks if two channels are equal.
x != y Checks if two channels are not equal.
hash(x) Returns the channel’s hash.
str(x) Returns the channel’s name.
guys, how i add cooldown on sending a command to the bot's private message?
in "error"
anyway for get the creator name of a channel?
how would i make it so it shows the result of the time? so like if said user did *timer 5 and it ends in 5 seconds how would i make it like this your countdown has ended (lasted #s)?
@commands.command()
async def timer(self, ctx, seconds):
try:
secondint = int(seconds)
if secondint > 300:
await ctx.send("i dont think i can go over 5 minutes")
raise BaseException
if secondint <= 0:
await ctx.send("i dont think i can do negatives")
raise BaseException
message = await ctx.send(f"⏱️ Timer: {seconds}")
while True:
secondint -= 1
if secondint == 0:
await message.edit(content="⏱️ Timer ended")
break
await message.edit(content=f"⏱️ Timer: {secondint}")
await asyncio.sleep(1)
await ctx.reply(f"your countdown has ended!")
except ValueError:
await ctx.send("you must enter a number")
hey
anyone know how i could make a command that sets values to an embed using flags and sends it?
what do you mean by using flags?
show your command_prefix/get_prefix
clearly this error is triggering when you return nothing
why dont you just return '!'
i can assure you, the error will go away
jeez mate
you see how there are 2 return's that are not returning anything
you have 3 returns, 1 return's prefix, and the other 2 return None; hence where the error is coming from
can i send a message to a specific channel? i tried searching google or youtube to try to find the answer but the videos are out of date
channel = bot.get_channel(id) await channel.send('Hello!')
yes
id like this: (id=27264376234) or like (982475284895)
yep
help.start()
AttributeError: type object 'MyHelp' has no attribute 'start'```
code
```py
@client.command()
async def helpmenu(ctx):
help = MyHelp()
help.start()```
a) you said help = MyHelp not Help which is in the error
b) help is a built-in python function
c) what is MyHelp
myhelp is "<main.MyHelp object at 0x7f84283431f0>" - a help object
i changed the variable name and same error
thanku
discord.Client does not have commands, only commands.Bot and its auto sharded counter part
Also pass_context is deprecated
@client.command(aliases=['staff-application'])
async def apply(ctx):
a_list = []
submit_channel = client.get_channel(906141169271062578)
channel = await ctx.author.create_dm()
def check(m):
return m.content is not None and m.channel == channel
for question in q_list:
sleep(.5)
await channel.send(question)
msg = await client.wait_for('message', check=check)
a_list.append(msg.content)
submit_wait = True
while submit_wait:
await channel.send('End of questions - "submit" to finish')
msg = await client.wait_for('message', check=check)
if "submit" in msg.content.lower():
submit_wait = False
answers = "\n".join(f'{a}. {b}' for a, b in enumerate(a_list, 1))
submit_msg = f'Application from {msg.author} \nThe answers are:\n{answers}'
await submit_channel.send(submit_msg)
Hi anyone know how to make a submit button to make it submit an staff application for then review in a particular channel?
everything works except the last line
any idea why?
Hello. I am having trouble using the discord-py-slash-command library module. I installed it with the command shown on the PyPi website. The error message said that slash isn't defined. Why is this?
You need to pass it through ur async def
^
using discord.py v2, how can i see if a user has nitro or not? im open to methods such as testing for animated pfps, or custom banners
#help-orange Someone plz
!d discord.member.premium
nvm i am incorrect let me look
the best i have is !d discord.Member.premium_since
ive already got that lmao
Then if it is None, then the user does not have nitro
a = member.premium_since
if a is None:
return nitro = False
else:
return nitro = True
``` maybe something like thast
!d discord.Member.premium_since
An aware datetime object that specifies the date and time in UTC when the member used their “Nitro boost” on the guild, if available. This could be None.
There is no direct way to check if a user has nitro
You could try gif pfps etc but those aren't 100%
As someone could have nitro, and use a regular pfp
yeah
ive gone with the premium_since string but for some odd reason that seems to only work with some users?
¯_(ツ)_/¯
¯_(ツ)_/¯
Then again, someone can have nitro and not have boosted
your help channel will receive assistance once it makes its way to the top of the category
yeah well by the time it reaches the top it will be closed automatically
but will see then
yeah see its closed
Does discord stops giving discord verified bot developer badge?
yes
Whats your question
Yes a while ago
sad
they are right
People started doing disocrd bots with little code so they would get the badge so it was unfair for the real devs
How would you know
it's quite obvious isn't it?
😩
@client.command(aliases=['staff-application'])
async def apply(ctx):
a_list = []
submit_channel = client.get_channel(906141169271062578)
channel = await ctx.author.create_dm()
def check(m):
return m.content is not None and m.channel == channel
for question in q_list:
sleep(.5)
await channel.send(question)
msg = await client.wait_for('message', check=check)
a_list.append(msg.content)
submit_wait = True
while submit_wait:
await channel.send('End of questions - "submit" to finish')
msg = await client.wait_for('message', check=check)
if "submit" in msg.content.lower():
submit_wait = False
answers = "\n".join(f'{a}. {b}' for a, b in enumerate(a_list, 1))
submit_msg = f'Application from {msg.author} \nThe answers are:\n{answers}'
await submit_channel.send(submit_msg)
Hi anyone know how to make a submit button to make it submit an staff application for then review in a particular channel?
description=snipe_message_content[channel.id], color=0x2f3136) KeyError: 862766760741699615 how am i meant to fix this..
Yt of all the discord badges😭
Add py
A view?
Error speaks for itself, the key was not found
yt?
like this
they even mentioned it lol
just make one
i upgraded to discord.py v2, it used to work with v1, not sure what happened
i know how to make the button but how do i make the feature of it
Yeah
Did the channel get deleted?
nope
Wdym by that
what do you mean by feature
👀
How do I get early developer in Discord?
Head on over to your bot's settings page in the Developer Portal. At the top of that page will be a banner with instructions on how to get started. This process is currently available for bots in more than 75 servers, to allow developers to preemptively apply.
is this working
No, thats the verified bot badge.
ok
@boreal ravine
thanks
Yeah you cant get it anymore
like when a member hits/clicks the submit button how do i direct the button to send it to a channel and submit the members answers from the questions
if that make sense
channel wasn't found I guess or the message wasnt found
u know when u apply for a job and u hit a apply button
get the channel > send the message
🧐
and it gets send to a recruitment team
ill see
Save the details somewhere

Whos the real grey discord icon?
u seem to not understand what i want
so ig ill do it by my self
we do
you just don't know how to do it
i mean its pretty easy i can see on the internet but i just wanted to know what the code was called
if that make sense
nvm
aight 👍
yeah but that doesnt go with what i want my bot to do
what do you wanna achieve?
to send the applications answers from the members to a specific channel
Pls explain what you wanna do
I have a problem, my robot isn't working but it has been verified and people have told me that it should work. Is there something where I can check what is wrong. It says that I left the vc but it doesn't leave
Did you do the leave command?
you left the vc but it didnt leave?
it says it leaves but it stays in the vc
hm
yeah it has been broken for a couple of months
isnt a thing?
Don't
he's not gonna learn anything if you spoonfeed to him
kk
Well he can learn it
How
isnt your code copied too though
it had pass_context which people dont even use anymore
yes but it read it before copying it
well it means that it should run ur async def
idk then seems like disconnect isnt an attr
form
what does that mean
nvm
i was following a tutorial to learn it and my code just hit a brick wall
do you know a fix for my code
Not really
kk
Why does this not work??
reacted_users = await new_msg.reactions[0].users().flatten()
reacted_users.pop(reacted_users.index(bot.user))```
This is in cog. works fine when not in cog
Error:-
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.ext.commands.bot' has no attribute 'user'```
what to do?
:incoming_envelope: :ok_hand: applied mute to @formal plaza until <t:1636172392:f> (9 minutes and 59 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).
dont use that to automate your account ,its against discord tos
if you're looking for a library for making a normal bot , just use discord.py ( or its forks) / hikari
🍜 if the question be against rule5 ,sure
why did you want to use discum tho?
How can i create a cache system
ok
@client.command('Add')
@commands.has_permissions(administrator=True)
async def Add(ctx, user : discord.Member, *, role : discord.Role):
if role.position > ctx.author.top_role.position:
return await ctx.send('**:x: | That role is above your top role!**')
if role in user.roles:
await user.remove_roles(role)
await ctx.send(f"Removed {role} from {user.mention}")
else:
await user.add_roles(role)
await ctx.send(f"Added {role} to {user.mention}")
So i have this code and it's followed by this error which i don't understand because i have the admin perms to do so
Like.. It's saying i don't have the role perms to run that command right? Or am i just straight up stupid?
Yeah ok i'm just fucking stupid.
The Bot role it's self had to be high into the list
bot doesn't have enough permissions (role hierarchy)
Yeah i noticed
how do i make every user's a different database in replit
ive been watching tutorial but none of them show this
i want to make many embeds iterating over a simple list , can i create a function for this?
curchannel isn't defined.Make sure to use the correct syntax.
curchannel is a global variable
defined in line 4
why did i get this?
!botvar use bot variables, not globals
Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:
bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"
@bot.command()
async def get(ctx: commands.Context):
"""A command to get the current value of `test`."""
# Send what the test attribute is currently set to
await ctx.send(ctx.bot.test)
@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
"""A command to set a new value of `test`."""
# Here we change the attribute to what was specified in new_text
bot.test = new_text
This all applies to cogs as well! You can set attributes to self as you wish.
Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!
so i need to change the whole program now?
sort of
can u help?
Sure
right click -> refactor -> rename
That ain't PyCharm afaik
i am new to this but i'll give it a try
oh I thought it works in vsc too
its Spyder
Also u didn't await embed_gen
Nope
can i invite you to my github project maybe we can work on this together ?
Vsc doesn't provide mass renaming?
It does
then
Change all Occurrences but there's a problem
Suppose there's a word, awesome and we just wanna change it to good
And if there's awesomeness, then it would change that to goodness
:potatopopcorn:
including strings?
Wym
It would literally change the word even if it's a substring
lol
so what things i have to change in my current code?
Icy gonna guide u since I got some urgent work to do, sorry 😤
this one
mhm
what else i need to change?
none
Do u have intents?
no?
U need reactions intent
Dude
😐
!d discord.Intents.reactions
Whether guild and direct message reaction related events are enabled.
This is a shortcut to set or get both guild_reactions and dm_reactions.
This corresponds to the following events...
There
thanks i'll try
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 the Members and Presences intents, which are needed for events such as on_member 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.
Just instead of members, u need reactions
let me read this very slowly
intents = discord.Intents.reactions should work
i dont have one?
U have
how does it look like
Ah yes that
should i change it to bot?
Add this
Nah
below this?
Nononono
are you sure you gonna disable guild intents and other useful intents?
😔
discord.Client(intents=discord.Intents.default())
He doesn't have any intents, soo
Edited it ^^^
defaulted to Intents.default()
Done it 🤦
cool
done 😃
Don't bully me 
just telling
what's next?
now i have intents enabled ?
in the dev portal also
i have to enable intents?
Yes
No?
ok
?
He just did default, no need to enable in dev portal
He didn't enable members and presence intent
oh

the last func still not work
dont bully
no error log either
Intents.reactions = True
Me who always gets bullied: 😬😐
default enables it...
!d discord.Intents.default
classmethod default()```
A factory method that creates a [`Intents`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents "discord.Intents") with everything enabled except [`presences`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.presences "discord.Intents.presences") and [`members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members").
did i do something wrong in the last func?
Try adding a print statement at the very first of the function and see if it's printing it. If it is printing it, that means the function is being triggered
who knows
you yea
in if blocks?
Nope
or outside
Outside it
Mhm
triggered 3 times
But at least the function is getting triggered
true
why didn't it created a new channel tho
....
Ahhh I understand
as far as i understand i used to statement so it only triggers when a specific emoji reaction is added
aka red circle emoji
id_red should be undefined tho
First send a message hey bot
Globals 😐
works
?
🙂
oh no
?
i have to set id_red as global?
It is global
Globals can work inside functions even if the function is inside a function which is again inside another function which is again inside another function and so on 🤣
so what is the error here
https://cdn.discordapp.com/emojis/859796078643904523.png?size=48
why did it not create a new channel
First send a message hey bot
After that reaction
!e
a = 1
def b():
global a
a = 3
def c():
global a
a = 2
return c
b()()
print(a)
@visual island :white_check_mark: Your eval job has completed with return code 0.
2
hmm
Lol
my eval is bad then
Why tho
it prints 1
Lmao
try eval it in your bot
Doing that only haha
I don't even know the problem
so i realized the last on raw react func gets triggered to itself reactions
show code
so it triggers when your bot reacts?
yessir
and when i react
can you try printing payload.member?
maybe it is triggering coz it is outside the if loop?
so i realized the second if loop isn't getting triggered
im not sure why my bot is getting HTTP ratelimited
is there a common reason?
also does the ratelimit only affect that one bot or all of my bots? would regenerating the bots token/creating a new one resolve the issue
first one triggers
Rarelimiting is per bot
You are making API Calls way too much
You are using a shared IP (replit?)
Regenerating bot token won't do anything
try using proxies
nope, using a vps not replit
api calls in what sense tho
who knows what the error is 'AttributeError: module 'pymongo.collection' has no attribute 'count_documents'
Everything that u await
Like await send
await edit
await fetch
oh
U doing that?
help
so they are not equal
how do i fix this?
nvm fixed
anyone have any emotes that are status indicators like these ones but for a desktop instead of mobile?
google it
Can someone actually tell me how tf can this bot get my info even when I don't share any common server
https://whois.mrrobot.app/886120777630486538
Rarelimiting is per bot
it's per IP (only bots not user acc)
making an api request
Discord restriction?
I don't share any mutual servers with the bot
And you get restricted when you try to find details bout someone who doesn't share a mutual server with bot
You don't share one with mine's too but it can
Whattttt
Never knew it was possible
!d discord.Client.fetch_user it is
await fetch_user(user_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") based on their ID. You do not have to share any guilds with the user to get this information, however many operations do require that you do.
Note
This method is an API call. If you have [`discord.Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_user()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.get_user "discord.Client.get_user") instead.
I was always restricted when I tried doing that
read the description :p
or use discords api and fetch it directly from there
get_user and fetch_user are different
simple really
Tysm sir
Np
I don't wanna read lots of docs 😩
What docs
API docs
Well thanks
For what
ig
Per token*
I meant that since he asked if every bot will be banned or only one
per IP
lol there is so much anyone can see about you just with yr username
like, if it isn't per IP, how do you get banned on replit if others that get banned and not you?
idts idt my bot js spamming await stuff
is this correct way ?
i want to create a new channel and send a message in it
so now i can do
new_channel.send
```?
yes if curchannel is a discord.Message object
hm
works , thanks!!
my mean to code the bot
in a python file
an IDE
idle?
an IDE
Wat the hell is IDE?
An integrated development environment (IDE) is software for building applications that combines common developer tools into a single graphical user interface (GUI).
so give me link
you don't have an IDE?
Depends
on?
i just want make bot
discord bot
this?
yes something like that
https://www.stxnext.com/blog/best-python-ides-code-editors/
check and tell
check
LOL
oh nice
How do i get category object by id?
didn't see get_category() nor fetch_category() from docs
!d discord.Client.get_channel returns category channel type too


