#discord-bots
1 messages ยท Page 650 of 1
Tos
No help in this server sorry
So what bout DMs?
How???
Terms of Service. How u should use a service/platform and the rules for using the same
It downloads audios from YouTube which is against ToS
I never used lava link, also would be better to ask in the disnake server
Ok
That is kinda right
As youtube is being a
Terms of service
anyone know why this doesnt pop up choices
@bot.slash_command(description='Pulls a list of up to 30 or more current orders in bazaar!')
async def bazaar(inter, item: str, orders: str = commands.Param(choices=['Both', 'Sell', 'Buy'])):
item pops up and allows u to enter a string, but orders doesnt
Sorry bruv never used choices
INFO:disnake.ext.commands.common_bot_base:WATCHDOG: Watching extensions
anyone know what this means
what lib
disnake
Disnake ofc
it did and was working
except now anytime I start the bot I get this error
I think its supposed to be going to my logging file but idk its not
wait might be bc I set reload=True
async def bazaar(inter,
item: str,
orders: str = commands.Param(choices=['Both', 'Sell', 'Buy'])):
how do I make orders optional wtf
required kwarg afaik
or just make it none
Never used slash
Hmm
This ain't an error
temp_list_4 = ["Please enter your paypal address in the following format: +paypal example@gmail.com", "Please enter your cashapp address in the following format: +cashapp $123example", "Please enter your cashapp address in the following format: +cashapp @exampleman123"]
@bot.event
async def on_reaction_add(reaction, user):
if reaction.emoji == "๐ค":
if user == bot.user:
return
roleid = 915953012818726953
roleobj = user.guild.get_role(roleid)
await user.add_roles(roleobj)
for i in range(0,len(Json_Items)): #It doesn't exist
for x in Json_Items[i]:
if int(x) == int(user.id):
Json_Items[i][x]['Payment Method'].append("Venmo")
json.dump(Json_Items, open("./all_user_rep.json", "w"), indent=1)
await reaction.message.channel.send(temp_list_4[0])
@bot.event
async def on_reaction_remove(reaction, user):
if reaction.emoji == "๐ค":
roleid = 915952966022856725
roleobj = user.guild.get_role(roleid)
await user.remove_roles(roleobj)
for i in range(0,len(Json_Items)): #It doesn't exist
for x in Json_Items[i]:
if int(x) == int(user.id):
Json_Items[i][x]['Payment Method'].remove("Paypal")
json.dump(Json_Items, open("./all_user_rep.json", "w"), indent=1)
await bot.delete_message(temp_list_4[0])```
Is there any way for this to work, or is it not possible?
This just an information log that the cog watchdog has started. That watchdog sees if there has been any change in the cog's code and if it was there, the cog would be reloaded automatically
What's not working...?
doesn't delete the information when you react the second time.
await bot.delete_message(temp_list_4[0])
I'm pretty sure it's not possible
yeah tryna delete a message that was sent in a different function
so like you react to a message:
it prints("Hi")
Then when you unreact:
It removes the ("hi") message
U sure u ain't looking for bot.wait_for?
perhaps
!d discord.ext.commands.Bot.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
This can be used in a command and with this the bot waits for anyone to do something like send a message or react to a message or something
ok but can I delete an original message that has already been sent
U can do
msg = await.ctx.send(...)
await msg.delete()
2021-12-04T06:54:55.987733+00:00 app[worker.1]: aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host lava.link:80 ssl:default [Network is unreachable]
2021-12-04T06:54:55.987744+00:00 app[worker.1]:
2021-12-04T06:54:55.987744+00:00 app[worker.1]: The above exception was the direct cause of the following exception:
2021-12-04T06:54:55.987744+00:00 app[worker.1]:
2021-12-04T06:54:55.987754+00:00 app[worker.1]: Traceback (most recent call last):
2021-12-04T06:54:55.987788+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/disnake/client.py", line 505, in _run_event
2021-12-04T06:54:55.987789+00:00 app[worker.1]: await coro(*args, **kwargs)
2021-12-04T06:54:55.987792+00:00 app[worker.1]: File "/app/main.py", line 72, in on_command_error
2021-12-04T06:54:55.987792+00:00 app[worker.1]: raise(error)
2021-12-04T06:54:55.987793+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/disnake/ext/commands/bot_base.py", line 560, in invoke
2021-12-04T06:54:55.987793+00:00 app[worker.1]: await ctx.command.invoke(ctx)
2021-12-04T06:54:55.987804+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/disnake/ext/commands/core.py", line 929, in invoke
2021-12-04T06:54:55.987804+00:00 app[worker.1]: await injected(*ctx.args, **ctx.kwargs)
2021-12-04T06:54:55.987813+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/disnake/ext/commands/core.py", line 184, in wrapped
2021-12-04T06:54:55.987813+00:00 app[worker.1]: raise CommandInvokeError(exc) from exc
2021-12-04T06:54:55.987831+00:00 app[worker.1]: disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientConnectorError: Cannot connect to host lava.link:80 ssl:default [Network is unreachable]โ
Can someone please help
I am not trying to download youtube videos so it's not against ToS
It has nothing to do with YouTube
I am using SoundCloud
according to the error , ill assume your lavalink server aint running yet
did you start it , sky lover

how do I send DM to a user using their ID
(user isnt in my guild or anything i just have its ID)
run(*args, **kwargs)```
A blocking call that abstracts away the event loop initialisation from you.
If you want more control over the event loop then this function should not be used. Use [`start()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.start "discord.Client.start") coroutine or [`connect()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.connect "discord.Client.connect") + [`login()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.login "discord.Client.login").
Roughly Equivalent to...
Hmm
No, you need to use .login and .connect
run() does the same thing tho
@slate swan can u show me where u r calling client.run()?
So not the same as what they have right now
It automatically connects to the websocket and the API
Can i see?
.login doesn't
Hide your token tho
Talking about run
Yea
how do I send dm to a user using their ID?
the user isnt in my guild or any other guilds
U can't then
Then you can't
no like he isnt in my guild but maybe he might be in a guild which the bot is
Indent the run outside of the event
!d discord.Client.get_user
get_user(id, /)```
Returns a user with the given ID.
If this returns None, then u can't DM else u cam
like dis?
async def msg(ctx, user:discord.User):
user = bot.get_user(793206762101669948)```
No
bot.get_user(id).send(...)
If that raises an AttributeError, then the person ain't there in any of the guilds
^^^
im getting this error how to fix it ??
People are just getting rate limited more nowadays
lmao
then what should i do ??
you wait >:)
Get a VPS or run locally
bot also got offline
Yea
slash commands are so garbo bro
does anyone know the code to get something sent to a webhook
Hey @maiden fable! 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!
await send(content=..., *, username=..., avatar_url=..., tts=False, ephemeral=False, file=..., files=..., embed=..., embeds=..., allowed_mentions=..., view=..., thread=..., wait=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message using the webhook.
The content must be a type that can convert to a string through `str(content)`.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object.
If the `embed` parameter is provided, it must be of type [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") and it must be a rich embed type. You cannot mix the `embed` parameter with the `embeds` parameter, which must be a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects to send.
@slate swan
We know (:
await send(content=..., *, username=..., avatar_url=..., tts=False, ephemeral=False, file=..., files=..., embed=..., embeds=..., allowed_mentions=..., view=..., thread=..., wait=False)
that cant be fixed ??
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
print('await send(content=Hello Sussy Bakas, *, username= Da King Rio#1111, avatar_url=..., tts=False, ephemeral=False, file=..., files=..., embed=..., embeds=..., allowed_mentions=..., view=..., thread=..., wait=False)')
where do i put the webhook
@maiden fable
@maiden fable
bro why is your print and every setting inside a string ๐
i dont know
bruh
i just started today
it'll just print await send(content=Hello Sussy Bakas, *, username= Da King Rio#1111, avatar_url=..., tts=False, ephemeral=False, file=..., files=..., embed=..., embeds=..., allowed_mentions=..., view=..., thread=..., wait=False then
please dont judge me
im not saying your bad at coding
started discord.py learning or python itself learning
wouldn't tell, it wouldn't even help anyone if i told how long i've been doing it.
if u were to ask me that same question the answer would be 15 minutes
hmm
can u help me send something to a webhook
idk through code
yeah try out discohook
it's a webhook sender.
because i have no idea how webhooks will send messages through code
ยฏ_(ใ)_/ยฏ
get the webhook using fetch_webhook ,and use the send method hunter redirected you to
!d discord.Client.fetch_webhook
await fetch_webhook(webhook_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`Webhook`](https://discordpy.readthedocs.io/en/master/api.html#discord.Webhook "discord.Webhook") with the specified ID.
i didnt know webhooks had ids
Hahaha
!d discord.Webhook.from_url
classmethod from_url(url, *, session, bot_token=None)```
Creates a partial [`Webhook`](https://discordpy.readthedocs.io/en/master/api.html#discord.Webhook "discord.Webhook") from a webhook URL.
Much easier
:skjul
Imagine a dpy fork also caching the webhooks ๐
It's there a in build method to know bots uptime
No
Damn
is there even a way to tell how long the bot has been up for
Save the current time in a bot variable upon startup, then do the maths
oh
Oh ok
well crab, im ded, h.
U can do bot.start_time = time.time() and when u invoke the command, then subtract the current time from bot.start_time and just use utils.format_dt
That would be pog for real , helpful for logging bots
Thx
How?
import discord
from discord.ext import commands
import datetime
class Ping(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print('Bot is ready COG')
@commands.command()
async def ping(ctx):
embed = discord.Embed(title="Pong! ๐")
await client.say(embed=embed)
def setup(client):
client.add_cog(Ping(client))
You miss self
where?
Facts, but none would do that
self, ctx?
yes its self, ctx
thanks
ctx.send also works too y'know?
And why are you naming your Bot instance to client
Oh yea
im just suggesting
yea i do ctx.send because that's the first ctx thing i learned
can u index embeds so it looks like
+ +
+ +
cuz i cant find a way to do it besides
+ + +
+
or
+
+
+
+
You mean, embed fields
yea
Not embeds
What's this now
๐ค
ok so
nvm
Client.say is deprecated
i knew it
can i send a message to a webhook through just talking right here?
use ctx.reply/ctx.send
dead chat
say "aye" if you do ctx: commands.Context and say "bru" if you do ctx
is that answering me?
no
ok good cause i dont get that
@commands.command()
async def ping(self, ctx):
embed = discord.Embed(title=f'Pong! {round(client.latency * 1000)}ms')
await ctx.reply(embed=embed)
Why does this give a error
๐ค
its {bot.latency * 1000:.0f}
I use client not bot though
yea same to same client.latency and bot.latency are the same tho
oh alr
it's just variable naming
@commands.command()
async def ping(self, ctx):
embed = discord.Embed(title=f'Pong! {round({bot.latency * 1000:.0f})}ms')
await ctx.reply(embed=embed)
like that?
no change it to client.latency
oh ok
because you use client
You defined client again in the cog
Yea that's what I said
Did you?
Ye I did
exactly this is what i said too
btw remove the round it's just {client.latency * 1000:.0f}
Yeah okay
use ctx.bot.latency
alternative method if you didn't quite understand wtf im saying
and don't define the client again in cog
Yeah I get that
yea like how i did
import discord
from discord.ext import commands
import datetime
class Ping(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print('Bot is ready COG')
@commands.command()
async def ping(self, ctx):
embed = discord.Embed(title=f'Pong! {ctx.client.latency * 1000:.0f}ms')
await ctx.reply(embed=embed)
def setup(client):
client.add_cog(Ping(client))
you didn't......
got this now
in the on ready bro
looks good to me! and btw change 'bot is ready POG' instead of cog, you dont have to tho
it was just for checking for my self
๐
It doesn't change the presence and results an error anyways
Bot is undefined
Try running it if you don't believe me
I said CTX.BOT
bru
Not client
๐
how to delete all the emojis in a server
!d discord.Guild.emojis Iterate thru them and use .delete()
All emojis that the guild owns.
nomwb it?
Ayt
Oh nevermind you have a multiline string
Why do you need an entire cog for a command? What a waste of classes
Is the cog loaded?
no it's for like making the bot commands look nice whenever the user does help command
ye
atleast thatz what i think
people not reading their code realizing they have an attribute for the bot
lol i asked them to use ctx.bot and they changed it to ctx.client because they use client instead of bot
hm
xD
same thing, just variable naming
ctx.client does not exist , ctx.bot does
sooo anyone know how to make optional parameters in slash commands
I guess u should ask in the disnake support server since not many people work with slash commands here ;-;
you should ask in whichever lib you're using support's server, since as hunter said, there's not many working with slashes in here
i'd recommend you use disnake because it's extremely easy to do it with it ๐
I am and my code is like basically done
its just slash commands
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
is it possible to send a direct message to a webhook just bye using python in a normal chat?
No
Webhooks are not members
They are a thing in a discord text channel
but if you mean sending a message using a webhook then its totally possible
thats what i mean
no idea why does it not get registered
!d discord.Webhook.send <=
await send(content=..., *, username=..., avatar_url=..., tts=False, ephemeral=False, file=..., files=..., embed=..., embeds=..., allowed_mentions=..., view=..., thread=..., wait=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message using the webhook.
The content must be a type that can convert to a string through `str(content)`.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object.
If the `embed` parameter is provided, it must be of type [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") and it must be a rich embed type. You cannot mix the `embed` parameter with the `embeds` parameter, which must be a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects to send.
which library?
disnake
get the webhook instance, then send it using the send attribute
Helo bots channel members, we now have disnake and nextcord in the !d command
ah cool
where do i paste the webhook
Paste? you don't paste a webhook
nice ๐
where do i put it then
https://github.com/sarthak-py/kakashi/blob/d01e515fce8c5d19d59f6a7bbfb31bd0a353ec42/kakashi/cogs/configs.py#L121-L127 in the required arg , change it to false
kakashi/cogs/configs.py lines 121 to 127
@slash_command(
name = 'prefix' ,
description='Change prefix for the server',
options = [
Option(name='newprefix' , description='The new prefix for the server',type=OptionType.string , required=True)
]
)```
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
print('await send(content=..., *, username=..., avatar_url=..., tts=False, ephemeral=False, file=..., files=..., embed=..., embeds=..., allowed_mentions=..., view=..., thread=..., wait=False)
')
Wut, you don't paste or print that. What the bot sent earlier was how to do what you wanted
('Hello world!')
wut
i want it to be like discohook
thats the shit way of doing it tho
this is old
No idea what that is but I gave you what you need to do what you want ๐คจ
yeah disnake has a preferred method of doing slash commands which is typehinting the function, for example
@slash_command(name="something", description="something else")
async def command(inter, newprefix: str = commands.Param(description="The new prefix"))
it's a lot easier to do it now
!d disnake.ext.commands.Bot
so basically , do it again
hm nice
though I am curious why you have a slash command to change a prefix that wouldnt be used because... its using slash commands?
Lmao
idk lol , never thought about that
it actually has message commands too , mostly
kakashi/cogs/configs.py line 135
description=f"{ctx.bot.my_emojis['cross']} Bot prefix Cannot contain \`โ , `โ@`โ or `โ#`โ characters due to discord markdown .",```
it will, but if the prefix is / then its gonna be an awful user experience as they try to avoid the slash commands that pop up
yeah true , thanks for the suggestion
@bot.slash_command()
async def bazaar(
inter: disnake.ApplicationCommandInteraction,
item: str,
orders: Literal['Both', 'Buy', 'Sell'] = "Both"
):
"""
Pull a list of up to 30 or more current orders in bazaar!
Parameters
----------
inter:
item: The item you are requesting to see!
orders: The type of orders you would like to see!
"""
!CODE
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
Hello, i just wanted to ask if it's possible to display a message when someone boosts your server
Errr I think so
Wish we could have the money to try this out lol
Also does anyone know how do i leave spaces between lines of text in embedded messages?
wdym leave spaces
you can use \u200b for that
Yeah but only one space, not 3. I've tried u200b before, and it left 3 spaces
then just string + ' '?
I am kind of a beginner at coding, so..
its allg
https://mystb.in/ColoredAdequatePrisoner.python
this displays the same rank for me and 2 others
that is #1
no errors
Greetings
please help
how to make slash commands?
of
I use disnake
go to bot commands smh
s
so im using a sqlite db to store the ids of people who are afk. The part where it enters the data works fine, but im using an on_message event to check if the user is being pinged, and if he/she is, the bot will say that that person is afk. for this i need it to get the mentions in a message and check if their ids are in the db. how can i do that?
please
!d discord.Message.mentions
A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.
Warning
The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.
It will return a list of Members who were mentioned in the message
will something like this work?
mentioned = message.mentions
for user in mentioned:
with sqlite3.connect(db_path) as db:
c = db.cursor()
c.execute(f"SELECT author FROM afks WHERE guild_id = {message.channel.guild.id}")
result = c.fetchone()
if user.id == result:
await message.channel.send(f'{user.display_name} is currently AFK.')
..?
help
import requests
import discord
import json
intents = discord.Intents.default()
intents.members = True
client = discord.Client(intents=intents)
@client.event
async def on_message(msg):
if msg.content.lower() == "!setwelcome":
r = requests.get("http://localhost/add.php", headers={"server":str(msg.guild.id), "channel": str(msg.channel.id)})
await msg.reply(r.text)
if msg.content.lower() == "!getdata":
if msg.author.id == 877778571748331561:
r = requests.get("http://localhost/list.json")
await msg.reply(str(r.json()))
else:
await msg.reply("Nincs jogod ehhez!")
@client.event
async def on_member_join(member):
r = requests.get("http://localhost/list.json")
for i in r.json():
if member.guild.id == int(i["server"]):
await client.get_channel(int(i["channel"])).send(f":dom: Welcome <@{member.id}> on this server!")
client.run("token")```
i don't know whats wrong with my code
it does not send a message when someone joins
cant help but sheesh thats some complicated code
help me plz
what
and ppl say to use database.. rthats why i hate dbs
what is the error?
in the console
nothing, just does not send the welcome message
in channel
this is the list.json:
[{"server":"904407590967054386","channel":"914925979116384306"}]
await client.process_commands(msg)
what will this code do?
wait a second
okay
use it at the last of ur on_msg and see
be sure to look up on indenting
i like when ppl say its complicated but its actually not
what
it worked but i got this error
import requests
import discord
import json
intents = discord.Intents.default()
intents.members = True
client = discord.Client(intents=intents)
@client.event
async def on_message(msg):
if msg.content.lower() == "!setwelcome":
r = requests.get("http://localhost/add.php", headers={"server":str(msg.guild.id), "channel": str(msg.channel.id)})
await msg.reply(r.text)
if msg.content.lower() == "!getdata":
if msg.author.id == 877778571748331561:
r = requests.get("http://localhost/list.json")
await msg.reply(str(r.json()))
else:
await msg.reply("Nincs jogod ehhez!")
await client.process_commands(msg)
@client.event
async def on_member_join(member):
r = requests.get("http://localhost/list.json")
for i in r.json():
if member.guild.id == int(i["server"]):
await client.get_channel(int(i["channel"])).send(f":dom: Welcome <@{member.id}> on this server!")
client.run("token")```
i meant to levente
Ye because Client has no process_commands method
i also meant to that..
process commands is not realated to an event
works for me tho
..
and calling it client
wait i didnt see.. ur using discord.Client.. bruh

client = commands.Bot(command_prefix="urprefixhere", intents=intents)
h
Who said he hates it?
@thick sigil
Client just doesnt handle commands
what
please help me
Nah your code gives me headache
bruh why
๐
The way it is coded
my guy did 582 lines of code only to implement a leveling system damn
massive dedication right there
- does it give roles?
- its cuz u dont have any perks or next level role reward or somethn written like that
It does 
please help me tho @thick sigil i beg u
Outdated topgg
I dont even remember its description
I be lazy finishing this bot
@prisma spoke can you be specific at what point the error occurs , since it's hard for someone to figure it out without actually running it
ok so for me and 2 other ppl in the server the rank shows #1
Lol i see , so you're rewriting it or something?
but we are on diff levels with diff xps
its been in that state for months, im running out of interest and just left it with some basics things until someone gives me interesting ideas or wants to join me (ofc ill not take any random)
did you check the database that the data is different for both users?
Oh , hope you find someone good to work along with it
Help to make the correct condition, if one server has a channel for sending messages, then the bot sends a message, and if it is not installed on some server, then skip
thanks
rank isnt stored in the db..
levels are..
๐ I mean if you used correct logic , the rank would be determined by the levels itself and cannot be same until the levels are same ryt
rank = result[0] + 1 this is rank as defined
await cursor.execute("Select Count(*) from users where xp > ? and guild_id=?", (xp, guild_id)) result = await cursor.fetchone() rank = result[0] + 1
Actually since "channel_id" is inside the dictionary you get from your database , the "channel_id" in row would be true , even if its value is None, you will be using. py if not row or row["channel_id"] == None
@slate swan
so?
Yea..m
Lemme check the complete code again
It did not display any errors, but the message was not sent to the servers that indicated the channel either.
why tf this code still runs after return?
You mean , it returns for the guild where a channel ID exists too?
cuz break exits the loop before the return lol
oh thanks
ok please
so i need only return?
That's weird since the if : return statment does that only if the row variable does not exist or channel_id is set to none
can you recheck it?
good, one sec
- Code
- Terminal
- The channel to which the message was supposed to come
@slate swan
depends on what you need. If you want to stop the code after your if statement and dont want it to go further then yes
okay thank you
You got an error handler ?
u got my issue's solution?
No, I'll put it now
didn't find a solution
@thick sigil u please help
try printing the row variable before the return
how to give aliases in a slash command?
you can't , you need to create another slash command for that
See , channel_id is None according to the database.
Indicates the server for which the channel is not specified
whom can i ask for help?
#databases would be more helpful with stuff related to databases
so what to do about 8ball?
And how to display those with ID
Name = "8balls"
i need it to be 8ball not _8ball in slash command so any solution?
.
Bad lucas code
um didn't get it
Small n , yes
ok done thx after this new message intent im working on slash cmd , first time
what library are you using?
You said - And try for the one which is specified, but I did not understand what needs to be done
me?
That's a command right?
More precisely, if the previous function displayed servers for which the ID was not specified, then this one should display those that have specified
on_ready
I see , and it prints only one server( with channel_id = null) right?
yea
!d pastebin
!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.
https://paste.pythondiscord.com/efedexuqoh.pyNow, if you need to see the details
I see your issue , your code for on_ready stops completely with the return statment lol, replace it with pass and you're good
so?
Yea
Is it possible to do web scraping in discord.py? is it the same thing as it did in normal python?
Yeah :D, I have been making over 10 such functions
No, this is how I feel
So?
Yea
thanks!
hmm change the condition to if row and row["channel_id"] != None
that should be working
if self.collticku.count_documents({'_id': guild.id}) == 0:
self.collticku.insert_one(tickudb)
#channel_id = guild.get_channel(self.collticku.find_one({'_id': guild.id})['channel_id'])
row = self.collticku.find_one({'_id': guild.id})
if not row or row["channel_id"] == None : continue
channel = (self.collticku.find_one({'_id': guild.id}))['channel_id']
channel_id = guild.get_channel(channel)``` try this
ohhh this is already in another code
@on_click.matching_condition(cancel_others = False, reset_timeout = True)``` you didnt mention a check here
it should be like py @on_click.matching_condition(a_check_function , cancel_others = False, reset_timeout = True) iirc
btw did the old issue get fixed?
It works, thanks a lot
you;re welcome ;)
Yes, I've already done that. By the way, you do not know how to make the buttons work until the bot is restarted?
library dislash
you mean to make the buttons work even when the bot is offline?
It's just that after sending a message, they work for several hours, and then everything
No, here is the bot sent a message to the specified channel and until the bot is restarted they did not stop working
so you want the buttons to be un-usable after some time?
Didn't stop working until the bot was restarted
how do I take the response from the msg and paste it into on_reaction_add?
i need help, how can i send a dm to a user that is in my server using python by using his id?
!d discord.DMChannel
class discord.DMChannel```
Represents a Discord direct message channel.
x == y Checks if two channels are equal.
x != y Checks if two channels are not equal.
hash(x) Returns the channelโs hash.
str(x) Returns a string representation of the channel
Just fetch the ID and do the thing
!d discord.Client.get_user
get_user(id, /)```
Returns a user with the given ID.
!d discord.User.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
An embed it sends?
Or from some other bot
!d discord.Embed.to_dict
to_dict()```
Converts this embed object into a dict.
but the embed object has all the attributes to read contents from it
!d discord.Message.embeds returns the list of Embeds in a message
A list of embeds the message has.
U can do msg.embeds[0].description and stuff
how do I force the bot, after sending the c#create command, then after he created the channel, bot installed it and gave permission to view the channel to the author?
@bot.command()
async def create(ctx):
guild = ctx.message.guild
overwrites = {
guild.default_role: discord.PermissionOverwrite(read_messages=False),
guild.me: discord.PermissionOverwrite(read_messages=True)
}
await guild.create_text_channel('easy', category = bot.get_channel(916347066882592890), overwrites=overwrites)
Hi i get this error can someone help me?
@client.command()
async def restart(ctx):
if ctx.author.is_owner():
shutdown_embed = discord.Embed(title='Bot Update', description='I am now Restarting. See you later. BYE! :slight_smile:', color=0x8ee6dd)
await ctx.channel.send(embed=shutdown_embed)
await client.logout()
if ctx.author.is_owner():
errorperm_embed = discord.Embed(title='Access Denied!', description='This command is `OWNER` only. You are not allowed to use this. Try not to execute it another time.', color=0xFF0000)
errorperm_embed.set_footer(text=ctx.author)
await ctx.channel.send(embed=errorperm_embed, delete_after=10.0)```
i guess ctx.author doesn't have attribute is_owner()?
how can i fix that?
!d help
help([object])```
Invoke the built-in help system. (This function is intended for interactive use.) If no argument is given, the interactive help system starts on the interpreter console. If the argument is a string, then the string is looked up as the name of a module, function, class, method, keyword, or documentation topic, and a help page is printed on the console. If the argument is any other kind of object, a help page on the object is generated.
Note that if a slash(/) appears in the parameter list of a function when invoking [`help()`](https://docs.python.org/3/library/functions.html#help "help"), it means that the parameters prior to the slash are positional-only. For more info, see [the FAQ entry on positional-only parameters](https://docs.python.org/3/faq/programming.html#faq-positional-only-arguments).
This function is added to the built-in namespace by the [`site`](https://docs.python.org/3/library/site.html#module-site "site: Module responsible for site-specific configuration.") module.
do you want to check if the user is owner of the bot or server?
if ctx.guild.owner_id == ctx.author.id maybe
i think there's better ways to do it, but it should work
np
Hello brother's and sisters
Please ask your question here
okay lemme take a screenshot
you could just copy and paste it into a codeblock py mypython code
so im coding my discord bot and its saying theres a cog error but theres no problem in it
cog error?
yeah but theres no errors anywhere
if you get an error the theres an issue. Can you send the screenshot again please? just hide the token please
why is it a string?
wdym
help?
what string
f"cogs.{extension}"```
what about it
is there a error message?
yeah
and what is it?
only?
send the error message
full copy paste it
how to get all the members in a command? like py @client.command() async def all_members(ctx): members = #return all of the members in guild. await ctx.send(members.flatten())
what functions would get me all of the members?
okay 1 second
because it worked before at some point but not anymore
I get this error ;-;
File "main.py", line 29, in <module>
bot.load_extension("music")
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 678, in load_extension
self._load_from_module_spec(spec, name)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 623, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'music' raised an error: CommandRegistrationError: The alias current is already an existing command or alias```
all members of a guild?
there
yes
halp
ples
sink what do i do then
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.cogs' raised an error: AttributeError: module 'discord.ext.commands.cog' has no attribute 'listener'
thats the error
so i just do py @client.command() async def hi(ctx): await ctx.send(guild.members)?
what if u do that in mrbeast server
i won't i need it for my class server
hmm wait
did u enable server members intent in ur application
I think that the error comes from one of your cogs, send a picture where you tryin' to use listener attribute
it will send a ugly list of members into a chat
not yet i am enabling it
@tidal hawk
like this?
thats my cog file where its being used
xD
thanks tho
np
how do i set intents?
do that and try this
intents.members = True```
and ```@bot.command()
async def members(ctx):
members = ctx.guild.members
await ctx.send(members)```
here
okay
how much members are there in ur server
15
then fine
Hrlo77 what are you trying to do?
trying to get all members name
in one cmd
and output those member names into a chat?
idk properly but ig a try
.
well ctx.guild.members returns a list of all members
halp this one
and [member.name for member in ctx.guild.members] returns a list of all names, and then it into a chat
I imported all my python files on a new computer, im using pycharm and when i stop my discord bot i have this error :
ye
after stopping , when u start this bot u get this error?
on my old computer i got that when i stop
so no error
hm
yes only on my new computer
i mean i can start my bot
but when i stop the script it does that
does it have any commands or functions?
show code
Guys how do i enable intents on my bot on the on_ready function? ```py
@client.command()
async def on_ready():
How do i set intents here?
there is a lot of code
intents.members = True```
ye
commands.Bot(intents=intents)
intents.members = True
bot = commands.Bot(command_prefix='s.',intents=intents)```
okay
why is it in on_ready function?
idk
so wich code do you want?
okay
because there is too much code
Does your bot have functions/commands?
yes a lot of commands
hm
did u enable intents?
but idk why it works perfectly on my old computer, and it's a virtual env so the python version is the same
default yes
and intents member
hmm
did u specify the token correctly?
the token is the same yes, but i can use the bot
just when i shutdown the srcipts it shows this error
so its not shutting down?
Any help ```py
intents = discord.Intents.default()
intents.members = True
from discord.utils import get
@client.event
async def on_member_join(member):
guild = client.get_guild(768876864319389696)
welcome_channel = guild.get_channel(768876864319389696)
await welcome_channel.send(f'Welcome to the {guild.name} Discord Server, {member.mention} ! :partying_face:')
await member.send(f'We are glad to have you in the {guild.name} Discord Server, {member.name} ! :partying_face:')
@client.event
async def on_member_remove(member):
guild = client.get_guild(768876864319389696)
welcome_channel = guild.get_channel(768876864319389696)
await welcome_channel.send(f'{member.mention} has leaved the server ! :sad_face:')
from discord.ext import commands
TOKEN = "here paste your token"
client=commands.Bot(command_prefix = '.')
@client.event
async def on_ready():
print('Connected')
client.run(TOKEN)```
try putting ur token in the main
now the error is shorter :
send the error
i use some commands before shutting down
o nvm
hmm
Hello friends
slash = SlashCommand(client=client,sync_commands=True)
@slash.slash(name="help",description="Macht help embed",guild_ids=[myserverid])
async def help(ctx: SlashContext):
await ctx.send("test")```The bot doesnt sends the message and doesnt give me an error
Guild id must be specified
i installd discord.py and discord with pip, and dsnt work
or you gotta wait a hour
' Module Not Found'
i did just edit it out
i reinstall the python / vsc / discord.py / python and nothing.
it's not a big problem but it intrigues me
hmm
?
insatall discord package
PS C:\Users\gelle> & python c:/Users/gelle/Desktop/main.py
Traceback (most recent call last):
File "c:\Users\gelle\Desktop\main.py", line 2, in <module>
import discord.py
ModuleNotFoundError: No module named 'discord'
PS C:\Users\gelle>
try this from discord.utils import get
try guild = member.guild
show the intents u enabled
Any help?
naw man sry
pog
there
@slash.slash(
name="help"
,description="Macht help embed"
,guild_ids=[867750507774869545]
)
async def _help(ctx: SlashContext):
await ctx.send("test")``` So apperently _help doesnt get called how do i fix this?
hm
Which lib?
discord-py-slash-command
Oh idk then
show the command_prefix line
bot = commands.Bot(command_prefix='b!', help_command=None, intents=intents)
but it looks like a windows issue
because im on W11 here
hmm
maybe it's that
ig so
where have u mentioned the token
dont show it to me
just tell that is it in a env or in main itself
u hav cogs?
sure
sure?
hmm then just do it like ```
import discord
from discord.ext import commands
token="<token>"
client=commands.Bot(command_prefix = '.')
@client.event
async def on_ready():
print('ok')
client.run(token)```
or else try keeping it in a env file
do not use โclientโ as your bot object variable.
uh but i can't keep it in my config file in secret folder?
whatever use bot ig
try this
okay
are u gonna stream someone this code?
i still have the same issue
nope
hmm, try keeping it in a env file
I enabled members intents and presence intents properly, but it still says i need members intents to use fetch_members
i can keep like this but it a bit annoying
show me where you defined intents in your code.
show intents code
Hey so I don't have youtube_dl imported but when the bot updates it says installing discord.py and installing youtube_dl, as long as I don't use it would it be fine?
then i used guild.Guild.fetch_members(limit=20)
but it said i needed members intent enabled
!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)
if youโre gonna fill the intents kwarg with intents.all() then whatโs the point in even defining intents in your code ?
Pip install discord
Useless token variable, why do you even need it?
I knw, its against tos I need to know aslong as I don't use it would I be fine? I don't even have it imported.
change ur python interpreter to another version
Lucas
on top of that, you have client as your bot object variable , and bot as your discord.Client variableโฆ
Bruh, just make another file then import it, thats way safer than making a variable in the same file
๐
Hey so I don't have youtube_dl imported but when the bot updates it says installing discord.py and installing youtube_dl, as long as I don't use it would it be fine?
bot the clean menssagens dm fro discord?
I was saying they are probably following lucas , I myself use environment variables :)
replit is like that lol, it isn't a bad thing by the way
Sorry I misunderstood, I donโt quite understand what you are asking tho?
Would I be alr (Not get banned or the bot take down) if I don't use ytdl or have it in any of the code would I be fine?
how do i register slash commands?
wait 1h or use a kwarg ig (in most forks it has it)
Same.
yeah? youโre not breaking any ToS
Okay! Ty.
and you could probably go into the replit packages and remove it
i already have some code but _help isnt called py slash = SlashCommand(client=client,sync_commands=True) @slash.slash( name="help" ,description="Macht help embed" ,guild_ids=[867750507774869545] ) async def _help(ctx: SlashContext): print("interaction recived") await ctx.send(content="test")
oh and the command gets registered but says interaction failed
anybody? no? ๐ฆ
naw bro i use replit
whats the package for discord slash commands?
disnake is one iirc
Try running print('hello') on a separate one on VSC and see if it works.
you just exposed your token
work
bro delete this
bro the t0ken...
delete your message
it hasa ||token||
the token is test bot. im not idiot guys ๐
DELETE THE PHOTO NOW
then fine
did you run pip install discord.py?
yeah and nothing.
then restart vsc and it should be fine after
pip install discord_slash
ERROR: Could not find a version that satisfies the requirement discord_slash (from versions: none)
ERROR: No matching distribution found for discord_slash
uh someone pls
merry nearly christmas, I guess
which IDE are you using?
ok guys. i mean gods. The Discord.py its work! Thank u all โค๏ธ
gods?
we are not gods
can someone help
we are mere programmers
I think it's supposed to be discord-slash
when ever you download anything in vsc via pip you should restart it, at least most of time
pip install discord-slash
ERROR: Could not find a version that satisfies the requirement discord-slash (from versions: none)
ERROR: No matching distribution found for discord-slash
that's why PyCharm is better
xd
try pip install discord-py-slash-command
It works but i have and this:
from discord_slash.utils.manage_comamnds import create_choise, create_option
Error:
pip install discord_slash.utils.manage_comamnds
ERROR: Could not find a version that satisfies the requirement discord_slash.utils.manage_comamnds (from versions: none)
ERROR: No matching distribution found for discord_slash.utils.manage_comamnds
which IDE are you using?
i get this weird ass error when i load my music cog
discord slash is bad anyways
you already have it in your code somewhere
y i want to try it in my test bot
do ctrl+f
?
hi i have a problem when i did the welcome command the role on join stops working
?
elaborate
hmm
You can't have two functions with the same name
!d discord.ext.commands.Bot.listen use this instead
@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...
oh yea i am so dumb
me?
yes
u can just combine them both ryt?
ide = ?
already answered
... ๐คฆโโ๏ธ
...........
what are you using to code
how
@maiden fable already answered you
what im gonna install?
from discord_slash.utils.manage_comamnds import create_choise, create_option
@bot.listen("event-name")
async def abc(...):
...
restart it
bc i installed discord slash once and restarted this
close and re-open VSC
If u specify the event name, u can name the function anything
again
the same error
from discord_slash.utils.manage_comamnds import create_choise, create_option
ModuleNotFoundError: No module named 'discord_slash.utils.manage_comamnds'
I never used VSC in a long time
@client.event
async def on_member_join(member):
channel = client.get_channel(768876864319389696)
embed=discord.Embed(title="Welcome!",description=f"{member.mention} Just Joined the server.")
ember=embed.set_thumbnail(url="https://media.discordapp.net/attachments/612746705406001213/612990390907305990/avatar.png")
await channel.send(embed=embed)
role = discord.utils.get(member.guild.roles, name = "ใ๐ ใUSER")
await member.add_roles(role)
print(f"{member} was given {role}")
``` i did that
and its working
Okay cool
its ok
what
;-;
what
Change the cogs name
Let's see it
Is it possible to somehow transfer emb2 to the embeds file without losing channel.mention?
CommandRegistrationError: The alias current is already an existing command or alias
Looks like you're loading the cog twice
Go to line 29
use ctrl+f?
bot.load_extension("cogs.tictactoe")
bot.load_extension("cogs.economy")
bot.load_extension("cogs.music1")
;-; to search through?
i tried
what did it say?
it had no other cog load
no it was 1/1
;-;
Virgo , you have 2 commands named music?
What's on line 29?
no its a cog
Read what I said again , do you have 2 commands named music?
line 29 is
no there isnt
Well , your error says the same
Have you restarted your bot?
i did million times
The error is showing code that isn't there
hm
class musicCog(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
<code>
def setup(bot):
bot.add_cog(musicCog(bot))```
How can i give permission to write in channel for only for example 15 minutes?
use datetime timestamp
ngl this part looks kina shitty
and loop it to check every minute?
nah, just delete permission to write after 15 minutes
wait i will make code
and send
I think better to loop it to every minute. Otherwise bot don't know about current time at all
oh, thanks for sharing your idea
np,, gib 2 mins
whats the name of that role ? @gentle rose
no its not role, i want to give permission to specific user
umm u cant giv perms to ppl like that u need to giv them roles with perms
How do i create a role?
....
ah, ok. Lets name this role - Allowed
ohwait
dms
i mean w/ my bot
Why a mistake?
when naming classes you should use the pascal casing typing convention. musicCog -> MusicCog
How do i edit a role perms?
because i created a role called New Role_
i want to remove perms on it
how do i do that?
Guys i have this code here https://pastebin.com/WT7xRQBA
I'm trying to call the build() function from the init file but it gives me NoneType error, what is the problem? i don't understand
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
How do i delete roles?
!d discord.Role.delete
await delete(*, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Deletes the role.
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.
- Folder 2. file
hi there,
How I can add spotify playlist function in bot?