#discord-bots
1 messages · Page 1012 of 1
you need to add that button to your selectiview first
view = SelectView()
view.add_item(Button(...))
await ctx.respond(embed=embed, view=view)
ah okay, sorry i have just begun last month with python ^^,
but my discord.py version is 1.7.3
message.send() has a delete_after Kwarg
I don't see why you would use io or time at all
channel
but yeah this
and time would be really bad for your bot
I coded one 🙂
Its simple doe
Yea
U just need a database
(json is not a db)
link_button = discord.ui.Button(label="link", style = discord.ButtonStyle.URL, url = "https://google.com/")
view.add_item(link_button)``` something like this
I made one like that
Same tbh
But I did this instead for the url
discord.ButtonStyle.URL, url = f"https://google.com/{query}"
No
SelectView.add_item(button)?
Do you know Python?
Call the subclass (SelectView) and add_item
Yes and no
view = SelectView()
link_button = discord.ui.Button(label="link", style = discord.ButtonStyle.URL, url = "https://google.com/")
view.add_item(link_button)
#ur embed codes
await ctx.send(embed = embed, view = view``` here is an example
@slate swan what module is needed for this pycord ?
no i meant to say "what u mean"
Never used pycord so idk tbh
I don't understand English abbreviations
I just want to make buttons in the bot
Oh i think pycord supports that too
from discord_components import DiscordComponents, Button, ButtonStyle shit doesn't work
so I decided to use picard, but apparently it's even worse than the first one
ohh
Lemme give u an example```py
await ctx.send("ur message", component = [Button(label = "o", style = ButtonStyle.green)])
@slate swan how do you use this damn pycard which module is responsible for it??
from ... import Button, View
from ... import Button, View
what do I need to enter instead of an ellipsis ?
@slate swanhow to make buttons is clear, but which module needs to be spoiled is not
what kind of lib ?
Yes. In slash commands
I just need to write from ... import Button, View for the buttons, but I do not know what to enter instead of an ellipsis in the video bullshit is shown. I installed the module and the bot says I didn't install it
any problem?
@slate swan yes
@slate swan from ... import Button, View
what do I need to enter instead of an ellipsis ?
idk depends on what library you're using
Idk if pycord do support buttons so
it does
they changed nothing in terms of buttons, as it was a direct fork from discord.py v2 which ws under development at that moment
By standard it is library.ui
!d discord.Button
class discord.Button```
Represents a button from the Discord Bot UI Kit.
This inherits from [`Component`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.Component "discord.Component").
Note
The user constructible and usable type to create a button is [`discord.ui.Button`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.ui.Button "discord.ui.Button") not this one.
New in version 2.0.
@brave forge ^^
ui subpackage is for users, this structure is system
for View it is discord.ui.View
u meant pycord*

