#discord-bots
1 messages · Page 696 of 1
i'm pretty sure is that she/he/they are trying to get like a # prefix
they did it
oh
.. read what I just said above
now have a nice day cool people
i did 🚎
saaame problem 2 commands works
try closing all instances of your bot
bruh
no me
y'all liars
yes you are right @slate swan this is the issue
big bruh moment
I KNOWWW BUT I DONT REMEMBER WHAT I HAVE THE BOT RUNNING IN OTHER HOST
are you using VSCode?
reset token
in the menubar go to terminal and then new terminal, you'll see 1-2 tabs named "Python", those are the tabs that all the bot terminal stuff and stuff goes to
gud idea
no. they said they host it
yup, caeden's answer is definitely something of a correction thrn.
Either that or he just restarts the bot properly lol
lmao yes
just replace self with client
bot*
on_ready does take no params tho redstone is right
what i do
something like bot.user
eh misread it
yeah, and you replace self.user with bot.user if i am right
!d discord.ext.commands.Bot.user
property user: Optional[discord.user.ClientUser]```
Represents the connected client. `None` if not logged in.
yes, alright here's the confirmation that this will probaly not work ☠️
it's the latest message python sent in this channel
so what i can do
Discord bots arent meant for people with basic knowledge or below, concider reading a book in python or something similar before these kinds of projects
🤦♂️ i already told you
im not english
this
why did you add bot in the parameters for on_ready?
you would not have been able to make the event
because you don't have bot, but you alr do so no need the bot
because im dumb
liar
thanks this works
np but next time learn python
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
yuh then why did you jump directly to a discord bot project? u have no idea what ur doing
you need more knowledge if you want better bot
but did you actually make a paginator?
:cap: 🧢
what is paginator
paginator = react to a message with arrow and the thing changes
a website?
ohh i use a command what i see in some docs
oh
yeah alright got it but next time focus more on learning python, don't straightly go for discord bots
thanks
np
byeee
hi, im working on a bot that will list info about every server its in
but whenever it gets to invite code it does this
does anyone know a way to make it print the invite codes to the server?
or better yet, make invite codes for that server
token = input("token: ")
prefix = "?"
import discord
from discord.ext import commands
from discord.ext.commands import Bot
bot = commands.Bot(command_prefix=prefix)
bot.remove_command("help")
@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print(discord.__version__)
print('------')
print('Servers connected to:')
for guild in bot.guilds:
print("name:")
print(guild.name)
print(" ")
print("id:")
print(guild.id)
print(" ")
print("owner id:")
print(guild.owner_id)
print(" ")
print("member count:")
print(guild.member_count)
print(" ")
print("invite codes")
print(guild.invite_code)
print(('------'))
bot.run(token)
here is the code^
why there are differences in formatting in desktop and mobile when bot sends an embed? For ex, ** ... ** bolds the text in desktop. but in mobile, its printed as is
!d discord.TextChannel.create_invite
await create_invite(*, reason=None, max_age=0, max_uses=0, temporary=False, unique=True, target_type=None, target_user=None, target_application_id=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates an instant invite from a text or voice channel.
You must have the [`create_instant_invite`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.create_instant_invite "discord.Permissions.create_instant_invite") permission to do this.
the main point of the tool is to find public tokens and use it to get in contact with the owner
cuz someone could take that same token and 
that's not related to disoord bots?
this happens when I send embeds through discord bots
huh alright let me see, definitely an issue with your discord app then
ok
nah , discord on desktop and mobile are different
Same thing happens with hyperlinked text in embeds too
yeah. is there any fix because I have seen some bots which handles bold text in embed both in desktop and mobile
oh
would it be like this?
because this is all i get as a result
Don’t put the asterisk as a arguement
hey anyone know how i can email a user if the user is verified?
like, how do i get their email and check if they are verified?
pretty sure u can't get an account's email
hi
I want to make a daily streak command
my code
import datetime
from datetime import datetime, timedelta
@client.command()
async def daily(ctx):
with open ("streak.json","r") as f:
data = json.load(f)
streak=data[f"{ctx.author.id}"]["streak"]
last_claim_stamp=data[f"{ctx.author.id}"]["last_claim"]
last_claim=datetime.fromtimestamp(float(last_claim_stamp))
now =datetime.now()
delta = now-last_claim
print(f"{streak}\n{last_claim_stamp}\n{last_claim}\n{now}\n{delta}")
if delta< timedelta(hours=24):
await ctx.send('YOU ALREADY CLAIMED YOUR DAILY in 24 hours')
return
if delta > timedelta(hours=48):
print('streak reset')
streak = 1
else:
streak+=1
daily = 45+(streak*5)
data[f'{ctx.author.id}']["streak"]=streak
data[f'{ctx.author.id}']["last_claim"]= str(now.timestamp())
with open("streak.json","w") as f:
json.dump(data,f,indent=2)
embed = discord.Embed(title="Daily", colour=random.randint(0, 0xffffff), description=f"You've claimed your daily of **{daily}** \n Not credited")
embed.set_footer(text=f"Your daily streak : {streak}")
await ctx.send(embed=embed)
My doubt - this requires a entry it json file , how can i automate that
I tried making a function but error - it adds timestamps before the command execuetes
so the bot says you already claimed your daily
Pls help
what would i put instead then?
just a question, what if your bot goes offline ;-;
nothing
remove it
yea but now it does another funny
that's just use to indicate args and not actually put it in the func
File "main.py", line 11
invite = await create_invite(reason=None, max_age=0, max_uses=0, temporary=False, unique=True, target_type=None, target_user=None, target_application_id=None)
^
SyntaxError: 'await' outside function
mhm, use a db first of all
I cant
why
btw can you help me in this
I can but still
cuz i dont know db
learn
would need to be in async function or do asyncio stuff
and too lazy
How to make your bot know who joined and left on the vs code terminal?
on_member_join?
yes
yes and on_member_remove?
yes
Hi, I'm new to git. I'm currently making a bot on Github. I just forked the Codes. How do I activate the codes on Github?
idk
ysh
you can't run code on github
But i got the codes
this is not the appropriate channel
Look i maded this bot
but how do i make the bot work?
good
So do you know?
is disnake a good library to use in replacement for the depreciated discord.py?
copy code on a ide
ok
maybe
is it the print function?
yes
yesh
wat r u trying to do
and what next?
no cuz many library has dependencies which is ofc discord.py
So in the terminal of the vs code i want it to where itll say who joined my server
run it with your bot token
but in the terminal of vs code
d.py is depreciated tho
@<bot/client>.command()
async def on_member_join(member):
member.kick(reason="Enjoy")
print(member)
like import the github into replit?
yes
You made the bot?
this but without member.kick
i forked
lmao
Ok, I was about to say. 
see my bot logging sys
but you said you "maded' the bot ;-;
💀
maybe i speeled wrong
wowooowowoowowow
my english is not good
;-;
.-.
its alright
ohh yes i have done this code to where a certain time frame if a member doesnt react to the reaction role it will get the member kicked
ohmg
but really it doesnt really work
omg @slate swan your bot is toooo big
mk
async def on_member_join(member):
guild = client.get_guild(730651046459998218)
channel = client.get_channel(885464532959526913)
Myembed = discord.Embed(title= f"Welcome",
description=(f"Welcome {member.mention}, You are member {guild.member_count}. \n Please enjoy your stay here and dont forget to read the await [#904279966693355550](/guild/267624335836053506/channel/904279966693355550/)"))
Myembed.add_field(name="Account Created at:", value=f"<t:{int(member.created_at.timestamp())}:R>" , inline=True)
await channel.send(embed=Myembed)
await member.send(embed=Myembed)
print(member)
roles_list = ["Unverified","•.¸¸.•:Colours:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Verification:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Age:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Gender:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Sexuality:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•",
"•.¸¸.•:Distance:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Ethnicity:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Hobbies:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Relationship:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Location:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•",
"•.¸¸.•::•.¸¸.•`Seeking`•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:DM:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Levels:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Games:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•"]
for roles in roles_list:
role = discord.utils.get(member.guild.roles, name=roles)
await member.add_roles(role)
def check(r: discord.Reaction, u: Union[discord.Member, discord.User]):
return u.id == member.mention.id and r.message.channel.id == member.channel.id and \
str(r.emoji) in ["\U00002705"]
try:
reaction, user = await client.wait_for(event = 'reaction_add', check = check, timeout = 15.0)
except asyncio.TimeoutError:
await member.send(f"{member.mention}, please react with :white_check_mark: on this message in 15 seconds")
return
else:
if str(reaction.emoji) == "\U00002705":
return
member.kick(reason="Enjoy")
await member.send(f"{member.mention}, you didnt react with a ✅ in 45 seconds.")
await member.send(f"**{member.mention}**, Sorry you got kicked")```
this is my code
!paste
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.
its modmail
IK
in invite links thers an option to automatically kick the user if they dont get a role after a certain time
i gotta coppy some inspiration
shouldnt have to code ur bot to do it
?
wdym?
I want my bot to kick the member for me
yes but i dont have any experience in invite making
make another function with time loop
ohh damn i cant change my name on this server
it will check the desired things
nice
change yiur pfp only
and u may not want that
@slate swan starred your repo
ok
lemme see
k
so
yes :/
add your token in client.run or bot.run
ok
my eyes going brrrrrrrr
interesting interesting
i think at the bottom take out the else after the try except
else is for any other error
hey someone help me too
ask away
here
asked
do you guys know theme park tycoon on roblox
NOT OFF TOPIC
don't have experience with datetime :(
so whats thr problem?
i want to make a roblox username searcher
see below it
ok
i didnt see the name of "client.run or bot.run " .
lets see if that works
i wrote my prob
api
what
i am bad at api
i can get apis but cant use it
myself
;-; then best of luck
you can learn
OK
it'll make your life easier
where do i add my token @graceful mulch i didnt saw "client.run or bot.run " .
in the last of main.py
bot.run('ur token here)
you just need common sense to use APIs ngl
ok
with your token
fr lol
xDD
may i ask a question too?
no
:/
this?
how do i get api
yes add token
What’s your question
betweeen brackets
{'coord': {'lon': -74.006, 'lat': 40.7143}, 'weather': [{'id': 800, 'main': 'Clear', 'description': 'clear sky', 'icon': '01n'}], 'base': 'stations', 'main': {'temp': 7.76, 'feels_like': 7.76, 'temp_min': 4.63, 'temp_max': 9.44, 'pressure': 1022, 'humidity': 39}, 'visibility': 10000, 'wind': {'speed': 0.45, 'deg': 262, 'gust': 2.68}, 'clouds': {'all': 1}, 'dt': 1639811066, 'sys': {'type': 2, 'id': 2039034, 'country': 'US', 'sunrise': 1639829707, 'sunset': 1639863028}, 'timezone': -18000, 'id': 5128581, 'name': 'New York', 'cod': 200}so i have all this data, but im having a hard time figuring out how to print it like this:
\ / Partly cloudy
_ /"".-. +10(8) °C / +50(46) °F
\_( ). ↘ 15 km/h
/(___(__) 16 km
0.0 mm```
if someone could help i'd appreciate it
;-; use an embed, it would be better
this is like YAGPDB's weather command
lol
you will have to say it many times cuz this is a amazing community
i can use an embed but idk how to set the thumbnail as the description of the weather
long strings and /n’s ?
i can do tht
im just asking how do i get the ascii art
according to the weather
use api
Well it doesnt kick me from the server still
this info is from an api LOL
read the docs, they must have a link to use the weather codes and fetch an image
oh
In case you would like to make a weather command using discord.py and have a cool addition to your bot, I got you covered, I have answered below on how to create a weather command in discord.py.
this is better
see this
try to help, not seek alternatives
i'll do that, but im pretty sure there isn't ;-;
;-; fine
i cant
then don't
he sent the same api LOL
oof
@graceful mulch thats what im using
Idk, I
lol
I'll just leave, best of luck
Yeah no idea about the art Nexxel
bye!
yeah lol
ik i said i dont have example in apis
tc tc
i've been stuck on that for 2 days now
@red sundial api name?
openweathermap
oh, openweathermap
yeah pretty cool api
they have a service to fetch images
do they
wait for 5 mins
sure
help i added the bot to my server and when i run it i doesnt work
here you go
read the docs
spent far too long just creating a damn utility function for dropdown menus, allows handling upto 375 items ; - ;
when will a user need to select that many items tho . - .
sure, ping me
where
@graceful mulch hey it doesnt work
what
i putted the token at the ( token)
dm
@red sundial https://openweathermap.org/weather-conditions
done
okay
I have no idea why this guy is even asking here. There’s setup instructions in the repos readme.
There’s even a dedicated support server for modmail support
just leave it
So you wait for their reaction. If you get the asyncio.TimeoutError then you kick them. If they react then you check if it’s the correct reaction. If not you kick them
That's cruel
xD
@upbeat otter https://nexxel.with-your.mom/Discord_peMLapkvls.png
lets gooo
thank you so much
its alright
Nice
Nice domain though
yeah
LOL
you can add this too Descripition
clear sky
Temperature(C)
0°C
Humidity(%)
59%
Atmospheric Pressure(hPa)
1024hPa
likediscoription
;-;
now its just not changing the "invite" variable
what are you trting to do here?
i am sending a message to a channel webhhok
oh interesting, i have no idea about that lol
im still a bit stuck
class discord.Webhook```
Represents an asynchronous Discord webhook.
Webhooks are a form to send messages to channels in Discord without a bot user or authentication.
There are two main ways to use Webhooks. The first is through the ones received by the library such as [`Guild.webhooks()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.webhooks "discord.Guild.webhooks") and [`TextChannel.webhooks()`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel.webhooks "discord.TextChannel.webhooks"). The ones received by the library will automatically be bound using the library’s internal HTTP session.
The second form involves creating a webhook object manually using the [`from_url()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Webhook.from_url "discord.Webhook.from_url") or [`partial()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Webhook.partial "discord.Webhook.partial") classmethods.
For example, creating a webhook from a URL and using [aiohttp](https://docs.aiohttp.org/en/stable/index.html "(in aiohttp v3.7)"):
💀
not nice at all
idk what you mean
then why ask in this channel 
How can I get the verified bot developer badge? By getting my bots verified?
You can't
Not possible anymore
not anymore
Why?
Discord stopped giving badges for a long time
Huh.
Then why?
what why
i need someone help me fill modules
?????
The reasons are long but one of the main reasons was, that bot developers where making bots only to get the badge
This message
local ur mom = workspace.A ```
😕
Honestly I understand your frustration, when I began coding my own bot I did it mostly for my community but also to in the future publish it and receive that badge.
There were many reasons as to why Discord stopped giving badges but the main reason was people selling their accounts or abusing the system to get the badge.
You should never work hard just to get something like a badge, your bot will still have the verified badge on it.
Thinking about it, I think they should just overall delete the badge from every developer. Their solution was to stop giving out badge due to abuse and basically said that it’s just a badge, well then take it away from everyone that obtained it. But that’s also selfish, so idk — hard topic
i can't find: copy , re , string modules version
its in-built in python
they are inbuilt
they have no version afaik
you dont need to install them
in-built
just use, pip3 freeze > requirements.txt
you dont need to type it in that file
;-;
Most modules have a version() method
Bruh
why are people so stubborn? I said its in-built, YOU DONT NEED TO TYPE IT IN THAT FILE
how
bro
Haha
go touch grass @boreal ravine
@slate swan I recommend you read this: https://docs.python.org/3/library/ and #rules
help me fill version
You were just told. You don't need to specify built in libraries
but someone said i need to put it
Nobody did
That's why you don't DM people
what?
Misinformation cannot be corrected
ok
"Misinformation cannot be corrected" said by @final iron
u fucking weirdo u said that
May I ask, how old are you?
!mute 699457437929046047 Investigating.
:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1640067537:f> (59 minutes and 59 seconds).
I would suggest you check #data-science-and-ml
lmao
I'm so confused on why he was so overly aggressive
lol
Does disnake support timeouts
How do we add Add to Server button our Discord bots?
afaik not yet, they just released try checking the github for any PRs related to timeouts
I think that PR adds it
Go to ur bots page in the discord dev page and set up the perms
Thanks man, you saved my life.
what permission is required for giving/removing roles from a member?
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
I get this error
@bot.command()
@commands.has_permissions(manage_roles=True)
async def verify(ctx, member: discord.Member):
role = discord.utils.get(ctx.guild.roles, name="verified")
await member.add_roles(role)
await ctx.reply(f"Succesfully Verified {member.mention} \u2705")
``` When I run this code
these are the permissions my bot has
is ur bot role above the role u wanna give
No. Does hierarchy matter even if my bot has Admin permissions ?
yes
oook
so, when the bot joins a server, its role is automatically in the last as per hierarchy
so how do I change its role hierarchy?
Have an admin/owner do it
oh ok.
Lmao that's weird though
They got aggressive for no reason
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: add_field() got an unexpected keyword argument 'description'
add_field(*, name, value, inline=True)```
Adds a field to the embed object.
This function returns the class instance to allow for fluent-style chaining.
oh
how to make it like a normal embed
like description="Shrek loves donkey!"
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
discord.Embed(description="")?
@bot.command(name="form")
async def form(ctx):
embed = discord.Embed(title="Please fill out this form:")
discord.Embed(description="")
await ctx.send(embed=embed)
it only sends "Please fill out this form:"
for colour you would need to use Embed obj afaik
Is there any way to find that bot is going to exceed limit and stop the bot for one minute
discord.py does that for u automatically
But it is stopping that bot preventing it to move further. I need to stop executing the command alone
so uh I need a bot to copy what you said after the command like:
!say InsertTextHere
I can do it without the !say but idk how to get it to get the text after it
i using this library to send webhooks to a channel
https://pypi.org/project/discord-webhook/
i want to just send one webhook and keep editing it. i want to save the webhook id to a file so it doesnt get lost when script stops and then use it next when script start
can you make me understand how it can be done
you usually have argument for that text, right?
import time
time.sleep(seconds)
or you can do that with asyncio
yh
@bot.command(ctx,*,args):
time.sleep is not good for discord bots, it's blocking
so just use the value of argument
yeah but it's still an option
that works?
that stores the value
alr thanks
well not exactly store it, but it's the value given to argument
but what about simply copying whatever comes after the command?
webhook = DiscordWebhook(url='your webhook url', content='Webhook content before edit')
sent_webhook = webhook.execute()
webhook.content = 'After Edit'
sleep(10)
sent_webhook = webhook.edit(sent_webhook)
i want to be able to edit this message when next time script starts ? anyone pls help
problem is how do i save the repsonse "sent_webhook" to be used later
Traceback (most recent call last):
File "C:\Users\shimo\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\shimo\Documents\bot1\levelsys.py", line 25, in on_message
if message.channel.id in talk_channels:
TypeError: argument of type 'int' is not iterable
Ignoring exception in command rank:```
help
code?
is "sent_webhook" a message obj?
Hey @sonic gale!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
Hey @sonic gale!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
no not entirely
async def on_message(self, message):
if message.channel.id in talk_channels:
stats = levelling.find_one({"id" : message.author.id})
if not message.author.bot:
if stats is None:
newuser ={"id" : message.author.id, "xp" : 50}
levelling.insert_one(newuser)
else:
xp = stats["xp"] + 5
levelling.update_one({'id':message.author.id}, {"$set":{"xp":xp}})
lvl = 0
while True:
if xp < ((50*(lvl**2))+(50*lvl)):
break
lvl += 1
xp -= ((50*(lvl-1)**2)+(50*(lvl-1)))
if xp == 0:
await message.channel.send(f"{message.author.mention} you leveled up to **level: {lvl}** <3")
for i in range(len(level)):
if lvl == levelnum[i]:
await message.author.add_roles(discord.utils.get(message.author.guild.roles, name=level[i]))
embed = discord.Embed(discord=f"{message.author.mention} you have recived role **{level[i]}** <3", color=0xC4A8B4)
embed.set_thumbnail(url= "https://cdn.discordapp.com/emojis/803218181694685204.png?size=96")
await message.channel.send(embed=embed)```
only the part where error happens, in this case the on_message part
its a response of a webhook sent..it contains all the info like webhook content , ids etc
oh i think i got it
you can use botvar to save the value for later as example
but depends a bit of way you want to save it
how to put hex colours in embed?
do you have the hex colour alrd?
if yes just pass it to colour=hex here
stats = levelling.find_one({"id" : ctx.author.id})```
that # will fail it
?
async def rank(self, ctx):
if ctx.channel.id == bot_channel:
stats = levelling.find_one({"id" : ctx.author.id})
if stats is None:
embed = discord.Embed(description="You havent sent any messages </3")
await ctx.channel.send(embed=embed)```
help pls
stats = levelling.find_one({"id" : ctx.author.id})
File "C:\Users\shimo\AppData\Local\Programs\Python\Python310\lib\site-packages\pymongo\collection.py", line 1114, in find_one
for result in cursor.limit(-1):```
no
0x[hex]
0x00ffff
#db7c16 would be 0xdb7c16
got it thanks!
or just int('00ffff', 16)
embed = discord.Embed(title = 'bot creator', description = '**shimo#0001**', color=0xC8E9E9)
example
NOW
someone help me with my shit
ty
just be patient :/
Or just 0x00ffff
ok i figured it out
https://www.thoughtco.com/using-pickle-to-save-objects-2813661
saved the obj in a pickle file
how do u create your own events?
like I want something like on_message() but I want to define it
how to search for a specific message using the bot
i want to have a command called "banwave" and it'll search for a list of keywords, get it, send it to logs channel along with user that sent it then ban the user
what will the event be triggered by?
#discord-bots message help please
lets say I want to DM someone and so he says !dminfo
Is there any other way than just using the inbuilt events?
#discord-bots message help please
so u want the bot to dm someone once they use the !dminfo command?
@bot.command()
async def bread(ctx, arg):
await ctx.send(arg)
can I make it send the given messages to another channel?
read dpy docs FAQ
theres an example on how to do that
k
Member object has an attribute send which u can use to dm the member when they use the command
#discord-bots message please help
my question is how to create a custom event just to do this?
don't know
u can right click, copy link or something, and the combination of numbers u see should be the emoji ID
I can't use animated emojis
asyncio.Event
Can't copy link from the tab itself
¯\_(ツ)_/¯
@slash_command(guild_ids=[918349390995914792], description="Shows information about a user")
async def ui(self, ctx, member: discord.Member=None):
if not member:
member = ctx.author
name, status = str(member), member.raw_status
date_format = "%a, %b %d, %Y @ %I:%M %p"
created_at = member.created_at.strftime(date_format)
joined_at = member.joined_at.strftime(date_format)
roles = [role for role in member.roles]
rr = " ".join([role.mention for role in roles])
embed = discord.Embed(title=name, description=status, colour=member.colour)
embed.add_field(name="Origin", value=created_at, inline=True)
embed.add_field(name="Joined", value=joined_at, inline=False)
embed.add_field(name="Roles", value=rr)
embed.set_thumbnail(url=member.avatar.url)
await ctx.respond(embed=embed)
```when i use the command in the status it shows offline, but im not offline lol
is there anything wrong here?
!d discord.Member.raw_status
property raw_status: str```
The member’s overall status as a string value.
New in version 1.5.
hm
yeah
property status: discord.enums.Status```
The member’s overall status. If the value is unknown, then it will be a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") instead.
this also showed offline when i typecasted it
are you sure your status was online?
you need intents
!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.
i have these
you need presence intents
yeah i have it enabled in the portal
and in my code i have this
ye it shows offline for me as well
so is this is a bug lol
just get the member again
using member = ctx.guild.get_member(member)
its fixes the issue
I tried to install a requirements.txt file but i get this error
lemme try
this is not related to #discord-bots
more like a replit bug
so i put this line before i store everything in the variables right?
yea
@slash_command(guild_ids=[918349390995914792], description="Shows information about a user")
async def ui(self, ctx, member: discord.Member=None):
if not member:
member = ctx.author
member = ctx.guild.get_member(member.id)
shows a weird error
it returns None from that I guess
it says NoneType object has no attribute 'raw_status'
yeah
@client.command(name='say_no') async def say_no(ctx): await ctx.send('No')
why does it not work?
wdym by not work
client does not have .command
I gave the command !say_no and didn't get a reply from the bot as I intended to do with it
are you using Client?
!d discord.ext.commands.Bot.command
@command(*args, **kwargs)```
A shortcut decorator that invokes [`command()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.command "discord.ext.commands.command") and adds it to the internal command list via [`add_command()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin.add_command "discord.ext.commands.GroupMixin.add_command").
I have a bot I forgot to change the name
client = commands.Bot(command_prefix='!', intents=intents, case_insensetive=True)
did you add that before if not member or after it?
member = ctx.guild.get_member(member) what is even happening here?
yeah i don't understand it
member = member or ctx.author shortest method.
they are using slash commands , the member argument they get always returns the value of status offline , so im asking to just get the member object again
so where does this line go
sent that already.
in the if statement?
I get that but it would still take an id.
not important
..?? Okay i won't intervene.
bro im so confused lol
edited
try fetching it
What’s wrong
the issue was that I added it after on_message()
Code
the issue has been solved now
Ok ill eat breakfast
Do decorators work on commands?
wait. wtf am i on about. nvm. im being silly. ofc they do lol
everyone be like lets make silly errors and solve them by ourselves lol
yeah
I thought of a solution to my issue and was like 'but will it work'
then scrolled up and was like 'derp. i use decorators already to run my bot'
Hey I need help with my Python bot
Hey @slate swan! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me
Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!
Bruh
I mean. the bot has a point
it really has, it is useful
If I had your token and didnt like you I'd totes get your account banned
Just remove the token. Put a few x's when you paste the code
import dicord
from dicord.ext import commands
client = dicord.Client()
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send('Hello!')
It keeps saying "module dicord not found"
'dicord' is not a module
you have to install the lib
it's 'discord'
oh dicord lol
Freecodecamp's tutorial wrote dicord...
LOL
freecodecamp is wrong. naughty.
nice one
people make mistake
import discord
from discord.ext import commands
client = discord.Client()
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send('Hello!')
you copy pasted the code from there?
Changed.
yeah it should work now
I didnt do shit @tawdry perch
wait wrong reply
did u add client.run(token)
I did
Oh so wrong. golly gosh i get the heebies heebies looking at that.
whats the error?
send the traceback from the console
@slate swan paste the full code
Hey @slate swan! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me
Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!
No errors
import discord
from discord.ext import commands
client = discord.Client()
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send('Hello!')
client.run("token")
good
First @slate swan you will want to read this documentation, it's very good and tells you everything you need to know about the discord.py api
Secondly, I can send you a template to get you started if you want. But the rest you need to figure out.
Ok
yeah read the docs
Ignore the search. that's just what I book marked it as.
I tried reading https://discord.js.org but I do not understand it
bruh
look at the whole video, he tells u how to find and add token
That's using Javascript. this is python.
you're coding in python
maybe you should learn the basic of Python before starting discordpy
It's different
No I'm going to make a music bot
Sir. I skipped the basics and ran head first into a brick wall and now I am having a blast. sure there's bleeding, but at least I still have all my toezs
I think u should make simpler things before working on this project
yeah but he even read the wrong documentation.
True true
you should learn python basics first, discord.py is an intermediate library
if you just wanna make a music bot
then just find some code on github and self host the bot
what do you mean lol?
No examples. Just google 'github discord music bot'
just go and search python beginner projects
nah he wants to 'code' a music bot
I'll find one
yeah you don't need to code then
dont use discord.Client 
If you need commands, use the commands extension.
Docs: https://discordpy.readthedocs.io/en/latest/ext/commands/commands.html
Why should I use the commands extension?
- Prevents spaghetti code
- Better performance
- Easy handling and processing of command arguments
- Argument type converters
- Easy sub commands
- Command cooldowns
- Built-in help function
- Easy prefix management
- Command checks, for controlling when they're to be invoked
- Ability to add command modules via extensions/cogs
- Still able to do everything you can do with
Client
😮
Did i ask?
ok rude
bruh
yeah just do this if u want to just make a music bot
nah dont use replit as well
he doesn't care lol

exactly, he just cares about the end product
Hey that's how I feel when I steal NFTs
lmao
maybe that's why my friends left me? 🤔
?
What
what what?
Bruh
Alright we're getting off topic here.
if you actually cared learn python basics then move on to dpy
Focus guys. We're professionals here.
Focus on the task at hand. Making discord bots.
yeahh
https://github.com/SudhanPlayz/Discord-MusicBot https://github.com/jagrosh/MusicBot https://github.com/ZerioDev/Music-bot https://github.com/eritislami/evobot Which is good
An advanced discord music bot, supports Spotify, Soundcloud, YouTube with Shuffling, Volume Control and Web Dashboard with Slash Commands support! - GitHub - SudhanPlayz/Discord-MusicBot: An advanc...
🎶 A Discord music bot that's easy to set up and run yourself! - GitHub - jagrosh/MusicBot: 🎶 A Discord music bot that's easy to set up and run yourself!
A complete code to download for a cool Discord music bot ! - GitHub - ZerioDev/Music-bot: A complete code to download for a cool Discord music bot !
the first one is pretty good
i think that person has a video on how to host it as well
Ok
is there a way to get today's date then send into a message without it being an epoch?
do we have any offtopic channel on this server?
!ydtl
Breh typo
!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)
You're welcome (:
yeah half of it is working
Too bad
Is the status fixed?
yeah only when the mention is there
So when you pass a user id it does not work?
Hey @loud junco!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
@slash_command(guild_ids=[918349390995914792], description="Shows information about a user")
async def ui(self, ctx, member: discord.Member=None):
if not member:
member = ctx.author
name, status = str(member), member.raw_status
date_format = "%a, %b %d, %Y @ %I:%M %p"
created_at = member.created_at.strftime(date_format)
joined_at = member.joined_at.strftime(date_format)
roles = [role for role in member.roles]
rr = " ".join([role.mention for role in roles])
embed = discord.Embed(title=name, description=status, colour=member.colour)
embed.add_field(name="Origin", value=created_at, inline=True)
embed.add_field(name="Joined", value=joined_at, inline=False)
embed.add_field(name="Roles", value=rr)
embed.set_thumbnail(url=member.avatar.url)
await ctx.respond(embed=embed)
```this is my code rn, works it a member is mentioned, doesn't work when a member is not mention(displays their activity status as 'offline')
Interesting
go on
lemme screenshot the error
I have no idea why that does not work
same lol
too complex for me 🥵
show how you set the intents
should be something like
intents = discord.Intents.all()
intents.members = True
bot = commands.Bot(command_prefix=PREFIX, case_insensitive=True, intents=intents)
{datetime.datetime.utcnow()}
datetime not defined
define it then
import datetime
yeah
help
i have no idea how to fix that lol
When you get it working can you ping me, I really want to know why that did not work
alright
sure
i know why it isnt working
Ty 👍
thanks btw
can someone tell me the code for giving a role cause dpy discord has some good staff

!d discord.Member.add_roles
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
- they arent a staff
- they're probably stressed
- just go to the channel, that channel is a help channel
and if you wanna give a role
!d discord.Member.add_roles here
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
@boreal ravine what is atomic?
Open the docs page
is *roles meant to be the role?
yes
Yes, a list of roles or single role
do i provide the role id or the role @
Role obj
4 what
nvm
^
you were using it in general not playground 💀
read channel description when
help chanel
you dont use self serve tags in help channels obviously
whats the thing for having a role, for example for permission
server_permissions.administrator
but idk the how you do it for roles
and also can someone tell me what the thing is called
Yeah you broke the rules and then you were a jackass
so i treated you as such
dont call me bro either
grow up
alright dickhead

You didnt follow the rules
you started to flood help
they told you to go to the proper channel and you refused
can you not?
and sicne you clearly can't read
the "search elsewhere" was for you:
:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1640086573:f> (59 minutes and 59 seconds).
@spice warren This is no place to bring up off-server drama, please don't do so again - you can report problematic users to us via @novel apex.
just tried it in my bot , you would actually have to fetch the member instead of getting it
Sorry about this Qwerty.
Traceback (most recent call last):
File "main.py", line 2, in <module>
import discord
ModuleNotFoundError: No module named 'discord'
what
this is replit
do pip install discord.py in the terminal
;-; ok
you can do that in replit too
there is a shell option.
@slate swan mute me for 10 minutes pleaseeeeeeeeee
We don't hand out infractions upon request 
OK
PyCharm is amazing
Does anyone know why i'm getting this error
File "main.py", line 119, in load_waiting
waiting = json.load(e)
File "/usr/lib/python3.8/json/__init__.py", line 293, in load
return loads(fp.read(),
File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 23 (char 22)
The code
def load_waiting():
with open("data/waiting.txt", "r") as e:
global waiting
waiting = json.load(e)
This is what's in the file
[[686225969467752479, 'Hoster']]
ye i just ran it on pycharm
an array
its a 2d array
also you did data/waiting.txt it should be data\waiting.txt
JSON shouldnt be an array.
and txt files have nothing to do with json
you can't do json.load a txt file
that's odd cause its been working for a whille like that
i restarted my bot today and it just didn't want to work
well you did something with the txt file
you shouldn't do json with txt
it doesn't work like that
i'm 99% sure this is wrong
cause that's not how files work
\ is an escape character ( used with escaped character )
what does that even mean
characters like \n \u200b which are used in strings
**```
import discord as d
bot = d.Client()
@bot.event
async def on_message(msg):
if msg.author == bot.user:
pass
elif msg.content.startswith('b.se'):
channel = bot.get_channel(ID)
await channel.send('welcome to this channel')
bot.run(BOT_TOKEN)
guys if there's no error in this code.... then why it's not working ???
bad import method and dont use discord.Client()
remove "as d" in line 1
If you need commands, use the commands extension.
Docs: https://discordpy.readthedocs.io/en/latest/ext/commands/commands.html
Why should I use the commands extension?
- Prevents spaghetti code
- Better performance
- Easy handling and processing of command arguments
- Argument type converters
- Easy sub commands
- Command cooldowns
- Built-in help function
- Easy prefix management
- Command checks, for controlling when they're to be invoked
- Ability to add command modules via extensions/cogs
- Still able to do everything you can do with
Client
I've not user as d in my original code... dw
and i can't use bot extension cuz my bot works in a different way
this is just an example not the original code
explain a different way
then send the original
try bot = d.Bot(...)
discord.Bot is not a thing
sorry, commands.Bot()
if you're not using pyc~
and from discord.ext import commands
yea
I'm gonna so sarthak = commands.Bot() from now on 😳
@sarthak.command()
sarthak.run() 🏃♂️
with a valid toe-ken passed
import discord
from discord.ext import commands
sarthak = commands.Bot(command_prefix="sarthak!")
@sarthak.event
async def on_ready():
print("sarthak is ready :)")
@sarthak.command()
async def test(ctx):
await ctx.send("sarthak")
sarthak.run(TOE-KEN)
actually I have some custom commands.. like one is !help one is b.s_login and etc
leave that na
lmao
just tell me why my code is not working ??😭
from discord.ext.commands import Bot , when_mentioned
class Dekriel(Bot):
def __init__(self):
super().__init__(command_prefix=when_mentioned)
async def on_ready(self):
print(f"{self.user} is ready ;)")
Dekriel().run()``` ( bad indentation ik ik)
is that all the code you have?
try doing commands.Bot
lmao
also there should not be a space before the comma 🚶♂️
lmao which one?
import Bot ,
why not ```py
if name == 'main':
bot = Dekriel()
bot.run()
ow i see wym py from discord.ext.commands import Bot, when_mentioned here
that should be better
am not doing any importing stuff with it , why is it required there lol?
yeahhh
no
oh then thats fine
if __name__ == '__main__':
dekriel = Dekriel()
dekriel.run()
😏 you still miss a :
no.. there are more custom commands.... but I've send you the part which is not working...
that made no difference
or
well , you should use the commands framework actually
!d discord.ext.commands.Bot
class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
you wont have to change your existing code
from discord.ext.commands import Bot, when_mentioned
import sys
class Dekriel(Bot):
def __init__(self):
super().__init__(command_prefix=when_mentioned)
async def on_ready(self):
sys.stdout.write(f"{self.user} is ready!")
if __name__ == '__main__':
dekriel = Dekriel()
dekriel.run(token)
bad
self.command_prefix would work right?
importing something inside a function is crime 🔪
toxic?
i guess not
error
indents dont match 💀
ok
well this runs completely fine
4 spacing indents are better iirc
yes cause my pc wont allow me to run vsc and discord tghtr lag free
🔪
unless i boot out from windows
discord broke again
nitro
?
nevermind

