#discord-bots
1 messages · Page 509 of 1
Ik embed but how do I make the bot capture role info
like how many people has the role?
and a matplotlib
idk
Role.members
@commands.Cog.listner()
async def on_message(self,message):
if message.author.bot:
return
if any(str(bot.get_user(user_id)) for user_id in message.content.split() if user_id.isdigit()):
uid = await self.coll.find_one({"user_id": str(user_id), "reaction" str(reaction)}) #getting the user ID if in db then getting reaction
await message.add_reaction(reaction)
Would something like that work?
how can i make this type of timestamp in dpy?
@skqwid#7560 is here too.
pls tell me
You can by setting the timestamp attribute of embeds to a datetime object
https://dislashpy.readthedocs.io/en/latest here's something which can help
k
datatime.datetime.utcnow() ?
yes, that'd be a valid datetime object
supported in cogs ?
will datetime.datetime.utcnow() make this kind of timestamp?
ok
i ama make a new py file and try using dstetime
this is what utcnow returns
not much readable
yes sir
set it as the timestamp attribute and discord will parse it
embed.timestamp = datetime.datetime.utcnow()
embed.set_timestamp(datetime.datetime.utcnow()) ?
ok
or you can have py timestamp = in discord.Embed itself
aren't u supposed to tell us?
just take a photo
also how can i set the user avatar in the footer? and i don't think there is ctx.author.tag
the error..?
!d discord.Embed.set_footer
set_footer(*, text=Embed.Empty, icon_url=Embed.Empty)```
Sets the footer for the embed content.
This function returns the class instance to allow for fluent-style chaining.
copy paste the error here
thanks
!paste or this
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.
KeyError
If you get a KeyError, it means what you are looking for isn’t in the dict/json. There are many solutions for this:
- Make a try-except to make a default value
- Add the key manually
- If its a discord bot and you are making a custom prefix thingy, simply kick the bot and invite it again (you need the on_guild_join part for this)
KeyError: '890976262452047872'
what is the error
Example isn't defined
can i pass the ctx.author.avatar_url in the icon_url
yes
def setup(bot):
bot.add_cog(Example(bot))
ok
this is the code
did u define it?
what
Example has to be a defined class above the setup function
^ meaning ur cog name
import discord
from discord.ext import commands
class BotOnReady(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
print('Bot is online now')
def setup(bot):
bot.add_cog(Example(bot))
this is the full code i added in cogs
use the class name in the Example part
oh ok
ok
Which commands shoul I use for auto role when member join
!d discord.on_member_join
discord.on_member_join(member)``````py
discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
Ty
ik now i got it 😂 thats why i deleted it
yeah lmao
Can a bot owner use commands with .has_perms() in a guild in which the owner doesnt have required perms?
The command named help is already registered
np
did u even read the error tho
you might have to elaborate
@waxen granite check if the authors is the bot owner
Or make a function to check it
Or use the decorator
Such as @commands.is_owner() or @bot.is_owner() depending on if you're in a cog or not
or put all owner-only commands in a cog, save time and do py async def check(self, ctx): if ctx.author.id not in self.bot.owner_ids: return False return True
you can just return ctx.author.id in self.bot.users
true, but for me I nornally have larger checks so it encourages better readability and development
It's readable if who's reading is good at Python.
.users returns all the users the bot can see, shouldn't it be .owner_id based on their question 🤔
okay, but you also cant extend on that
typo 🐷
¯\_(ツ)_/¯

I'm making a discord bot using python, and I wanted to add a command to create a text channel.
And I wanted to check if the channel exists or not but I'm not able to do so
So can anyone help me with this?
if utils.get(guild.channels, name="Channel-Name") is None:
guild.create_text_channel(...)
```or smth like that
oh thanks let me try
ah sorry but idk it's still not working
I don't have any error but I created a channel that already exists and the bot created that wasn't supposed to
existing_channel = discord.utils.get(guild.channels, name=channel_name)
if existing_channel == None:
i tried this too
still not working
Would adding a check for if ctx.author.id == owner.id, alter the usage of the cmd by other members who has the right perms?
Just do the command check @commands.check_any(commands.is_owner(), commands.has_permissions(the discord permission you want=True)
check_any checks for both
Hm
Okay thanks, i will try it
is it possible to run a music bot by playing files and the files will be randomized like run by 1 command so any 1 in 2 sound files will be played these are the codes
@bot.command()
async def fastmoans(ctx: commands.Context):
voice_channel: discord.VoiceChannel = ctx.author.voice.channel
print(voice_channel.name)
vc = await voice_channel.connect()
vc.play(discord.FFmpegPCMAudio("fast moan.mp3"))
while vc.is_playing():
time.sleep(.1)
await vc.disconnect()
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
!yt
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)
@slate swan
also kinda nsfw not gonna lie
Hey @gloomy coral, can we keep things on topic please?
it is
@slate swan Using FFMPEG breaks the YouTube ToS, and this server doesn't allow us to help with projects that breach any violations or ToS's, so we can't help you with it, sorry
i am not using youtube
i have sound files which i want to be played by the bot
how do you check whether a member has a specific role or no
i guess it was something like
r!tag member.roles
!d discord.Member.roles
property roles: List[Role]```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [‘@everyone](mailto:'%40everyone)’ role.
These roles are sorted by their position in the role hierarchy.
if there are 2 sound files
and i want any 1 sound file to by played when a single command is used
how do I do that pls help
@bot.command()
async def test(ctx: commands.Context):
voice_channel: discord.VoiceChannel = ctx.author.voice.channel
print(voice_channel.name)
vc = await voice_channel.connect()
vc.play(discord.FFmpegPCMAudio("song"))
while vc.is_playing():
time.sleep(.1)
await vc.disconnect()
how to connect pgadmin 4 with heroku?
can someone help me out?
@commands.command(brief="SUPPORT TEAM+", description="Will je iemand bannen? Dat kan met dit command!")
@commands.has_role('Support Team')
async def ban(self, ctx, member:discord.User=None, reason =None):
if member == None:
await ctx.send("Je moet wel iemand opgeven.")
if member == ctx.author:
await ctx.send("Je kan jezelf niet bannen.")
if reason == None:
reason = "Geen reden opgegeven!"
await member.ban(reason = reason)
message = f"Je bent gebanned van {ctx.guild.name} ivm {reason}"
await member.send(message)
await ctx.channel.send(f"{member} is gebanned van de server!")```
I get no output or error, why>
The cog works fine btw
what's the issue?
What was the error
I dont get an error thats the problem.
Hmm
But I dont get an output either.
hmm
@commands.command(brief="SUPPORT TEAM+", description="Will je iemand bannen? Dat kan met dit command!")
@commands.has_role('Support Team')
async def ban(self, ctx, member:discord.User=None, reason =None):
if member == None:
await ctx.send("Je moet wel iemand opgeven.")
if member == ctx.author:
await ctx.send("Je kan jezelf niet bannen.")
if reason == None:
reason = "Geen reden opgegeven!"
else:
await member.ban(reason = reason)
message = f"Je bent gebanned van {ctx.guild.name} ivm {reason}"
await member.send(message)
await ctx.channel.send(f"{member} is gebanned van de server!")``` maybe, it's been a while since i worked with dpy
Good idea, ill try.
btw bread can you help me out with something
@client.event
async def on_member_join(member):
print("You havd")
guild1 = client.get_guild(893391320813555713)
guild2 = client.get_guild(893330054254317698)
role = guild2.get_role(893391786586828800)
if role in member.roles:
print("You have joined")
return
else:
await member.kick()
print("You have not joined")``` i want it to check if the member has role in guild2, but it instead checks in the guild1 and kicks the member instantly
mention me if you helped. thanks!
@client.listen
async def on_message(message, member):
for i in range(len(Filter)):
if Filter[i] in message.content:
for j in range(1):
await member.ban(reason='filter')
await message.send('A member has been banned')
await client.process_commands(message)
``` This is not banning when I say a word
oof, that looks weird and broken
like it should find the words in the array called filter then ban if the message contains the word
Do you know How to make it better
Where is Filter defined?
it's a list above my code
you don't need a filter you can just use a variable then store the bad words in it
You can use regex.
Filter = ['giant', 'hi', 'hello', 'monke', 'bye', 'balance']
can someone help with this anyways?
One second.
Here is the variable I have created
async def on_message(message, member):
for words in Filter:
if words in message.content:
await member.ban(reason='filter')
await message.send('A member has been banned')
await client.process_commands(message)
else:
return``` maybe try this?
let's see
!e
import re
bad_words = ["word 1", "word 2"]
message = "word 1 is a bad word"
for word in bad_words:
found = re.find(word, message)
if not found:
continue
print(f"Detected word '{word}'")
@dapper cobalt :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 6, in <module>
003 | AttributeError: module 're' has no attribute 'find'
!e
import re
bad_words = ["word 1", "word 2"]
message = "word 1 is a bad word"
for word in bad_words:
found = re.search(word, message)
if not found:
continue
print(f"Detected word '{word}'")
@dapper cobalt :white_check_mark: Your eval job has completed with return code 0.
Detected word 'word 1'
!d re.search
re.search(pattern, string, flags=0)```
Scan through *string* looking for the first location where the regular expression *pattern* produces a match, and return a corresponding [match object](https://docs.python.org/3.10/library/re.html#match-objects). Return `None` if no position in the string matches the pattern; note that this is different from finding a zero-length match at some point in the string.
You can use this.
🙂
This is the only thing ik how to do with regex 😂
I get a error in this
please someone help, can ya?
try str(Filter)
Where did the member join? guild1?
yes
Yes
member.roles will return the member's roles in guild1 and not guild2.
And you are trying to check if they have a role that's not even in the guild they joined.
yes i understand
this seems hard for me
It's really easy.
You are telling it to search for a keyword in a string.
I get it, so how can i uhh check if the person has the role in guild2 and not guild1
hmm
You can get the member in guild2 using guild2.get_member().
!d discord.Guild.get_member
get_member(user_id, /)```
Returns a member with the given ID.
@client.listen
async def on_message(message, member):
for i in range(len(Filter)):
if Filter[i] in message.content:
for j in range(1):
await member.ban(reason='filter')
await message.send('A member has been banned')
await client.process_commands(message)
``` Can I not make this work
can you give me a short example if possible?
oh nvm
Why are you using range()? You can loop through Filter itself.
Filter is a list which is iterable.
I cannot loop when there is not for?
for item in array:
...
@dapper cobalt can you give me a very short example
for i in Filter:
if i in message.content:
await member.ban(reason="filter")
member2 = guild2.get_member(member.id)
if role in member2.roles:
...
guild2 = client.get_guild(893330054254317698)
role = guild2.get_role(893391786586828800)
members = guild2.get_member(member)
if role in members.roles:
print("You have joined")
return``` i am trying this
You are not getting the member correctly.
oh
You need to use the member's ID.
it's working now thanks!
@client.listen
async def on_message(message, member):
for i in range(len(Filter)):
for i in Filter:
if i in message.content:
await member.ban(reason="filter")
!d discord.Guild.get_member
get_member(user_id, /)```
Returns a member with the given ID.
No.
you told me this ig
@client.listen
async def on_message(message):
for i in Filter:
if i in message.content:
await message.author.ban(reason="filter")
So first we make a function
then check if i is in Filter or not
and i is in filter
HELP
then we ban
for every_word in this_list_of_words
!e
list_of_names = ["seif wessam", "giant", "scoopy"]
for name in list_of_names:
print(name)
@dapper cobalt :white_check_mark: Your eval job has completed with return code 0.
001 | seif wessam
002 | giant
003 | scoopy
we loop the number of time the size of array
array is 3 * 1 so we loop thrice
Loop through the array instead.
ya i see that
How to get the number of invites of the user?
message.content is a string, you are going through each word (i) in your list Filter and you check if this word is in the message.content.
one last thing, how can i make it like it should only work if the person joined a specific server
if guild.id != server_id:
return
i don't get it
Get all the invites of the user then get the len() of it. You can do that with discord.utils.get(guild.invites, inviter=user).
Filter = ['giant', 'hi', 'hello', 'monke', 'bye', 'balance']
@client.listen
async def on_message(message):
for i in Filter:
if i in message.content:
await message.author.ban(reason="filter")
await message.send("You are banned")
``` I don't see this working when I say hi
Learn Python.
Errors?
i am sorry, i haven't used dpy in ages and i've understood what's the issue
Are you the server's owner? Or is your role higher than the bot's role?
!source
but the should atleast reply the message
Then I will ask you a genuine question. Are you able to ban a server's owner even if you had administrator permissions?
bro
I am not fool the bot is not even saying You are banned
how do I make my bot send a thank you message to DM when it gets an upvote from their voting site using webhooks
Filter = ['giant', 'hi', 'hello', 'monke', 'bye', 'balance']
@client.listen
async def on_message(message):
for i in Filter:
if i in message.content:
await message.author.ban(reason="filter")
await message.send("You are banned")
That's first. Second, when you get banned, the message will be deleted. Which will raise "Unknown Message" error.
The bot should say You are bammed
And third, discord.Message has no method called send().
And fourth, the ban operation has raised an error, which will stop the rest of the code after it.
What is ctx defined as?
help ps
context
Is this a command? Or an event?
it mean context basically what is going
class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)```
Represents the context in which a command is being invoked under.
This class contains a lot of meta data to help you understand more about the invocation context. This class is not created manually and is instead passed around to commands as the first parameter.
This class implements the [`Messageable`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable "discord.abc.Messageable") ABC.
like
await ctx.send('wut you wanna send')
you can put this line in any event or command
this is a on_message event
That's not really kind
It doesn't work in events.
At least use the resources tag
Huh?
My bad then.
Then you cannot use ctx.
It's either message.reply() or message.channel.send().
!d discord.Message
class discord.Message```
Represents a message from Discord.
x == y Checks if two messages are equal.
x != y Checks if two messages are not equal.
hash(x) Returns the message’s hash.
Delete this, please. 🙂
Make it able to ban the user first. And then message.channel.send().
It's considered advertising.
oh
Which is discord.ext.commands.Context
I see thanks
I don't really see how though.. I may be wrong
ok
It had an application's invite URL.
Let's not be so dismissive of people who are new to Python please. I get that it can be frustrating, but you can be a lot more helpful than just "learn Python". Remember there's no obligation to help anyone either, so there's always the option to let someone else help the newer users.
Okay. I apologize if it didn't sound very well.
Yeah I saw but it wasn't like "Guys please invite my bot" but nevermind
can anyone help me how do I make my discord bot send a thank you message to their when they get upvote from their upvoting site i am using webhooks for this purpose
These are the codes
import re
@bot.event
async def on_message(message):
if message.channel.id == 834837773805813780:
data = message.content.split(" ")
user = re.sub("\D", "", data[0])
await bot.process_commands(message)
Hello how to get a server object?
!d discord.Guild
class discord.Guild```
Represents a Discord guild.
This is referred to as a “server” in the official Discord UI.
x == y Checks if two guilds are equal.
x != y Checks if two guilds are not equal.
hash(x) Returns the guild’s hash.
str(x) Returns the guild’s name.
Using server id
!d discord.ext.commands.Bot.get_guild
get_guild(id, /)```
Returns a guild with the given ID.
Can I get the owner name and member count from that obj?
Yes
!d discord.Guild.owner
property owner: Optional[discord.member.Member]```
The member that owns the guild.
!d discord.Guild.members
property members: List[discord.member.Member]```
A list of members that belong to this guild.
any1 help me pls
Yes. You can get more as well.
!d discord.Guild click on the blue title and you will see it on the docs.
class discord.Guild```
Represents a Discord guild.
This is referred to as a “server” in the official Discord UI.
x == y Checks if two guilds are equal.
x != y Checks if two guilds are not equal.
hash(x) Returns the guild’s hash.
str(x) Returns the guild’s name.
Sorry, could you please explain where in that code have you used any webhook?
i am using integromat and make a scenerio connectin custom webhook and HTTP
and the codes in the Integromat
{ "username" : "test", "content" : "https://imgur.com/a/E38fUIx", "avatar_url" : "https://cdn.discordapp.com/attachments/874658736797515897/892027800700198982/images_5.jpeg"
"<@{{2.id}}> : Thank you for upvoting the bot ! ":D" }
What is the data you get when someone upvotes?
i am not getting any data actually
Then most likely it fails to send a POST request to your webhook URL.
can you pls tell me how to fix?
i have also connected a discord webhook within HTTP
I'm not very familiar with that.
the site helpers gave me a doc but he said it wont show how to send DM but use this as a ref
Well, first of all, you need to receive some data. Then, if the data includes the voter's ID, sending them a private message would be easy. Just get the user from the bot's cache using their ID, and send them the message.
What code?
This?
this is webhook codes
this python
That's a JSON dict, not a code.
okay so python codes are having problems
do you think is there any way to fix it?
How do you receive the POST request?
What?
What does that have to do with Python at all?
the site isnt having an API for that which makes it even a bigger problem
1st dpy and now entire python?
oh
Discord.py has a default help command.
dpy stopped dev it means discord is also stopping dpy?
dpy doesnt supp slash commands
WAIT WHAT?
Then just type / and you will see all your bot's slash commands.
i heard that the only reason why dpy stopped dev was due to discord was making all languages slashes
It's up to you whether you want to make a help command.
But I believe it's useless since it's slash commands.
I'd go with disnake. It's pretty good imo. And also it supports all kinds of Discord interactions.
.com?
yes its a discord bot sites
Yeah, my bot's listed there.
https://github.com/DankMemer/webhook-server
dank memer has also a system which sends a DM when it gets an upvote
i tried to understand it but everything gone above my brain
on_voice_update isn't working
@client.event
async def on_voice_update(member,before,after):
if member.bot:
return
if not before.channel:
print(f"{member.name} joined {after.channel.name}")
if before.channel and not after.channel:
print(f"{member.name} left {before.channel.name}")
if before.channel and after.channel:
if before.channel != after.channel.id:
print(f"{member.name} swicthed voice channel")
else:
print("Something else happened")
the codes are js
delete message or we get mute or ban
no risk
play safe
I don't think there's such an event.
!d discord.on_voice_state_update
discord.on_voice_state_update(member, before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") changes their [`VoiceState`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceState "discord.VoiceState").
The following, but not limited to, examples illustrate when this event is called...
anyways dank memer is on discordbotlist and sends a DM when it gets an upvote using webhooks this link i gave has the files
you mean this?

and the way to make a DM when get upvote
can you please check if its possible for python because dank memer is JS
i suffer from brain pain,dizzyness when lookin on js codes
webhooks site helper said he doesnt know about API of the site
Official documentation for the discordbotlist.com API.
{
100 lines of codes with bunch of ( , . /
}
It's not that hard, though. Just different syntax.
js codes in a nutshell
code isn't plural by the way
Same goes for python?
nah i guess
https://docs.discordbotlist.com/vote-webhooks @slate swan
i ned to go
Those are just python parentheses in javascript.
How can I make my bot send message in On_message function
message.channel.send()
ok
@client.listen
async def on_message(message):
for i in Filter:
if i in message.content:
await message.channel.send('hmm')
await message.send("You are banned")
``` But the bot doesn't replies
Filter is a list of some words
Ah
yes I send
I get a syntax error now
Code?
@client.listen
async def on_message(message):
for i in Filter:
if i in message.content.lower()
await message.channel.send('hmm')
await message.send("You are banned")
I really think that there is no problem
There is.
:?
And I've spotted it once you sent the code. Just look closer.
:
Yes.
lemme try now
Me who smashes my head in a wall when I miss a closing bracket: 
@commands.command()
async def blur(self, ctx):
img = Image.open('C:/bots/studybot/cogs/test.png')
img2 = img.filter(CONTOUR)
await ctx.send(img2)
```help pls
i want to send a image
and the bot doesn't replies
@client.listen
async def on_message(message):
for i in Filter:
if i in message.content.lower():
await message.channel.send('hmm')
await message.send("You are banned")
Try to print the message.content at the start of the function.
lol ok
anyone help pls
:stare:
Java.
aint that java
U gotta save the image
lul bit too late
Yups
how ,where
sooo
this is not discord.py tho
Where?
- In your code's directory.
How? - By doing some code.
😂
xD
I got these codes from dank memer github where it showed how to send user a thank you message is it possible to convert these into python?
return _saveQuery(_fetchUserQuery(id).merge({
voteReminderWaiting: true,
pocket: r.row('pocket').default(0).add(50000),
inventory: {
[itemOne]: r.row('inventory').default({}).getField('banknote').default(0).add(3),
[itemTwo]: r.row('inventory').default({}).getField('daily').default(0).add(1)
},
upvoted: true,
...(isDbl
? { lastDblVote: Date.now() }
: { lastTopggVote: Date.now() }
)
})).run();
};
this is the code
!d PIL.Image
Dank Memer is open source?
dank memer is opensource?
@client.listen
async def on_message(message):
for i in Filter:
if i in message.content.lower():
print(message.content)
await message.channel.send('hmm')
await message.send("You are banned")
``` This is my code and bot doesn't prints
I said at the start of the function.
before the first for?
yea
idk about that but in dank memer github it showed webhooks in which there was upvote.js and i checked what dank memer DM when we vote for him and found these codes were behind it
Yes.
OFC
how can i send a message in on_ready?
already tried
await channel.send('hello')```
and
`await client.get_channel("enter channel id here").send("bot is online")`
didnt work
@client.listen
async def on_message(message):
print(message.content)
for i in Filter:
if i in message.content.lower():
await message.channel.send('hmm')
await message.send("You are banned")
``` nothing changed
Does it print your message?
Replace @client.listen with @client.event.
i dont know, but try @client.event
!d discord.ext.commands.Bot.listen
@listen(name=None)```
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready")
The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.9)").
Example...
then my other commands won't work
@client.listen("on_message") should work.
Or just @client.listen().
You just have to call it.
File "/home/container/bot.py", line 137, in on_message
with open('/json/users.json', 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'users.json'
The file exists, but why this error then?
@client.listen("message")
async def on_message(on_message):
print(client.message)
for i in Filter:
if i in message.content.lower():
await message.channel.send('hmm')
await message.send("You are banned")
umm there is
on_message not message.
oh yeh
It's on_voice**_state**_update
!d discord.on_voice_state_update
discord.on_voice_state_update(member, before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") changes their [`VoiceState`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceState "discord.VoiceState").
The following, but not limited to, examples illustrate when this event is called...
ohh shit
You were using on_voice_update.
🥳
😄
Yes.
Now time to ban myself if I say hi
You cannot if you're the guild's owner.
Ah, okay.
Isn't that API abuse? Or are you joking as well?
how can i send a message in on_ready?
already tried
await channel.send('hello')```and
`await client.get_channel("enter channel id here").send("bot is online")`
You told me How to ban
await member.ban(reason=reason)
``` Should I just put this
i should remove that reason
did it wrktho
no
else i wouldn't have asked right?
the reason shows up in the audit log do you want that or no?
whats the error the got raised
that got*
I don't want that
then remvoe it ig
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.7/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "/home/pi/Desktop/Quotes.py", line 19, in on_ready
await client.get_channel("861677744956768290").send("!calibrating " + text)
AttributeError: 'NoneType' object has no attribute 'send'```
try fetching the guild first
@client.listen("on_message")
async def on_message(message, member):
print(message.content)
for i in Filter:
if i in message.content.lower():
await message.channel.send('hmm')
await member.ban('filter')
``` Will this work ?
wait
change it an an int
not string lol
got told that solution with a string lmao
who said that
IDs are integers
not strings
works now, thx
idk, was a while ago
no problem
pinged
How can I ban someone by using the on_message function
@client.listen("on_message")
async def on_message(message):
print(message.content)
for i in Filter:
if i in message.content.lower():
await message.channel.send('Time to ban you out')
ok
ya
@client.listen("on_message")
async def on_message(message, member):
print(message.content)
for i in Filter:
if i in message.content.lower():
await message.channel.send('Time to ban you out')
await message.guild.ban(member)
oh
@client.listen("on_message")
async def on_message(message, member):
print(message.content)
for i in Filter:
if i in message.content.lower():
await message.channel.send('Time to ban you out')
await message.ban(member)
member not message
on_message doesnt take a member arg
!d discord.on_message doesn't take a member parameter.
discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Warning
Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
It's message.author.ban() and not member.ban().
he didnt explicitly say that
@client.listen("on_message")
async def on_message(message, member):
print(message.content)
for i in Filter:
if i in message.content.lower():
await message.channel.send('Time to ban you out')
await member.author.ban(member)
this isn't working
You didn't even read correctly.
oh
@client.listen("on_message")
async def on_message(message, member):
print(message.content)
for i in Filter:
if i in message.content.lower():
await message.channel.send('Time to ban you out')
await message.author.ban()
Still
@client.listen("on_message")
async def on_message(message, member):
print(message.content)
for i in Filter:
if i in message.content.lower():
await message.channel.send('Time to ban you out')
await message.author.ban(member)
I have member parameter
!d discord.on_message can you please click on the blue title?
discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Warning
Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
@client.listen("on_message")
async def discord.on_message(message, member):
print(message.content)
for i in Filter:
if i in message.content.lower():
await message.channel.send('Time to ban you out')
await message.author.ban(member)
this?
Do you see any member parameter?
@client.listen("on_message")
async def on_message(message):
print(message.content)
for i in Filter:
if i in message.content.lower():
await message.channel.send('Time to ban you out')
await message.author.ban()
Not working
Does it print the message's content?
Try removing "on_message" from the listen() function.
It replies?
@client.listen()
async def on_message(message):
print(message.content)
for i in Filter:
if i in message.content.lower():
await message.channel.send('Time to ban you out')
await message.author.ban()
no it doesn't
It don't say 'Time to ban you out'
Hey, add this:
@client.event
async def on_command_error(ctx, error):
raise error
Not very sure if this applies to errors of message events as well, but hopefully it does.
Nothing changed
Make it print i.
still nothing changes
@client.listen()
async def on_message(message):
print(message.content)
for i in Filter:
if i in message.content.lower():
print(i)
await message.channel.send('Time to ban you out')
await message.author.ban()
for i in Filter:
print(i)
Maybe check ur old code and see what u did for roles = self.roles.get(message)? that usually helps for me lol
what is the error
VoiceClient.play raises an OpusError: invalid argument? works fine on other operating system, using macos
i know that error is name error
but i don't found that
lastmsg={}
@commands.Cog.listener()
async def on_message_delete(message:discord.Message):
lastmsg[message.guild.id]=message
Filter not defined
this is code
^^
yes
it is a list
why
this the code
yhea
@client.listen()
async def on_message(message):
print(message.content)
for i in Filter:
print(i)
if i in message.content:
print(i)
await message.channel.send('Time to ban you out')
await message.author.ban()
``` Why is the if not working
i am converting my code into cogs
maybe indents?
show the cog
ok
class Snipe(commands.Cog):
def __init__(self, bot):
self.bot = bot
lastmsg={}
@commands.Cog.listener()
async def on_message_delete(message:discord.Message):
lastmsg[message.guild.id]=message
@commands.command()
async def snipe(self, ctx:commands.Context):
try:
author = lastmsg[ctx.message.guild.id].author.mention
content = lastmsg[ctx.message.guild.id].content
channel = lastmsg[ctx.message.guild.id].channel.mention
embed = discord.Embed(title = ":gun:Hitman Snipes a message!!:gun:\n\n",description = f"**Author**\n{author}\n\n**Message**\n`{content}`\n\n**Channel**\n{channel}\n\n")
embed.set_footer(text=f"Made by {ctx.author.display_name}.", icon_url=ctx.author.avatar_url)
await ctx.send(embed = embed)
except KeyError:
await ctx.send(f"No Messages to delete in {ctx.channel.mention}")
this is the entire code
put the lastmsg variable on the same line as self.bot
what
After it print(i in message.content.lower()).
Wdym what
i don't understand
Bro the if is not working
what you say
put the variable on the same line as self.bot variable
class WIP(commands.Cog, name='WIP (SOON)'):
def __init__(self, bot):
self.bot = bot
@commands.command()
@commands.has_role("Support Team")
async def announce(self, ctx, msg=None, channel=None):
await ctx.send("Wat is het bericht?", delete_after=3.0)
try:
message = await bot.wait_for("message", check=lambda m: m.author == ctx.author and m.channel == ctx.channel, timeout=45.0)
except asyncio.TimeoutError:
await ctx.send("Helaas reageerde je niet binnen 45 seconde! En de prompt is beeindigd.")
else:
msg = message.content
await ctx.send("Welk kanaal will je het in hebben?", delete_after=3.0)
try:
message = await bot.wait_for("message", check=lambda m: m.author == ctx.author and m.channel == ctx.channel, timeout=190.0)
except asyncio.TimeoutError:
await ctx.send("Helaas reageerde je niet binnen 190 seconde! En de prompt is beeindigd.")
else:
channel = message.content
await ctx.send("Ik ga het bericht verturen.", delete_after=3.0)
await channel.send(msg)```
The prompt works but It doesnt send the message
and I dont get an error
class Snipe(commands.Cog):
def __init__(self, bot):
self.bot = bot
lastmsg = {}
channel = message.content?
Did you mean channel = message.channel?
hi
False
False
False
False
good one
No I didnt
I want them to mention the channel in the content
and send it there
This is what I see in console
now also the error
@client.listen()
async def on_message(message):
print(message.content)
for i in Filter:
print(i in message.content.lower())
if i in message.content:
print('hi')
await message.channel.send('Time to ban you out')
await message.author.ban()
``` @dapper cobalt
comes
what error and show ur code
show code
mm
class Snipe(commands.Cog):
def __init__(self, bot):
self.bot = bot
lastmsg = {}
@commands.Cog.listener()
async def on_message_delete(message:discord.Message):
lastmsg[message.guild.id]=message
@commands.command()
async def snipe(self, ctx:commands.Context):
try:
author = lastmsg[ctx.message.guild.id].author.mention
content = lastmsg[ctx.message.guild.id].content
channel = lastmsg[ctx.message.guild.id].channel.mention
embed = discord.Embed(title = ":gun:Hitman Snipes a message!!:gun:\n\n",description = f"**Author**\n{author}\n\n**Message**\n`{content}`\n\n**Channel**\n{channel}\n\n")
embed.set_footer(text=f"Made by {ctx.author.display_name}.", icon_url=ctx.author.avatar_url)
await ctx.send(embed = embed)
except KeyError:
await ctx.send(f"No Messages to delete in {ctx.channel.mention}")
this is the code
hmm
Also your on_message_delete is missing self
i don't understand
oh ok
the var name
Then learn python, it's basic oop, change lastmsg with self.lastmsg
ok
i understand
@dapper cobalt bro thanks a lot lot lot because now everything is working and I even banned Dank Memer for saying "need" Thanks a lot
this is the code
@client.listen()
async def on_message(message):
print(message.content)
for i in Filter:
if i in message.content:
print('hi')
await message.channel.send('Time to ban you out')
await message.author.ban()
Are you like 11, not trynna be mean but that's what I always hear 11 y/o kids saying when they trynna be satire 😂
Use regex
I am not
he helped me a lot
we're happy to help you lol
Alr
if ctx.guild.id == id:
those are for commands and no there isnt a way to hide slash commands yet
How to mention the mentioned user?
@commands.command()
async def wanted(self, ctx, user: discord.Member = None):
if user == None:
user = ctx.author
wanted = Image.open("C:/bots/studybot/cogs/wanted.PNG")
asset = user.avatar_url_as(size=128)
data = BytesIO(await asset.read())
pfp = Image.open(data)
pfp = pfp.resize(111, 171)
wanted.paste(pfp, (105,327))
wanted.save("profile.PNG")
await ctx.send(file=discord.File("profile.PNG"))
help please
File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\bots\studybot\cogs\fun.py", line 121, in wanted
pfp = pfp.resize(111, 171)
File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\PIL\Image.py", line 1899, in resize
raise ValueError(
ValueError: Unknown resampling filter (171). Use Image.NEAREST (0), Image.LANCZOS (1), Image.BILINEAR (2), Image.BICUBIC (3), Image.BOX (4) or Image.HAMMING (5)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\hp\AppData\Local\Programs\Python\Python39\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: ValueError: Unknown resampling filter (171). Use Image.NEAREST (0), Image.LANCZOS (1), Image.BILINEAR (2), Image.BICUBIC (3), Image.BOX (4) or Image.HAMMING (5)
every single time i try run my bot it says it has a invalid token
its right
Do you use env?
i have checked like 50 times
and regenerated50 times
nope
i have a host
so i dont need too
do you put it directly in the code
ohok
yes
can you send the trackback
i do token = "token here" and client.run(token)
are you sure that you regenerate and copy it ?
client.event
write your code
token = "token here"
client.run(token)
improper token?
and look at it
thats what i have done
member.mention ig
did u regenerate and copy it?
o.o
this works fine
i did that
i not got any error
i think im blacklisted
or something
idk what for
it would not have sent improper token error
i even tried making a new application
in case you were banned from accessing the api
same error
L
i think u overided @quaint axle.event
bruh
wdtm
no pinging random ppl
ok
How to mention the mentioned user?
@client.event
async def on_ready():
print('Connected to bot: {}'.format(client.user.name))
print('Bot ID: {}'.format(client.user.id))
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name=f">commands"))
``` this is the only client event i have
ook
!d discord.Member.mention
property mention: str```
Returns a string that allows you to mention the member.
@commands.command()
async def wanted(self, ctx, user: discord.Member = None):
if user == None:
user = ctx.author
wanted = Image.open("C:/bots/studybot/cogs/wanted.PNG")
asset = user.avatar_url_as(size=128)
data = BytesIO(await asset.read())
pfp = Image.open(data)
pfp = pfp.resize(171, 171)
wanted.paste(pfp, (105, 327))
wanted.save("profile.PNG")
await ctx.send(file=discord.File("profile.PNG"))
can anyone help me
whats the traceback?
isnt it io.Bytes.IO
and i wouldn't save images in cogs
Ignoring exception in command wanted:
Traceback (most recent call last):
File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\bots\studybot\cogs\fun.py", line 121, in wanted
pfp = pfp.resize(171, 171)
File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\PIL\Image.py", line 1899, in resize
raise ValueError(
ValueError: Unknown resampling filter (171). Use Image.NEAREST (0), Image.LANCZOS (1), Image.BILINEAR (2), Image.BICUBIC (3), Image.BOX (4) or Image.HAMMING (5)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\hp\AppData\Local\Programs\Python\Python39\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: ValueError: Unknown resampling filter (171). Use Image.NEAREST (0), Image.LANCZOS (1), Image.BILINEAR (2), Image.BICUBIC (3), Image.BOX (4) or Image.HAMMING (5)
Process finished with exit code -1```.
im just testing bro
y
yes but y
otherwise its messy
mhm
hm
anyone listen here
pls
I mean its a resizing issue
yes
Image.resize takes 1 argument for size, pass it as an iterable, documented here: https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.resize
ok
what are you making btw
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'int' object is not iterable
show what you did
me?
ok
nothing, watching YT, I opened it just in case something happened with my bot
:rooBulli:

Ignoring exception in command wanted:
Traceback (most recent call last):
File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\bots\studybot\cogs\fun.py", line 121, in wanted
pfp = pfp.resize(171,171)
File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\PIL\Image.py", line 1899, in resize
raise ValueError(
ValueError: Unknown resampling filter (171). Use Image.NEAREST (0), Image.LANCZOS (1), Image.BILINEAR (2), Image.BICUBIC (3), Image.BOX (4) or Image.HAMMING (5)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\hp\AppData\Local\Programs\Python\Python39\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: ValueError: Unknown resampling filter (171). Use Image.NEAREST (0), Image.LANCZOS (1), Image.BILINEAR (2), Image.BICUBIC (3), Image.BOX (4) or Image.HAMMING (5)
fk clyde
pass it as an iterable
waitbro
resize(<list/tuple or whatever>)??

watermark 
im gonna solve
ok
ty
i can't use roo emojis anymore ;-;

lmao
yeah but i love some roo emojis
How can I count a member's message in total?
- Use on_message then += 1 everytime
- Fetch history
Code: ```py
@commands.command(description='Says whatever you want using a webhook.')
async def echo(self, ctx, *, message):
webhook = await ctx.channel.create_webhook(name=ctx.author.name, avatar=ctx.author.avatar)
await ctx.message.delete()
await webhook.send(message)
await asyncio.sleep(0.5)
await webhook.delete()
Error: ```py
Command raised an exception: AttributeError: 'Asset' object has no attribute 'startswith'
full traceback
it isnt a traceback
the error is kinda...
then what bruh
thats the full error
Thanks
how
that's not possible thought
you used an eval?
no?
oh maube avatar=ctx.author.avatar
the console
avatar is an Asset
hm
hmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
Command raised an exception: TypeError: startswith first arg must be str or a tuple of str, not bytes
``` wot
!d discord.TextChannel.create_webhook
await create_webhook(*, name, avatar=None, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a webhook for this channel.
Requires [`manage_webhooks`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_webhooks "discord.Permissions.manage_webhooks") permissions.
Changed in version 1.1: Added the `reason` keyword-only parameter.
wot
do you have any error handlers?
thats the full error
raise error dont do print(error)
hm
bruh
Asset isn't bytes-
do you see the difference?
.read() it 
k
discord/asset.py line 54
async def read(self) -> bytes:```
umm K
hm```py
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 351, in _run_event
await coro(*args, **kwargs)
File "/home/runner/bot/main.py", line 66, in on_command_error
raise error
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 994, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 894, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 176, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: startswith first arg must be str or a tuple of str, not bytes
show what you did
How to make the bot trigger on every message?
in the error handler or the command earlier
!d discord.on_message
discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Warning
Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
hey
code?
ok
if content == 'yes':
await ctx.author.send('Ticket created')
try:
channel = self.bot.get_channel(self.bot.logs_channel.id)
await channel.send('ye a guy made a ticket ig')
except Exception as e:
print(e)
if content == 'no':
await ctx.author.send('Cancelled')```
this is the which does not work
and the var is defined in another file
no it's different file
this is in report.py
and this server_setup.py
hm
wrong indent level
@commands.command and async def should be in same level
wait like this ?
import discord
from discord.ext import commands
import youtube_dl
class music(commands.Cog):
def __init__(self, client) :
self.client = client
@commands.command()
async def join(self,ctx) :
if ctx.author.voice is None:
await ctx.send("You're not in an voice channel!")
voice_channel = ctx.author.voice.channel
if ctx.voice_client is None:
await voice_channel.connect()
else:
await ctx.voice_client.move_to(voice_channel)
@commands.command() async def disconnect(self,ctx) :
await ctx.voice_client.disconnect()
def setup(client):
client.add_cog(music(client))
no
what u did in join
they're in the __init__ function too
!indention
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
@commands.command()
async def
man I rly am dumb I still cnat get it
u did like
@commands.command()
async def
^ # there shouldnt be a space
maybe try to learn basic python before going into discord.py
;-;
async def disconnect(self,ctx) :
await ctx.voice_client.disconnect()```
same error
then learn basics
ok
u just copy pasted the code from somewhere thats why
this is why you shouldnt copy paste codes

who tf even invented copy pasting?
Hi anyone knows how to use same command and add arguments on it ?
believe me or not I am rn watching an tut to make an discord bot
I have fixed it
phew
i think the setup indent is a bit big
like grouping commands?
and by a bit i mean a lot
Exemple: {prefix}(command name) (specific text here)
And i want to use the command name multiple time but add different specific text
your indents are wrong
please learn python before discord.py and don't go to youtube tutorials
anyone ^^
!indents
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
Guys what’s the best way to learn coding bots, I’ve seen heaps of tutorials for things like moderation bots and things but nothing that I am aiming to do.
In order to work with the library and the Discord API in general, we must first create a Discord Bot account.
Creating a Bot account is a pretty straightforward process.
anyone ^^
Bruh
yes lol
i watched that video
Define the variable
wait is it done ?
i did
its cringy he doesnt even explain what the code does?
!intents
scroll down the chat from there
?
^^
discord.Intents.all() is capitalized
Its defined in an else. So its only going to exist if a very specifc piece of ccode runs
ye that specific piece of code ran
bro,...
No offense, but the error says otherwise. Can you add some print statements after where you define it?
is the bot in the vc is the bot playing music?
no
I used the command with the prefix
and an yt vid link
!ytdl
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)
ok
no i cna ban u with that but im nice
is the bot in the vc? Is the bot playing music?
:o now the new guy do be dm advertising
No
send me screenshot ill report that for you :)
me too
then do it then lol
is there any way to get the list of all the channels names in a particular server? using discord.py
@valid perch
Bruh my prefix is "+" so i used +play (song link) and erros pop up in my console and bot never joins vc
!d discord.Guild.channels
property channels: List[GuildChannel]```
A list of channels that belongs to this guild.
Nice. Don't see any errors in that new log of yours so thats good to know its working 👌
oh so the cmd is discord.Guild.channels right?
bruh
no
do +join first??
ok
wai
ofc it says nonetype has no attr play it isnt even in a vc lol
No, get the channels attribute of your Guild object
wai it works
channelname = ", ".join([channel.name for channel in guild.channels])
oh let me try
Stop the spoonfeed maybe? You're not helping anyone 
join command dosent exist
Thanks
dm
no
it won't work
sori
here
Copy pasting thie exact code will get you an error
As per usual when people spoonfeed
@frozen forum here
And just help nobody
yeah, that didn't work
so what do I do now?
Use your python knowledge
And do this
you need to await it
i did tho
yeah but how to get that channel attribute?
await self.open_account(ctx.author)```
ohhhh
should I do it like this? guild.channels
with self , or Balance.open_account
You use .channels on your Guild object
There's nothing more I can explain
oh
It's pretty much self explaining
yeah it is
I'm getting a list like this
[<TextChannel id=889528021076283424 name='other-servers-you-should-check-out' position=5 nsfw=False news=False category_id=891448181433466931>, <TextChannel id=891786097858854993 name='giveaway-payout' position=6 nsfw=False news=False category_id=891448181433466931>, <TextChannel id=893273251285970954 name='shop-and-trading' position=7 nsfw=False news=False category_id=891448181433466931>, <TextChannel id=891506761847148544 name='poke-show-off-january' position=8 nsfw=False news=False category_id=891506620494921739>, <TextChannel id=891506852205043722 name='undertale-show-off-febuary' position=9 nsfw=False news=False category_id=891506620494921739>]
is there any way to fetch that name of each channel?
Iterate through all the elements in the list and get the .name attribute of each of these
oh thanks, that actually works!
:)
pass self
Or Remove self from get_bank_data
it gives more errors
It's not required there
yeah its technically not required
wait no its in a class innit
its inside a class
im blind
whats line 25
but classmethods usually have cls as their first arg
nothing
did you make sure to reload your code
also users will be a coroutine object in your code
and there is no reason to make get_bank_data an async function
and im sure open_account doesn’t have to be async too
but i need to fix the issue atm
how do i check if a command is invoked