it is py-cord*
😏
Oh thats WHYY
wot?
Wait lmao lemme tey something
Wait nvm 😭😭😭😭
💀
😂
bro, calm down 💀 😂
Extension 'cogs.osnov' raised an error: ModuleNotFoundError: No module named 'discord.ui'
which version r u using?
Download discord.py v2
wrong version
install from github branch @brave forge
yes
buttons aren't released on pypi yet
i want to be able to see who ran this command
what ?
you can see
well it is version problem
within my bot
if you've installed directly from pypi, then it's versoin 1.7.3
and that version doesn't have buttons & shit @brave forge
if you've slash, it is expected to work in the same way
otherwise, use a footer where u put author's name
or do some shit related to ctx.author on_command event
the slash command is to a different bot
im using a on_message and picking up the embeded response
i then want to see from the reply who sent the command
@slate swan how to view the version discord.py
the embeded message sent into the chanel by the bot
well u better show me your code @uncut comet
i can't help u this way
?
i told u to check the version that you're using
bots cant see each others commands
if i run a slash command to another bot
any other bots wont see it full stop
how to check it!? КАК ЕЁ ПРОВЕРИТЬ ?
thats why im looking at the embed that gets sent in
pip freeze
@slate swanhow to update it ?
tell me your version first
@slate swanversoin 1.7.3
how do i make a bot that counts
example:
1+ 1 = 2
but i want always to add +1 once i say !count
@slate swan deleted
u want to make that count bot.. which is specific to a channel?
@nimble minnow ?
nope, check dms
now install py-cord from their github master branch
my DM isn't a help channel.. send here whatever it is
:")
there is a slowmode here 😭
stop, do I have to rewrite all the code under pycord?! 0_0
ah.
XD
https://paste.pythondiscord.com/godaduvika
It’s not letting me use the amount option
just use replit, no need to install everything
Error?
bro? i told u to install from github branch.. just say that u don't know how to install from github branch & i'll help u
I cannot read your screen.
No error at all
I don't know
pip install git+https://github.com/Pycord-Development/pycord
installed
i have a check and i can pick out this message
but how can i see who sent the command
wdym
Do you know or not?
are u coding a bot or what??! (im dumb)
ok now do pip freeze & check your version again
yes why
do u use on_message or ctx
huh
Not really 🤔
just go in dms
wdym??
It looks fine
discord-components==2.1.2
discord-py-interactions==4.1.0
discord-ui==5.1.6
dislash.py==1.4.9```
why are you dming me?
wtf? why u have so many libs with same namespace?
It doesn’t work tho
which one are u planning to use? @brave forge
i have no idea what u need help with so im not gonna spend 6 seconds to type a new msg here
Only amount doesn’t work
arent you the one who is asking how to do counting in python?
I do mine a bit differently for amount
I’m doing a slash command
the one in which when the bot starts, there will not be this error "Extension " cords.fun" caused an error: ClientException: A cog named "User" has already been loaded"
But for a normal command amount would work
it means there is already a cog with User name
With that code
Yea
yes? im just tryna help u but alr 💀
I’ve asked some people to help but they don’t know.
you asked if i was using on_message or ctx tho...
cuz idk what u asking 😭
instead of User, you need to write Dog ?
With slash commands
pardon?
there is a cog, named "User", so it means, there are two cogs that are trying to load & both of them have "User" name..so just change name of any one of 'em
Slash.
wdym
You use ctx.reply(“[your message]”)
message.author would work i think if its in on_message
https://paste.pythondiscord.com/godaduvika
It’s not letting me use the amount option
sorry what?
im sending a command to a completely different bot (my bot cant see the command sent to that bott)
but i can see the reply from the bot (the embeded)
i want to see who sent the original command from the embeded reply
don't u think message author would return the "bot" instead of the "user of bot"?
yknow that makes complete sense
@slate swan and why after installing pycord. have my commands stopped working ?
Here’s code https://paste.pythondiscord.com/godaduvika
i don't think.. there is any way for OTHER bot to know the command user of other bot.. if im wrong, pls correct me
the thing is.. you've multiple libs in your envv. with same namespace 'discord'.. that's gonna cause conflict uk
sounds like this is true
yeah.. i feel the same way
well i had a bump bot previously which could see and even @ them
ask the question and if someone can help they will
im trying to make my bot do the same hahaha
ok thanks
bro, he pinged those users who were USER OF ITSELF, did it ping user of some OTHER bot?
https://paste.pythondiscord.com/godaduvika
It’s not letting me use the amount option
other bot
screenshot pls :>
and how to fix it ? before installing on that link, everything worked
did u get the message that pycord has been installed?
this is not about bots, i would like to reply as a user to a message from another determined user
anyone can help me start to make a ticket bot
someone can help me ? i dont know what im doing wrong
I do not remember
is it a self bot?
that kinda sounds like a self bot
https://paste.pythondiscord.com/godaduvika
It’s not letting me use the amount option
which is against tos
wow, who is suppose to remember then? :")
what is a self bot ?
stop sending the same thing
what is a self bot ?
Sorry
🤔 hmm that's interesting.. probably it is using on_message event or something like that
idk exactly
yea i got stuck haha
@slate swan how do I delete everything installed ?
hence i am now here
A selfbot is basically a bot inside your own account
eh. idk any way other than ```py
pip uninstall <lib name>
which isn't allowed
yep ^^ +1
oh ok thanks
but it is still possible even if its forbidden ?
ig but no one here will help you afaik
2. Follow the Discord Community Guidelines and Terms Of Service.
:")
ngl i kinda want to try make one
@slate swan thanks for helping. And yes as I understood to make the buttons in discord.py need to do probably not on disocrd.py
uhm.. i didn't get it completely.. but okay.. if u feel like it helped u
https://paste.pythondiscord.com/godaduvika code
It’s not letting me use the amount option
Please help me
:>
looks like you're using discord.py..
and i'm not familiar with its concept of slash.. let's wait till someone comes & help u out :")
it's just that there are already 2 ways how these buttons are made and not one does not work for me ...
it's just a shame somehow
there were libs in your env with same namespace
importing discord anyway would cause a conflict
Ok
:")
I wish slash just have the same code as a normal command
Because that code will work for a normal command
i agree till some point
No error
but i don't want it to happen anymore after migrating to the changes
Yeah but its against tos
You can use this
lmao
@bot.slash_command()
async def test(inter: ApplicationCommandInteraction, amt: int):
await inter.response.send_message(“Hello”)
@formal basin
ok thanks i won't do it no worries
yup. very interesting stuff
I originally didn't care much for it but I wanted to make a sign in with discord option for my bot's web dashboard so that kind of forced me to learn it
found it pretty fun
@client.event
async def on_message(message):
if channel.name == 'announcements':
messageembed = discord.Embed(
description=message,
color=0xffffff)
await channel.send(embed=messageembed)
client.run(token)``` this isn't working for me basically im trying to make it so if any message is sent in a channel, it deletes it and changes it to an embed
says it can't recognise channel
oh ok
channel hasn’t been declared yet
would that above declare it?
no
It’s getting the message that has been parsed as an argument
message.channel.send
Channel still doesn’t exist
oh mb
uh its sending this now
when i send a message
message is a discord.Message object and you want to set that as the description?
message.content
To get the message text
message is a message object
I just wanted to set this prefix to my bot: $
What can I do, if it's writting an error:
client = commands.Bot(command_prefix="$")
TypeError: BotBase.__init__() missing 1 required keyword-only argument: 'intents'
Yeah that happened to me
I just added intents and it fixed it
How to do it ?
where did you add
intents = discord.Intents().all()
client = commands.Bot(command_prefix=',', intents=intents)
Here is an example of how to add intents
k
thanks
Np
!e ```py
import getpass
class check():
@staticmethod
def number(number,number2, returnbool: bool):
"""Checks if number is bigger than number 2. If so, it will return a statement or a boolean depending on if returnbool is set to True or False."""
#hello
if number > number2:
if returnbool == False:
return "{} is bigger than {}!".format(number,number2)
elif returnbool == True:
return True
elif number == number2:
return "Same number."
else:
if returnbool == False:
return "{} is not bigger than {}!".format(number,number2)
else:
return False
@staticmethod
def type(obj):
return type(obj)
@staticmethod
def string(obj):
if type(obj) == str:
return True
else:
return False
@staticmethod
def integer(obj):
if type(obj) == int:
return True
else:
return False
if check.number(2,2**2,returnbool=True) == False:
print('bob')
@slate swan :white_check_mark: Your eval job has completed with return code 0.
bob
#bot-commands
That has nothing to do with this channel
ok
couldnt find it throuhg all these channels
There’s a whole category for it
Hard to miss
pretty easy to miss but alr
I would look harder and not put it in some random ass channel
🤣
ok then lmao
import discord
from discord.ext import commands
import youtube_dl
import os
intents = discord.Intents().all()
client = commands.Bot(command_prefix='!', intents=intents)
@client.command()
async def play(ctx, url: str):
song_there = os.path.isfile("song.mp3")
try:
if song_there:
os.remove("song.mp3")
except PermissionError:
await ctx.send("Wait for the current playing music to end or use the 'stop' command")
return
voiceChannel = discord.utils.get(ctx.guild.voice_channels, name='『:notes:』music voice')
await voiceChannel.connect()
voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
ydl_opts = {
'format': 'bestaudio/best',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([url])
for file in os.listdir("./"):
if file.endswith(".mp3"):
os.rename(file, "song.mp3")
voice.play(discord.FFmpegPCMAudio("song.mp3"))
# noinspection PyArgumentList
@client.command()
async def leave(ctx):
voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
if voice.is_connected():
await voice.disconnect()
else:
await ctx.send("The bot is not connected to a voice channel.")
@client.command()
async def pause(ctx):
voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
if voice.is_playing():
voice.pause()
else:
await ctx.send("Currently no audio is playing.")
@client.command()
async def resume(ctx):
voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
if voice.is_paused():
voice.resume()
else:
await ctx.send("The audio is not paused.")
@client.command()
async def stop(ctx):
voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
voice.stop()
client.run('')
I sent this
@client.event
async def on_message(message):
if message.channel.name == 'announcements':
author = message.author
messageembed = discord.Embed(
description=message.content,
color=0xffffff,
set_author=message.author)
await message.delete()
time.sleep(1)
await message.channel.send(embed=messageembed)
print('changed a message to an embed in announcements')``` this just deletes my message and says `NameError: name 'time' is not defined`
Import time
oh
!!!
!ytdl # For the reason why we don't help, it's not just because they are 'music bots'
im dumb af
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
BRUH IS THAT SERIOUSLY THE PROBLEM LMAO
Your trippin lmao
ok so that was the problem for that but now im getting this
You shouldn't use time.sleep, it blocks your bot from working.
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embed.description: This field is required```
You should use await asyncio.sleep() instead
@client.event
async def on_message(message):
if message.channel.name == 'announcements':
author = message.author
messageembed = discord.Embed(
description=message.content,
color=0xffffff,
set_author=message.author)
await message.delete()
time.sleep(1)
await message.channel.send(embed=messageembed)
print('changed a message to an embed in announcements')
thats the code the embed appears for a sec then disappears
Your embed is fucked up
author =, not set_author=
Make sure what you do ignores messages from bots
That's one reason of your issue
You try to convert embeds to embeds again
Embeds coming from your bot
how would i do that, i could ig check if the message is the bots message
Add a simple check at the top to ignore messages from bots, something like this
if message.author.bot:
return
ah ok lemme try
And as I've said ^
it works thanks so much peeps ❤️
NP <3
one last question how could i get the person who sent the msgs pfp
message.author.avatar.url
I believe
alr lemme see
Returns a pfp url
What was that
import discord, requests, randfacts
client = discord.Client()
@client.event
async def on_ready():
print('Running...'.format(client))
@client.event
async def on_message(message):
request = requests.get(url='https://catfact.ninja/fact?max_length=140')
if message.author.bot:
return
if message.author == client.user:
return
if message.content.startswith('.catfact'):
await message.reply(f"The cat fact is: {request.json()['fact']}")
elif message.content == '.meh':
await message.reply(f".meh")
elif message.content.startswith('.fact'):
await message.reply(f"The random fact is: {randfacts.get_fact()}")
client.run(discord token)
it used to work but for some reason now it does not anymore
Any errors?
getting this error File "C:\Users\harle\Downloads\final\purge.py", line 50, in on_message messageembed.set_author(name=message.author, icon_url=message.author.avatar.url) AttributeError: 'NoneType' object has no attribute 'url'
@client.event
async def on_message(message):
if message.channel.name == 'announcements':
if message.author.bot:
return
author = message.author
messageembed=discord.Embed(description=message.content, color=0xffffff)
messageembed.set_author(name=message.author, icon_url=message.author.avatar.url)
await message.delete()
await asyncio.sleep(0.1)
await message.channel.send(embed=messageembed)
print('changed a message to an embed in announcements')```
nope does not work
Just checking, you're using 2.0 right?
python 2.0?
discord.py 2.0
Read it wrong and you don’t need it anyway
The user who sent the message has a default avatar, you should be checking for this, and replace with Member.default_avatar when that is the case
is there a cmd i can do in command prompt to check
Print discord.__version__
1.7.3
Then it's avatar_url not avatar.url, avatar.url is for 2.0
what do u mean?
i tried to update but it gave me an error so i couldn't
And you should check for default avatars as said above
Your allready checking if it’s a bot, you don’t need to do another check if it’s the bot user
Also try adding print statements in the commands to see if they are actually working
Debugging is a big part of fixing errors
I mean debugging is fixing errors 💀
i get this so i couldn't update do u know why this could be, if not ill go to a diff chanel since this isn't for discord bots
ImportError: cannot import name 'Mapping' from 'collections' (C:\Python310\lib\collections\__init__.py)
Change your code from
from collections import Mapping
to
from collections.abc import Mapping
does not read the msg i think
You sure?
by code do you mean the init.py?
it does not go into the def
No
i made it print something if it goes to the def but it does not
Is the error coming from a library? If so, then you need to downgrade Python
Show your code
Python 3.10 made changes to collections and if a library you're using uses that, then you get an error as they haven't updated it yet
import discord, requests, randfacts
client = discord.Client()
@client.event
async def on_ready():
print('Running...'.format(client))
@client.event
async def on_message(message):
print('a')
request = requests.get(url='https://catfact.ninja/fact?max_length=140')
if message.author.bot:
return
if message.content.startswith('.catfact'):
await message.reply(f"The cat fact is: {request.json()['fact']}")
elif message.content == '.meh':
await message.reply(f".meh")
elif message.content.startswith('.fact'):
await message.reply(f"The random fact is: {randfacts.get_fact()}")
Enable message intents
is there anyway i can just clear all the libraries i have and then manually reinstall them one by one
Reinstalling might not do the trick, they might have not even been updated
wdym?
You can for sure try to update them
!intents
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.
Whether guild and direct message related events are enabled.
This is a shortcut to set or get both guild_messages and dm_messages.
This corresponds to the following events...
And don't make commands with the on_message event, use commands which are implemented - https://discordpy.readthedocs.io/en/stable/ext/commands/commands.html
Yeah honestly don’t know why people do that
Probably following typical tutorials which show exactly what not to do
Lmao
Discordpy tutorial slander
There is no tutorial that actually explains how to make a bot in a decent way, but people are new and they don't know that so they think it's good
but it used to work without it
Everyone I could run this thing, now it can't be (
client = discord.Client()
TypeError: Client.__init__() missing 1 required keyword-only argument: 'intents'
Yeah it used to work
like an hour ago
Enable intents
Don't use Client, use Bot
As the example shows above
Oh, sorry
Client is not made for your plans
Ehh copy past from site is so bad (I did .Bot last time)
Don’t copy and paste
You learn nothing
I know,
I didn't
Only one time
Now I learned it (few hours ago*)
Only copy and paste when you understand the code
That’s the only acceptable way to copy and paste
Even in that case; read the code, understand it to get some inspiration and then make your own solution
Ima watch better call Saul then go to bed, cya guys
👋
better call saul is cool xd
It’s kinda shit the first few seasons
yeah its not working, is there any other way I could input the discord pfp without that
Breaking bad is better
Not really, what is your error right now?
Mf
If you think better call Saul is better than breaking bad your not allowed to watch anything
gud series drive to survive
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
whenever i uninstall discord.py and reinstall it, it installs the 1.7.3 version
and not version 2.0
Because it's not on PyPI
oh
Install it with pip install git+https://github.com/Rapptz/discord.py
what about ninjago
!rule 7
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
I did bot (last times it worked), but now not!!!
Without errors and/or errors nobody can help
It said client = discord.Bot()
AttributeError: module 'discord' has no attribute 'Bot'
Look at the example above again please
oh no, now im getting this
Traceback (most recent call last):
File "C:\Users\harle\Downloads\final\purge.py", line 9, in <module>
client = discord.Client()
TypeError: Client.__init__() missing 1 required keyword-only argument: 'intents'```
Quick question: Is it possible to perform remote actions (I.e. autoban users in one server that are banned in another), and if so, how?
how would you know if they are banned in another server
krypto what did u mean add intents to my code?
These are important lines
You're missing a kwarg in your client instance
it confused me
how do i fix it
Ohhhhh
But I don't use it )
I assume by checking mutual servers with the bot
Read what krypton said
If your bot exists in that other server, and has the permissions to view bans, then yes, you can
It does, in fact it was only made for these two servers
Look:
then sure
Please look at them again
You really don't see a difference between the highlighted blue lines and your code?
The goal is to have it automatically kick members from one server, using on_member_ban, that are banned in the other/main server
I don't see any
from discord.ext import commands
import
And I don't see that you use commands.Bot
Oh...
how would i fix my error, @boreal ravine told me to see what u said about the intents so i added it to my script and it made no difference
I don't need bot prefix!!!!!
I'm really just not sure how to specify guild, or rather how to have it kick the user from all mutual servers
Do you know what a kwarg is?
nope
Probably on_message with re
If you have no commands the bot prefix won't be relevant, you can put anything you want as it will never be used
im so confused
can someone help me with this error File "C:\Users\harle\Downloads\final\purge.py", line 9, in <module> client = discord.Client() TypeError: Client.__init__() missing 1 required keyword-only argument: 'intents'
The last question: how to add intens, last time it didn't need them, but know ||IDK WHY|| but it need them...
if you need the code lmk
Same
kwargs are the basics of python
Hello, I have created a command, that when you turn it on, it runs other functions for 1 day. And I would like to know how I can make it so that another user can also do the command even if the other one is still running
@slate swan
look at that SS and see what your code is missing
!intents
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.
Read the entire message, not just the code
Otherwise you will come to another error because you haven't read it entirely
Run your other function that runs for 1 day in an asynchronous way so that it gets run in the background and doesn't block your entire bot from working
intents = Intents.default()
NameError: name 'Intents' is not defined
It said
For the fourth time, please read
You're missing
from discord import Intents
Ohh
Now what ?
intents.member = True
AttributeError: 'Intents' object has no attribute 'member'
eh..
I need to import Mebers
It's members
WORKED
ok its because i use this in my discord command?
for i in range(89):
print(result2)
Yeah that will make it block
and i need to put it in async func or normal function ?
Noo, it worked, but my command
@client.event
async def on_message(message):
if any(word in message.content.lower() for word in["lol", "haha", "mhm"]):
await message.delete()
not working
What intents have you enabled?
members
Make it asynchronous
look..
We told you to enable the messages intent
No, they only have this word filter which they apparently consider as a command

It's not this
uh
They only have a word filter, that's it
I'm literally done
now what..
not working
Is that the entire code?
PyCharm (idk what is entire ......)
Is that all your code or you have something below
Yes I have smthong
Something with .run()?
Don't send it, just yes or no
no
I wanna send
Here we go....
Yeah ok
It ran\
like this ?
@bot.command()
async def test(ctx):
z = get_string()
await test2(z)
async def test2(z):
for i in range(50):
print(z)
time.sleep(5)
because no work
Now you need another intent
but when I type one of that words it don't do anything (which intent)
The message_content intent is also needed
Ok.
"no work" doesn't help anyone to help you further.
What do you get? Any errors? What's happening? etc.
Where.. ?
Ik it is wrong
intents.messa....
Have you learned Python?
Yes
Then maybe you want to learn more about OOP in Python before doing a bot. Doesn't seem like you know that pretty well and it's fundamental to know it
when I run the command a second time while the other one is running it does not start
OH MY GODDES worked (I learned only Python IDLE a bit), but it works again and when I said bad word it is automatically deleting, so, I am so happy again (I am Ukranian btw) I wish you a good night (2 am for me ...)
how did you get "Advent of Code" role here ?
It's an opt in role for an event run in december
opt in, meaning you can give it to yourself
how would i use custom emotes with the bot
i read the thing you said and enabled all the intents i needed
however, none of my scripts work, i added the intents thing in the scripts too
File "C:\Users\harle\Downloads\final\purge.py", line 14, in <module>
client = discord.Client()
TypeError: Client.init() missing 1 required keyword-only argument: 'intents'
client = discord.Client()```
class discord.Client(*, intents, **options)```
Represents a client connection that connects to Discord.
This class is used to interact with the Discord WebSocket and API.
A number of options can be passed to the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
discord pycord
@bot.slash_command()
async def avatar(ctx, member : discord.Member = None):
if member == None:
member = ctx.author
memberAvatar = member.avatar_url
avaEmbed = discord.Embed(title=f"{member.name}'s Avatar")
avaEmbed.set_image(url = memberAvatar)
await ctx.respond(embed = avaEmbed)
"member" object has no attribute "avatar_url"
idk what I forgot
try uninstall pip and install again
guys how can i get everyone whos banned in a guild?
Are you Owner ?
id have administrator yeah
!d discord.Guild.bans
async for ... in bans(*, limit=1000, before=..., after=...)```
Retrieves an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") of the users that are banned from the guild as a [`BanEntry`](https://discordpy.readthedocs.io/en/master/api.html#discord.BanEntry "discord.BanEntry").
You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission
to get this information.
Changed in version 2.0: Due to a breaking change in Discord’s API, this now returns a paginated iterator instead of a list...
No error just when I try to use the command
member.avatar.url
.url? no xd
yes
wait
Are you on 2.0?
o.o
yes xD
Then yes.
bannedmems = []
async for mem in bans(*):
bannedmems.append(mem)
``` so this would worj?'
Oh yeah lol. Saw that I did all my commands with author/member."...."
bruh ok my fault, thanks Tylerr
what for.
And what’s the point of that star there
adding every banned member to an array
@sage otter Banner is the same with just .banner right?
not sure copying off docs, wud guess its smth to do w *args tho
Definitely not
but it’s different. You need the members User object for the banner.
tf
Idk
strong xd whys it so complicated
hmm so hw would i get every banned member id into an array?
By not passing anything
In the docs. If you read, if you pass in None which is the default value. It returns all the bans.
bannedmems = []
guild = client.get_guild(guild)
for mem in guild.bans:
bannedmems.append(mem)```so this?
If i want to have the embed field value to be empty how do i make it do that? because i want it to store numbers on that field if that make sense
async def start(ctx):
embed=discord.Embed(title="Profile", description="", color=0x00ff00)
embed.add_field(name= f"User: {ctx.author.mention}", value="✅Verified 18+✅", inline=False)
embed.add_field(name='Name', value=str(ctx.author.name), inline=True)
embed.add_field(name='Age', value="", inline=True)
embed.add_field(name='Gender', value="", inline=True)
embed.add_field(name='Orientation', value="", inline=True)
embed.add_field(name='Location', value="", inline=True)
embed.add_field(name='Dating status', value="", inline=True)
embed.add_field(name='Height', value="", inline=True)
embed.add_field(name='DMs status', value="", inline=True)
embed.add_field(name='Verification level', value="", inline=True)
embed.add_field(name='Looking for', value="", inline=True)
embed.add_field(name='Hobbies', value="", inline=True)
embed.add_field(name='About me', value="", inline=True)
embed.set_author(name=ctx.author.name, icon_url= ctx.message.author.avatar_url)
await ctx.send(embed=embed)```
Pass "** **" to the value keyword-argument.
Fair warning, mentions wont render inside names or titles
is it possible to make webhooks with disnake?
yes
u r being labeled as spammer btw
alr
elaborate
are you familliar with databasews
also id suggest go look up tutorials cause this stuff usually takes itme
maybe
try making it and share the errors with us
well maybe try learning sql or mongo db first
maybe start with more simple commands then
and try learn the basics of python
database but i suggest you learn python before you move onto them
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
Coke smart
ikrrr :>
owo i see.. i just never thought to look into it even tho i want to do it.. uff complicated :'/
💀 then find videos in your language
Error says it
It can't find Player
Depends on what Player is
Is it a function, a class, where is it from? A pip module or some other file? etc
seems like Player is in the player.py module
maybe you can try from player import Player
Also this probably belongs in #game-development
File "d:\CODE\py\discord.py\main.py", line 88, in work
user[str(user.id)]["wallet"] += earnings
TypeError: 'Member' object is not subscriptable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\H81\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\H81\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\H81\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'Member' object is not subscriptable
what is this error guys ?
@client.command(hidden=True)
async def prefix(ctx, prefix=None):
if prefix is None:
return
async with aiosqlite.connect('prefixes.db') as db:
async with db.cursor() as cursor:
await cursor.execute('SELECT prefix FROM prefixes WHERE guild = ?', (ctx.guild.id,))
data = await cursor.fetchone()
if data:
await cursor.execute('UPDATE prefixes SET prefix = ? WHERE guild = ?', (prefix, ctx.guild.id,))
await ctx.reply(f'Updated prefix to `{prefix}` successfully.')
else:
await cursor.execute('INSERT INTO prefixes (prefix, guild) VALUES (?, ?)', (',', ctx.guild.id,))
await cursor.execute('SELECT prefix FROM prefixes WHERE guild = ?', (ctx.guild.id,))
data = await cursor.fetchone()
if data:
await cursor.execute('UPDATE prefixes SET prefix = ? WHERE guild = ?', (prefix, ctx.guild.id,))
await ctx.reply(f'Updated prefix to `{prefix}` successfully.')
else:
return
await db.commit()
I am using this to change prefix and it changes but still doesnt work for new prefix and works for , only
||Sorry if i am asking in wrong channel|| https://media.discordapp.net/attachments/865884512692207636/969810961559080990/unknown.png
async def getprefix(client, message):
async with aiosqlite.connect('prefixes.db') as db:
async with db.cursor() as cursor:
await cursor.execute('INSERT INTO prefixes (prefix, guild) VALUES (?, ?)', (',', message.guild.id,))
data = await cursor.fetchone()
if data:
return data
else:
try:
await cursor.execute('INSERT INTO prefixes (prefix, guild) (?, ?)', (',', message.guild.id,))
await cursor.execute('SELECT prefixes SET prefix = ? WHERE guild = ?', (message.guild.id,))
data = cursor.fetchone()
if data:
await cursor.execute('UPDATE prefixes SET prefix = ? WHERE guild = ?', (',', message.guild.id,))
except Exception:
return ','
I believe here is some error

``py
oops
@bot.tree.command(guild=discord.Object(id=guild_id), name="hello",
description="Use this and I'll say hi!")
async def slash(interaction: discord.Interaction):
await interaction.response.send_message("Hi!")
How would I implement a slash command like this in a Cog?
@app_commands.command()
And the function would be the same
except with self stuff, right?
Yep
how do i get a user object from an ID? i'm having some trouble getting it to work
messages = await ctx.channel.history(limit=200).flatten()
for i in messages[::-1]:
print(bot.get_guild(ctx.message.guild.id).get_member(i.author.id))
how do I learn more about the decorators?
https://realpython.com/primer-on-python-decorators/ I haven’t read this one but the website it usually good
I mean the specific app_commands.command decorator
@discord.app_commands.command(*, name=..., description=...)```
Creates an application command from a regular function.
i.author is already the user/member object which sent the message
it doesn't seem to be? when i do ctx.author.color i get the right hex value, but when i do i.author.color it just returns black (#000000)
def information(message):
return {'COLOUR': message.author.color, 'NAME': message.author.name, 'ICON' : None, 'CONTENT': message.content, 'BOT': message.author.bot, 'TIME': message.created_at}
@bot.command()
async def archive(ctx):
messages = await ctx.channel.history(limit=200).flatten()
for i in messages[::-1]:
# print(bot.get_guild(ctx.message.guild.id).get_member(i.author.id))
print(information(i)['COLOUR'])
Are you sure the author and the i.author are the same user?
i is the message object, since its looping through the messages in messages
by author do you mean the person who sent the command?
Yes
no, they arent necessarily the same
its grabbing the messages from the channel and im trying to get the name colour of the person who sent each i
!d discord.User.color
property color```
A property that returns a color denoting the rendered color
for the user. This always returns [`Colour.default()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Colour.default "discord.Colour.default").
There is an alias for this named [`colour`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.colour "discord.User.colour").
yeah thats the problem though
Says something about default color 0 here
Hii, I have some questions regarding discord oauth2 that i am not sure i understand it right, and i am not sure where to ask so i asked here
https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-refresh-token-exchange-example
in this function, what should i pass?
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
when i just have ```python
@bot.command()
async def archive(ctx):
print(ctx.author.color)
they are different actually
solved it! 
Please don't crosspost.. and also, use a pastebin
okay so for a modmail bot, when someone DM's the bot and confirms, it opens a ticket and for the bot to know which ticket is open, I put it in a db. If a user has an open ticket in the db, it sends the message, if not, it gives the confirmation message (whether they're sure they want to create a ticket). Now, I saw someone has opened two tickets at the same time. does anyone have an idea why?
you forgot to put a cooldown/check
i would recommend a per member ticket cooldown, or a custom check
what do you mean custom check
!d disnake.ext.commands.check
@disnake.ext.commands.check(predicate)```
A decorator that adds a check to the [`Command`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Command "disnake.ext.commands.Command") or its
subclasses. These checks could be accessed via [`Command.checks`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Command.checks "disnake.ext.commands.Command.checks").
These checks should be predicates that take in a single parameter taking
a [`Context`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Context "disnake.ext.commands.Context"). If the check returns a `False`-like value then
during invocation a [`CheckFailure`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.CheckFailure "disnake.ext.commands.CheckFailure") exception is raised and sent to
the [`on_command_error()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.disnake.ext.commands.on_command_error "disnake.disnake.ext.commands.on_command_error") event...
lemme give an example
it's not a command
it isn't?
I have a sort of check.
. If a user has an open ticket in the db, it sends the message, if not, it gives the confirmation message (whether they're sure they want to create a ticket)
A on_message?
no it's a modmail bot where you DM the bot
im talking about a check to make sure that the user hasn't created a ticket already
hi
such as py if user.id in db: return await ctx.send('you already have an open ticket')
like I said, I do have one
^
mind sending the code over?
Does it work?
It's not listening to command verification
it should work
no errors
But does it
i did testing before I pushed it out to my bot but yes it did work
this makes my json empty for some reason
with open("giveawaytime.json","w") as f:
logs2 = json.load(f)
try creating a view class separately, i usually do it like ```py
class my_view(View):
@button(style=discord.Style.green, name='Verify')
async def callback(self, button: Button, interaction: discord.Interaction):
pass # do something here
await ctx.send(view=my_view())```
Aren't you writing
open in read mode
i want to delete a key
Are you perhaps using json as database again
ke so do py with open("file.json", 'r') as f: dict = json.load(f) del dict[key] with open("file.json", 'w') as f: json.dump(dict)
i found sql hard and im learning it
I'll let double 7 handle this
hm?
import sqlite3
im stuck in IMPORT in sql

ok
forgor this is async
bru
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: UnsupportedOperation: not writable
not writable
kek lemme edit it
okay
How can I import it?
Like what’s the code
Do I import?
yes
disnake?
either that or access it by disnake.ApplicationCommandInteraction
What’s disnake?
from disnake import ApplicationCommandInteraction
I’m using dpy
Not disnake
I’m using dpy
Not disnake
I finally, finally think i'm nearing the end creating my bot. After getting a rough prototype done, i wrote down 60 items to complete and estimated two weeks to finish it. I've now completed 242 items in my dev log, have 9 left to go, and if i get finished in a couple days i'll have spent 6 weeks on it.

So I'm making my discord bot and I want to set the thumbnail of an embed. As we know, discord.py only accepts links in the url parameter, But I want to use an image which exists in my working directory, not a link. How can I do that? Any help is appreciated (:
file = disnake.File(fp=your_directory, filename="image.png")
embed.set_thumbnail(url="attachment://image.png")```
i think if my brain is working that should do it
there is a file kwarg iirc
the directory in str right?
there is no disnake function or something @dull terrace
replace disnake with discord if you're using that
oh ok
it's the module you imported
thanks let me try it
you may have to send the file in the message too
File "c:\Users\DEBARKA NASKAR\Desktop\The Marauders\main.py", line 1330 file = discord.File(fp='C:\Users\DEBARKA NASKAR\Desktop\The Marauders', filename='flower.png') ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
@dull terrace Why is this coming?
fp=r'C:\Users\DEBARKA NASKAR\Desktop\The Marauders'
oh, you have to put the full path
raw string? ok lets try
'C:/Users/DEBARKA NASKAR/Desktop/The Marauders/flower.png'
ok
wait where is your python file
same dir
IT WORKED TYSM


idk if it exists there
I fixed it anyway
replit
goto shell and type pip install disnake
lmao
why did I read that as hell
Suggest more topics here!
prolly a server mapping command, shows which users have the most activity, most active channels, most messages sent, who was banned recently, and other things
Could someone please help me figure out what this means?
Attribute avatar_decoration is missing from the User data model, skipping.
trying to do slash commands with discord interactions
show code
and the full traceback

you don't have intents enabled
:0
go to application page, turn on all intents
and in your code do py intents = discord.Intents.all() bot = commands.Bot(command_prefix='!', intents=intents, case_insensitive=True)
@slate swan @quaint epoch
import discord
import interactions
token = str("my token")
client = discord.Client()
bot = interactions.Client(token=token)
@client.event
async def on_ready():
print('Bot Started')
@bot.command(
name="test",
description="test",
scope=963627111111856138,
options = [
interactions.Option(
name="test2",
description="test2",
type=interactions.OptionType.STRING,
required=True,
),
],
)
async def thorne(ctx: interactions.CommandContext, test2: str):
await ctx.send("Working", ephemeral=True)
bot.run()
@quaint epoch u the goat, thanks
PS C:\Users\Micha> c:; cd 'c:\Users\Micha'; & 'C:\Users\Micha\AppData\Local\Programs\Python\Python39\python.exe' 'c:\Users\Micha\.vscode\extensions\ms-python.python-2022.4.1\pythonFiles\lib\python\debugpy\launcher' '57290' '--' 'c:\Users\Micha\discslash.py'
Attribute avatar_decoration is missing from the User data model, skipping.
PS C:\Users\Micha>
uhhh
you can't do that
the context for regular commands is discord.ext.commands.Context
for slash commands, use~
welp, back to the docs
gimme a bit, kay
one sec
why not just use the slash commands that come with discord.py?
im looking for the docs, although i can't find them
@slash_command(*args, **kwargs)```
A shortcut decorator that invokes [`slash_command()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.slash_command "disnake.ext.commands.slash_command") and adds it to
the internal command list.
Discord making a feature for killing some kind of bots again 💀
use this instead
im gonna use it...
which lib are you using?
It is beta and available to limited amount of servers
👀
wow
Well time to test its bypass resistance
nice, just ctrl+z-ing my swear filter to bring it back to my bot 👍
how do I check?
When in use the command it doesn’t say that I’m on a cool down
!pypi better_profanity --- go brrrr
cuz you didn't add a callback/defer
Defer?
What is that?
!d discord.InteractionResponse.defer
await defer(*, ephemeral=False, thinking=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Defers the interaction response.
This is typically used when the interaction is acknowledged and a secondary action will be done later.
This is only supported with the following interaction types...
@quaint epoch i dont see the problem with that I did, could you please expand or talk to me in #help-falafel
As I checked mine is even better than this and more customizable
Can I have a e.g?
And I am gonna add character antidoubling later
if you are going to give a response to an interaction, and if that process is going to take longer than 3 seconds, defer.
because if the application does not response in 3 seconds, it say's it did not respond
and btw, show your work command
@slash.slash(name="work", description="work to get money")
@commands.cooldown(1, 300, commands.BucketType.user)
async def work(ctx):
await open_account(ctx.author)
users = await get_bank_data()
user = ctx.author
earnings = random.randrange(20000)
await ctx.send(f"you got {earnings} coins from working")
users[str(user.id)]["wallet"] += earnings
with open("bank.json", "w") as f:
json.dump(users, f)
@slash.slash(name="work", description="work to get money")
@commands.cooldown(1, 300, commands.BucketType.user)
async def work(ctx):
await open_account(ctx.author)
users = await get_bank_data()
user = ctx.author
earnings = random.randrange(20000)
await ctx.send(f"you got {earnings} coins from working")
users[str(user.id)]["wallet"] += earnings
with open("bank.json", "w") as f:
json.dump(users, f)
Is this the automatic discord censoring or is it something you’ve programmed
Discord
And as you can see it sucks
Aight
I programmed a better thing
But I got no server to host in on because of stupid sanctions
Gonna build bare metal
So what do I do to show the user that they have a cooldown
Could I do await defer.send_message(“”)
if i kept my previous swear filter, (the one that was around 3 mb of data), it would've filtered that
but it was too aggressive
How do I make this for my guild only so that it syncs instantly?
@app_commands.command(name="hello", description="Use this for me to say hi!")
Did it punch you and shit?
yes
☠️
So what?
then do stuff after
Oh ok.
sending messages, calculations, all that
Wym?
await defer(thinking=False)
Right?
Is there somewhere I have to make it for my guild only?
await defer(thinking=False)
i like to turn on thinking
guilds=[id's]
in the decorator
that's not an option for that decorator
what lib are you using?
dpy, disnake?
dpy
dpy doesn’t have app_commands
Anything else?
yea it does..
I don’t believe
!d disnake.ext.commands.Bot.command
@command(*args, **kwargs)```
A shortcut decorator that invokes [`command()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.command "disnake.ext.commands.command") and adds it to
the internal command list via [`add_command()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.GroupMixin.add_command "disnake.ext.commands.GroupMixin.add_command").
I'm looking at the docs rn
what's the latest version?
Some mf must’ve lied to me then
2.0
that's an application command, not a regular text/slash_command, i don't think you can do that then
how could i make a leaderboard command for my discord.py economy bot using aiosqlite?
yeah sure
i haven't used it myself tho
?????????
?????????
what do you mean "yeah sure"?
you can
Even though your using it in a discord bot, your handling all your database stuff
i know i can
oh you asked, how, not if
yeah
How can I make it send that the user sees that they have a cooldown
#databases should have answers
return await ctx.send_message(content='you are on cooldow', ephemeral=True)
yeah i asked there aswell
That chat is kind-of dead tbh
I gave up on databases a while ago
The hosting service I’m using just allows me to edit json files so I’m using that
It has a built in database too but I cba to use it
yeah
im mostly working with this bot cus my friends and i have a private server with an economy bot
and json lagged so much that we had to switch database
Still not working
That’s probs why my commands are so slow 💀
exception discord.ext.commands.CommandOnCooldown(cooldown, retry_after, type)```
Exception raised when the command being invoked is on cooldown.
This inherits from [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError")
try printing out the type of the error
commands.errors.CommandOnCooldown
?
Use that instead
Ok
Nope doesn’t send still
remove return
Wont change bullshit
just try
Nope doesn’t send
hm
Wdym?
Dw
Yes
did it work
No
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.
With token included!
Oh lol


