#discord-bots
1 messages Ā· Page 928 of 1
i cant finf the channel code
!d discord.Guild.get_channel
get_channel(channel_id, /)```
Returns a channel with the given ID.
Note
This does *not* search for threads.
Changed in version 2.0: `channel_id` parameter is now positional-only.
do you have a .env with a var called TOKEN = ... in it?
lmao
yes
channel = guild.get_channel(ID)
is the .env named TOKEN?
well this error is saying you're passing None
Yes
aka the variable doesnt exist
the prblm is how to get that ID?
can I clarify that your .env file is actually named .env?
look if your running that on ur local pc no need to hide it just put the token
Turn on developer mode, right click on the channel and press Copy ID.
ok
can I clarify that you saved the load_dotenv() when rerunning it?
remove os.getenv and just replace with "TOKEN"
same error?
yeah
how to turn on developer mode?
are you on your browser?
Settings>Advanced>Enable Developer Mode
yes
doesnt matter if you're on client or browser
just go on the url and the last string is the channel id when you click the channel
look at the url
use os.environ
hello
User Settings > Advanced > Developer Mode
Hey!
yh ik but you can get the server and channel id by the url
wsp i need project for online bot ?
got it
Uh?
em
online bot?
What?
i need online my bot
Host it then.
ehm
Self-host, vps*...
vps*
okey thanks
If you can't self host or use a vps, you could use free stuff like uptimerobot, even tho that's not really a good option.
its good but only for small bots
that arent in many servers
the response time will be slow
if its too many
I meant, like it isn't really made for hosting discord bots. It won't make it 24/7.
fyi uptimerobot is not a host
It usually gives like 99.3% uptime.
I know, but it can be used as one.
i have a bot running in repl just for one server and the last time it was down was like 3 months ago
Woah, my bots usually restart after like 8 hours.
host on a vps
i use a service that costs $3 monthly and its only gone down once for about 5 minutes
hm maybe cuz my bot just stays there its a security bot anti-raid , anti-nuke stuff
Fun
i hosted my old bot on vultr
how to make profile-role clickable
@client.event
async def on_member_join(member):
guild = client.get_guild(930722774513754112)
channel = guild.get_channel(930722774513754114)
profile-roles = guild.get_channel(936819091992354826)
await channel.send(f"Welcome to the server Friend {member.mention}! You can do your #š¹{profile-roles}, if you want us to know you better.")
await member.send(f"We are so excited you have joined our 'Average' community! {member.mention}, with your great personality, you are going to be a great addition. Welcome!")
i did it thank u
np
how can i make the welcome msg whr the profile role channel will be clickable
what are you trying to do by making it "clickable"? like how does its clickability effect the role and effect the user who has it
oh you use <#idhere>
for user ids you can use <@idhere> but its automatic if you use .mention
i mean whn u click the word profile role it will take u to that channel
and for roles you can use <&@role id>
yes. if you have it formatted like <#> for example: [#discord-bots](/guild/267624335836053506/channel/343944376055103488/)
type that
whr should i use it
ok
your profile-roles should be replaced with <#the-channels-id>
@client.event
async def on_member_join(member):
guild = client.get_guild(930722774513754112)
channel = guild.get_channel(930722774513754114)
await channel.send(f"Welcome to the server Friend {member.mention}! You can do your #channel-name, if you want us to know you better.")
await member.send(f"We are so excited you have joined our 'Average' community! {member.mention}, with your great personality, you are going to be a great addition. Welcome!")

no?
Welcome to the server Friend {member.mention}! You can do your [#936819091992354826](/guild/267624335836053506/channel/936819091992354826/)
@slate swan try clicking this #936819091992354826
[#936819091992354826](/guild/267624335836053506/channel/936819091992354826/)
i cant see the channel so i cant mention it
same with your bot, so make sure your id is correct
oh yeah i forgot
await channel.send(f"Welcome to the server Friend {member.mention}! You can do your [#936819091992354826](/guild/267624335836053506/channel/936819091992354826/), if you want us to know you better.")
@client.event
async def on_member_join(member):
guild = client.get_guild(930722774513754112)
channel = guild.get_channel(930722774513754114)
await channel.send(f"Welcome to the server Friend {member.mention}! You can do your [#936819091992354826](/guild/267624335836053506/channel/936819091992354826/), if you want us to know you better.")
await member.send(f"We are so excited you have joined our 'Average' community! {member.mention}, with your great personality, you are going to be a great addition. Welcome!")
I would add some error handling in case the user has DMs closed
yup
try except?
just basic try else
exception discord.Forbidden(response, message)```
Exception thatās raised for when status code 403 occurs.
Subclass of [`HTTPException`](https://discordpy.readthedocs.io/en/master/api.html#discord.HTTPException "discord.HTTPException")
@client.event
async def on_member_join(member):
guild = client.get_guild(930722774513754112)
channel = guild.get_channel(930722774513754114)
await channel.send(f"Welcome to the server Friend {member.mention}! You can do your [#936819091992354826](/guild/267624335836053506/channel/936819091992354826/), if you want us to know you better.")
try:
await member.send(f"We are so excited you have joined our 'Average' community! {member.mention}, with your great personality, you are going to be a great addition. Welcome!")
except:
pass
yeah i remember getting those alot because i have a custom prefix command and iit searches for a "prefix": on user command through guild id
If DMChannel is closed, it either raises Forbidden or HTTPException
its forbidden but just except will do fine if the dms are closed then let it be
?
wha
are you suggesting a bare except?
im suggesting this will do just fine
uh no
how?
you donāt even know if an error was raised
just do py profile_roles = client.get_channel(936819091992354826) or await client.fetch_channel(936819091992354826) guild and channel is not needed here
donāt think get channel is a coro
all fetch_x methods are coroutines
oh yeah fetch is
fetch_channel isnt usually needed as discord keeps your bot pretty well updated with guild stuff
yea
i hate making avatars for my bot
Keep up to date with any interruptions to our service which may be affecting you.
yes but if an error was raised it will just pass.
Except exception as E:
raise E
Why it said this error ?
Traceback (most recent call last):
File "main.py", line 25, in <module>
client.run(os.getenv('TOKEN'))
File "/home/runner/Welcoming-Bot-1/venv/lib/python3.8/site-packages/discord/client.py", line 723, in run
return future.result()
File "/home/runner/Welcoming-Bot-1/venv/lib/python3.8/site-packages/discord/client.py", line 702, in runner
await self.start(*args, **kwargs)
File "/home/runner/Welcoming-Bot-1/venv/lib/python3.8/site-packages/discord/client.py", line 665, in start
await self.login(*args, bot=bot)
File "/home/runner/Welcoming-Bot-1/venv/lib/python3.8/site-packages/discord/client.py", line 511, in login
await self.http.static_login(token.strip(), bot=bot)
File "/home/runner/Welcoming-Bot-1/venv/lib/python3.8/site-packages/discord/http.py", line 300, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "/home/runner/Welcoming-Bot-1/venv/lib/python3.8/site-packages/discord/http.py", line 216, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 429 Too Many Requests (error code: 0): You are being blocked from accessing our API temporarily due to exceeding our rate limits frequently. Please read our docs at https://discord.com/developers/docs/topics/rate-limits to prevent this moving forward.
Integrate your service with Discord ā whether it's a bot or a game or whatever your wildest imagination can come up with.
exactly
you donāt know if an error happened because it passed
nice capitalization
Rate limited
How to fix?
wait a few minutes
Wait
that better be autocorrect
^
thanking you
kill 1 in shell
it was
except Exception as e: i just had a stroke
Thatās just as bad
still eror
as a bare except
I know
kill 1
Just the same error
isnt it ip related tho the api blocks u
u gotta wait a few minutes
thats later
kill 1 changes ip ptoo

done yet?
10-15 mostly
why i need to wait?
Minutes
cuz its rate limit
because replit sucks (unless web development)
Ah okay
What should i use?
your pc
even a spare laptop
anything that can run notepad and command prompt honestly
I'm using macbook
install linux
okay
are you using uptimerobot?
Host on a Linux vps
yes?
so running it on ur pc will mean down time
because im sure you turn ur pc off

can i run it now?
@slate swan ps: the help command doesnt work if the guild doesnt have a icon (getting a dev to change that soon)
How does one have a command where two arguments are seperated by commas?
ive been trying to figure that out for months
oh okay
like when invoking?
yeah
like one arg would be example foo and the execution would be !command arg1, arg2, foo
why would you need that though. Use * or Greedy to consume the arguments after into one argument
it looks better for some more spcific commands
and spacing is a pain
im trying to figure out how to invoke more than one argument with no spaces
like the command is used by ?name arg1, arg2
str.split(sep=None, maxsplit=- 1)```
Return a list of the words in the string, using *sep* as the delimiter string. If *maxsplit* is given, at most *maxsplit* splits are done (thus, the list will have at most `maxsplit+1` elements). If *maxsplit* is not specified or `-1`, then there is no limit on the number of splits (all possible splits are made).
If *sep* is given, consecutive delimiters are not grouped together and are deemed to delimit empty strings (for example, `'1,,2'.split(',')` returns `['1', '', '2']`). The *sep* argument may consist of multiple characters (for example, `'1<>2<>3'.split('<>')` returns `['1', '2', '3']`). Splitting an empty string with a specified separator returns `['']`.
For example:
yh its a nice bot in general
i just work on the website haha
#bot-commands
ye the website ui is pretty amazing
it said this now
Traceback (most recent call last):
File "main.py", line 25, in <module>
client.run(os.getenv('TOKEN'))
File "/home/runner/Welcoming-Bot-1/venv/lib/python3.8/site-packages/discord/client.py", line 723, in run
return future.result()
File "/home/runner/Welcoming-Bot-1/venv/lib/python3.8/site-packages/discord/client.py", line 702, in runner
await self.start(*args, **kwargs)
File "/home/runner/Welcoming-Bot-1/venv/lib/python3.8/site-packages/discord/client.py", line 666, in start
await self.connect(reconnect=reconnect)
File "/home/runner/Welcoming-Bot-1/venv/lib/python3.8/site-packages/discord/client.py", line 601, in connect
raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
Integrate your service with Discord ā whether it's a bot or a game or whatever your wildest imagination can come up with.
Try reading the error before sending it here
thanks. i was working on it yesterday and changed the font around
idk
!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.
u gotta enable member intents in the developer portal too
how?
Check the intents above
Read this
Integrate your service with Discord ā whether it's a bot or a game or whatever your wildest imagination can come up with.
chose the bot ur working on
your welcome
wait
btw Cesiyi
File "/home/runner/Welcoming-Bot-1/venv/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 18, in on_member_join
channel = guild.get_channel(955726308787245086)
NameError: name 'guild' is not defined
It now said this
Guild isn't defined
let me see the code
its gotta be ctx or member
import os
import discord
from discord.ext import commands
from discord.utils import get
from discord import Intents
from dotenv import load_dotenv
load_dotenv()
intents = Intents.default()
intents.members = True
client = commands.Bot(command_prefix="!", intents=intents)
client.remove_command("Help")
@client.event
async def on_member_join(member):
channel = guild.get_channel(955726308787245086)
await channel.send(f"{member.mention} has just joined the server!")
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
client.run(os.getenv('TOKEN'))```
!d discord.Member.guild
The guild that the member belongs to.
Use that
PS C:\Users\NISHA\VScode\PythonCode> pip requests
ERROR: unknown command "requests"
PS C:\Users\NISHA\VScode\PythonCode> pip requests
ERROR: unknown command "requests"
PS C:\Users\NISHA\VScode\PythonCode> & C:/Users/NISHA/AppData/Local/Programs/Python/Python310/python.exe c:/Users/NISHA/VScode/PythonCode/MyFirstbot.py
Traceback (most recent call last):
File "c:\Users\NISHA\VScode\PythonCode\MyFirstbot.py", line 3, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
PS C:\Users\NISHA\VScode\PythonCode>
member.guild.get_channel
pip3 install requests
y request cant import
on shell
oh wait
its pip install
pip install requests
not pip
and for flask?
pip install flask?
Traceback (most recent call last):
File "/home/runner/Welcoming-Bot-1/venv/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 19, in on_member_join
await channel.send(f"{member.mention} has just joined the server!")
NameError: name 'channel' is not defined
This now
hi hi
Get the channel using guild.get_channel.
channel is not defined
channel isnt defined
basic python
guild = member.guild
channel = guild.get_channel(ID)
await channel.send()
import os
import discord
from discord.ext import commands
from discord.utils import get
from discord import Intents
from dotenv import load_dotenv
load_dotenv()
intents = Intents.default()
intents.members = True
client = commands.Bot(command_prefix="!", intents=intents)
client.remove_command("Help")
@client.event
async def on_member_join(member):
channel = member.guild.get_channel(955726308787245086)
await channel.send(f"{member.mention} has just joined the server!")
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
client.run(os.getenv('TOKEN'))
that code is bad ngl
- use f strings
- use listen and not event
- remove the help command in the constructor
- why import the intents class?
- remove_command("
help")
What's wrong with an event?
cuz on_member_join needs intent
nothing just listen is superior and should always be used
If you say so.
you do know you imported discord right?
Event limits you to a single event, you cannot have more than 1 same event in same file, but as many listeners you want
yes but intent is still needed to capture user data
You mean, using listeners you could have 10 on_message?
Even 100
That's great
not my point. my point is you imported the class which wasnt even needed because you can access the class from the module
good thing about listeners lmao
thats not even my code i just fixed it for someone

And since you're importing discord , you an just discord.Intents, discord.utils.get instead of importing them
oh, it's someone else's code
if youre gonna spoonfeed someone do it right

it's still against the ToS
performance: yea its fine
!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)
Would be against these
or do it wrong and just leave them be
wow it worked now thank you guys so much
if I have ```py
class Suggestion_Modal(disnake.ui.Modal):
def init(self, cog):
if not (await check_if_suggestion_blocked(interaction.author.id)):
#code
class Suggestion(commands.Cog):
def init(self, bot):
self.bot = bot
async def check_if_suggestion_blocked(# arguments):
#function
how do I access the `check_if_suggestion_blocked` that's in the cog from the suggestion modal above?
how to see the messages my bot get in inbox
i think you can override init like you would with View and pass the cog instance as an argument
what?
its annoying when people just "ask" me for code in dms so ive just given them code with errors in it (basic errors like indentation, typos, caps, etc) and just stopped responding
its a nice challenge for them
because they actually learn along the way
That's the only way?
unless they dont
well you need the cog instance somehow, this is a sensible way to pass it
if theyre asking for a code snippet that works whats gonna make them fix the error on there own if they cant even code there own working command? "guidance" im not sure guiding someone with code snippets is a very good way of teaching/guiding someone.
eh well
how long does to take before dev portal changes update to discordapp
you just restart your client and wait for it to cache the changes thats all,dev portal changes are done quickly
Message intents are enforced on 31st April right?
haha dude yes very funny, so like in 8 years? it's 2015 what are you thing?
not as long as gta6s release date
okay sorry for the ping again but mind telling me how I pass the cog as an argument?
not sure what i did wrong, but i tried
cant you just access the method from an instance of the class?
so I need to pass the cog as an argument in the init you mean right
why do you need the cog?
because the function is in the cog
i don't get what you mean by that
ClassInstance().method()
Should work.
!d discord.HTTPException
exception discord.HTTPException(response, message)```
Exception thatās raised when an HTTP request operation fails.
The status code of the HTTP request.
What does ārequirement already satisfiedā means?
Iām trying to import discord.py-message-components
Or any way to import it
it means you have already got it installed
I used pip install discord.py-message-components
k
And I have a import with name
from discord import Button, SelectMenu, SelectOption
But the console says :
from discord import Button, SelectMenu, SelectOption
ImportError: cannot import name āButtonā from ādiscordā
You have to use the package name.
assuming you have discord.py 2.0 you should just use discord.ui
not necessarily
True __import__() works too
no, packages can extend other packages
!pypi buttons
A simple to use, interactive session and paginator with custom buttons for discord.py.
from discord.ui ?
look at the import code
I know but should you?
k
what
Exactly, what?
what
tell me you're trolling
how to know which guilds our bot is in?
!d discord.Client.guilds
property guilds```
The guilds that the connected client is a member of.
No, i'm pretty against making extensions in pypi's it's too messy.
i didnt make the package
May I have the documentations link for discord.ui?
okay so i just checked and do i need classinstance().method() or classinstance.method()
afaik there are no docs for buttons or components that you installed
oh kden
https://github.com/PythonistaGuild/buttons this has an example
Might as well use disnake at that point..
whats wrong with you
that stuff is discords stuff
it just has documentation
error:
if not (await Suggestor().check_if_suggestion_blocked(inter.author.id)):
TypeError: Suggestor.__init__() missing 1 required positional argument: 'bot'
Code:
class Suggestion_Modal(disnake.ui.Modal):
def __init__(self) -> None:
#modal stuff
async def callback(self, inter: disnake.ModalInteraction) -> None:
if not (await Suggestor().check_if_suggestion_blocked(inter.author.id)):
#code
class Suggestor(commands.Cog):
def __init__(self, bot):
self.bot = bot
async def check_if_suggestion_blocked(self, member_id):
async with self.bot.db.execute("SELECT member_id from suggestion_blocks WHERE member_id = ?", (member_id,)) as cursor:
data = await cursor.fetchone()
if not data:
return True
else:
return False
should i be putting the function async def check_if_suggestion_blocked in another file and import it instead of putting it within the cog?
you clearly havent passed bot
^
oh shoot
but this?
Why use a separate class when you can just compose it all into a modal subclass
what do you mean?
One of OOP terms - composition
why can you not just pass bot?
Anyways I think you should extract it from cog
and when you call SuggestionModel you just pass bot
You shouldn't put functions that are used outside of the cogs into the cogs
yeah i got it I'm doing it now
Unless you declare it as a staticmethod
so put it outside both classes?
not necessarily
I usually have a module with functions for that kind of stuff you may do the similar thing
I have the error for import
Iām using from discord import Select, SelectOption, SelectMenu
Console says:
ImportError: cannot import name āSelectā from ādiscordā
it depends is method a class instance if not you do need to call the class.
Which you should be using
discord.py has no classes named Select, SelectOption and SelectMenu
ModuleNotFoundError: no module named ādiscord.uiā
aka you're not on 2.0
this is correct, you're just not on 2.0
& how can I be on 2.0
Imports
Considering the ClassInstance already an instance (object) it can't be called unless it has __call__ overwritten so small logical typo
nah its not a variable
i ment it as the creation of an instance hence why i called it
but you do have a point
I mean it would be more correct if you named it like MyClass().method() for example
I get what you meant that's just uh barely noticeable
i mean im just creating a class instance
Kk
class naming lol
how to know which guilds our bot is in?
!d discord.ext.commands.Bot.guilds
property guilds```
The guilds that the connected client is a member of.
doesnt help
bro what
len(bot.guilds)
it returns a list of Guild objects you cant say it doesnt help
dude this is the third time you've said this
Why understand docs when you can copypaste
and the third time you've gotten the same answer
nextcord doesnt like it
nvm i find
Ok
nextcord has docs for a reason
where do i send api requests for bots to?
!d nextcord.Client.guilds
property guilds: List[nextcord.guild.Guild]```
The guilds that the connected client is a member of.
works fine.
@delicate hornet if you do just check dev portal
Documentation tab
just (discord.com/api)?
v10 is the latest Yup
Erase it
what's the best way to add a reaction to a message? I find bot.get_emoji very inefficient as it returns None sometimes
yeah but why does it get there
Merge conflicts ig
You don't really have any other option other than using the raw emoji format then
it's <:emoji_name : emoji_id> right?
wait why doesn't putting \ behind an emoji show raw format
why does discord thing its not found
and Unauthorized if i put /oauth2/applications/@me
at the end?
it does, just post the message !dice_0
i did
this is what happens for me
whoooops nevermind
!d discord.Object
class discord.Object(id)```
Represents a generic Discord object.
The purpose of this class is to allow you to create āminiatureā versions of data classes if you want to pass in just an ID. Most functions that take in a specific data class with an ID can also take in this class as a substitute instead. Note that even though this is the case, not all objects (if any) actually inherit from this class.
There are also some cases where some websocket events are received in [strange order](https://github.com/Rapptz/discord.py/issues/21) and when such events happened you would receive this class rather than the actual data class. These cases are extremely rare.
x == y Checks if two objects are equal.
x != y Checks if two objects are not equal.
hash(x) Returns the objectās hash.
!d discord.Guild.unban
await unban(user, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Unbans a user from the guild.
The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to do this.
what
async def on_member_join(member: disnake.Member):
channel = client.get_channel(953020283386757161)
await channel.send(f'Welcome to the discord {member.mention}! ')
await member.add_roles(953020268656353350)```
why dosent this add role neither send message to the channel
i would walk you through it but i really cant be bothered; just add the -f to the push again -_
I did, still didn't update on my repo
don't you need to pass the role itself, not the ID to add_roles?
uh pretty sure there is
I dont know docs never make sense to me
try getting the role first
My table is called prefixes?
so youre saying sqlite is a liar?
Noo but idk
got any idea
is it the same db file?
ye
show db file and code
their is if it raises an operation error?
async def on_member_join(member):
guild = client.get_guild(772968562054660107)
channel = guild.get_channel(953020283386757161)
role = guild.get_role(953020268656353350)
await channel.send(f"Welcome to the server {member.mention}!")
await member.add_roles(role)```?
dosent add role neither send message
I normally do discord.utils.get(guild.roles, id=...) but that might work too
im using disnake
Yeah I get you
oh, then try what you said. seems fine
Got any idea on how to fix it?
I want to buy a VPS from GalaxyGate. Which OS is the best for discord bots?
how do i format this embed to look cleaner?
@slate swan
what would make it look cleaner
thinking about fields but that would be awkward
fields would help
idk atm it looks like a wall of text
maybe changing colors and using authors and footnotes
what does that error mean:
Traceback (most recent call last):
File "main.py", line 14, in <module>
client.run(token)
File "/home/runner/haha21/venv/lib/python3.8/site-packages/discord/client.py", line 723, in run
return future.result()
File "/home/runner/haha21/venv/lib/python3.8/site-packages/discord/client.py", line 702, in runner
await self.start(*args, **kwargs)
File "/home/runner/haha21/venv/lib/python3.8/site-packages/discord/client.py", line 666, in start
await self.connect(reconnect=reconnect)
File "/home/runner/haha21/venv/lib/python3.8/site-packages/discord/client.py", line 601, in connect
raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to
still dosent work..
async def on_member_join(member):
disnake.utils.get(guild.channel, id=953020283386757161)
disnake.utils.get(guild.roles, id=953020268656353350)
await channel.send(f"Welcome to the server {member.mention}!")
await member.add_roles(953020268656353350)```
you're asking for intents that we're enabled in the dev portal
alright imma try to add fields but i don't think itll work caus i need two sections
you have to set the role = to the get
so i have to disable them?
lol no
or enable disabled ones?
Channel isnt even defined
go to your dev portal and enable the intents that were disabled
still dosent work
ok
cant help if you dont give info
what problem
learn to code
can you put two embeds in one message?
i just enabled all
!d discord.ext.commands.has_permissions
@discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.
Note that this check operates on the current channel permissions, not the guild wide permissions.
The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions").
This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingPermissions "discord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
@commands.has_permissins(ban_members = True)
What info you need
@bot.event
async def on_member_join(member):
channel = disnake.utils.get(guild.channel, id=953020283386757161)
role = disnake.utils.get(guild.roles, id=953020268656353350)
await channel.send(f"Welcome to the server {member.mention}!")
await member.add_roles(role)```
wont work
what problem
it dosent do anything
not very helpful when you yourself are a beginner
np
not correct*
has a typo lol
so..
not anymore
show your query and db file
what do u want it to show
its ment to add role and send message when you join the discord
join the discord.....
i did................................
u meant the server....
no i mean the discord..........................
do you have intents?
ahh okimii halp
yes
lol
show
this is just view in vsc, my query ```py
c.execute(f'SELECT prefix FROM prefixes WHERE guild_id = {ctx.guild.id}')

how do you enable intents
wait getting this error now
!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.
im using disnake
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "main.py", line 17, in <module>
bot.load_extension('cogs.rr')
File "/home/runner/keiro/venv/lib/python3.8/site-packages/nextcord/ext/commands/bot.py", line 789, in load_extension
self._load_from_module_spec(spec, name, extras=extras)
File "/home/runner/keiro/venv/lib/python3.8/site-packages/nextcord/ext/commands/bot.py", line 678, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
nextcord.ext.commands.errors.ExtensionFailed: Extension 'cogs.rr' raised an error: SyntaxError: invalid syntax (pr.py, line 30)
īŗ§
what does this error mean?
well it says it lol
Can someone help me please?
theres a syntax error in the cog
any os that doesnt take much ram
color=discord.Color.green whats wrong
Which is..? šš
theres nothing wrong with line 30 though
i added intents but still dosent work
!d discord.Color.green
No documentation found for the requested symbol.
lol not a color
hm so what should it be then?
you could hexcode
ah ye ill just do that then ig
linux is good
did you read the error
i did?
Ubuntu or debian? And which version?
Thank you
it says received method aka it exists but its a classmethod, meaning you call it
looks better
personally, i dont like debian based distros (ubuntu being one), what are you looking for in an os though?
maybe you can bold the numbers
look at the alignment of items and ingredients, its completely off
how if its not in docs?
try putting newlines in between the items
no way to tell how many lines ingredients will be on different screens
i donāt look at what people write, i look at the error - it clearly says received method therefore itās supposed to be called
itll be different for everyone
discord.Color.random
I am using sqlite db and discord.py, I am not sure why but when I do .setprefix ! it sends me a message it changed but it did not change.
didnt answer my question.
I want to buy a VPS for my discord bot. Thisās my first bot and also my first VPS, so Iām not sure what to choose.
there can be thousands of reasons why it isnāt in the !d docs - first being that there are multiple versions and shit changes
oh this is for a vps
might as well just use ubuntu server
oh wow i just checked on my phone and fields don't even appear on the same lines
i havent heard of a new color getting added
it's broken for everything
@manic wing which version do you recommend?
okimii, i donāt care what youāve heard of, because itās clearly wrong, proven by the error.
how tf am i supposed to format this so it doesn't look dumb on phones
probably the latest, which is v21 last i checked
Thank you šš»
Traceback (most recent call last):
File "/home/container/.local/lib/python3.8/site-packages/discord/client.py", line 373, in _run_event
await coro(*args, **kwargs)
File "main.py", line 54, in on_message
game = bot.games[msg.guild.id]
TypeError: 'set' object is not subscriptable
bot.games is a set.
!d set
class set([iterable])``````py
class frozenset([iterable])```
Return a new set or frozenset object whose elements are taken from *iterable*. The elements of a set must be [hashable](https://docs.python.org/3/glossary.html#term-hashable). To represent sets of sets, the inner sets must be [`frozenset`](https://docs.python.org/3/library/stdtypes.html#frozenset "frozenset") objects. If *iterable* is not specified, a new empty set is returned.
Sets can be created by several means:
⢠Use a comma-separated list of elements within braces: `{'jack', 'sjoerd'}`
⢠Use a set comprehension: `{c for c in 'abracadabra' if c not in 'abc'}`
⢠Use the type constructor: `set()`, `set('foobar')`, `set(['a', 'b', 'foo'])`...
why does my bot sometimes not find the command?
@slate swan
where can i find a valid url for the bot?
the things i tryed give "Unauthorized"
because i cant find it
Isn't it fun...
discord/colour.py line 331
Color = Colour```
it's the same for all fields on mobile.... inline does not work even if there's tons of space
v2.0
wtfff
That was like that since 1.7 or smth
it was
maybe from before that
im not sure why hes showing me the creation of the instance
š¤·
fffffffff
whats that:
as danny made it as aliases
it doesnt have any documentation.
because its an alias not a class.
hence why its in the docs.
u didn't load the cog
!d discord.Colour.green
classmethod green()```
A factory method that returns a [`Colour`](https://discordpy.readthedocs.io/en/master/api.html#discord.Colour "discord.Colour") with a value of `0x2ecc71`.
ah thats your point
not* in the docs
wdym?
same shit
that is a cog, right?
yw okimii
for what
yes
being a saint š
but how can i fix?
a what
@manic wing mind telling Marksman?
telling him what
to load his cog
cuz my script has an issue
the command isnt found its probably the cog hasnt been loaded or indents
@slate swan weren't u playing Clash Royale? š
the indents are loading
i lost
cuz the other commands work
we are here to give information, not give out free thumbs to suck
what
you arent
didnt i just tell you what you couldnt figure out?
infact i told you 3 things you couldnt figure out
in the space of 5 minutes
i love being cocky
not my point
my point is you are giving out thumbs to suck?
my only suckable thumb goes to you
so what can i do?

I want it to send a message every 10 seconds (I will change it to 3 hours)
Stop it @slate swan @manic wing. Take this to an ot channel
hunter jealous 
Ofc ofc

ok got i guess
show your code
i forgot to trigger
trigger what
wasnt your command giving an unknown command error
just use a task loop
@task.loop ?
that is so
another one that isnt officially documented š
!d discord.ext.tasks.loop | this is though <3
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
it is
not the module
ah
bows make that 4 things
smh
basic things which are all related to dpy and not experience or skill!
well basic is the building blocks to a better understanding of programming :)
and if you think you're on my level, be my guest to prove that to me
your so cocky its honesty embarrassing to have a conversation with you
im just gonna go and not waste my free time
š³
@slate swan
ive been watching too much suits
show us where you imported tasks
Why is it not defined
and can you show the rest of the code
dude you didn't import it
Oh
from discord.ext import tasks
theres actually no good way to format my embeds ffs
btw
when you fetch/get objects in dpy or any fork, they take ints as id's unless specified
read the docs dude
how do i format this to work on mobile, i can't use fields because they end up on new lines for each field, using a seperate field for each item takes up too much space. using plain text looks an absolute mess.
i think the only thing i can do is go back to trying to somehow work out spacing between words with code to manually create fields with plain text
š
at least that seems to be consistent across mobile and desktop
You need to provide Authorization header
what do i put there?
your bots token
i did that
Bot sfiuyiu43w4.w45gw45g.5gw4gw4oghiwp5okpow5kwpotopkopgk
That thing is "token" don't mind
Don't forget about the Bot before token itself
@bot.listen()
async def on_member_join(member: disnake.Member):
guild = ['772968562054660107']
role = disnake.utils.get(guild.roles, id=953020268656353350)
channel = bot.get_channel(953020283386757161)
await channel.send(f'Welcome to the discord {member.mention}! ')
await member.add_roles(953020268656353350)
bot.get_guild(guild[0])
to me?
K
K thx
!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.10)"). 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.10)") 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.10)") 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**...
{
4: "jl",
5: "i",
6: "ftI :,.[]|/!",
7: "r-()",
8: "^*",
9: "z",
10: "kx",
11: "bcdghnpqsuvyJ",
12: "aeoLT=+_?~#$",
13: "AFVZ",
14: "BEHKNPSUXY&",
15: "wCDR",
16: "mGOQ",
17: "M",
19: "%",
21: "W@",
}
figured out the widths of all characters in discord
jjjllljjjlll
ljljljjjljjj
ok
I need some ideas to script a fun bot in discord
doesnt everyone
for short periods š
Tell people to use a database instead (much more efficient)
imagine trying to asyncio.sleep for 10 days giveaway
Well, it'd work if your bot was online for 10 whole days
hey Cumali, didnt you just try to talk about efficiency and then say to use asyncio.sleep? o.O
Puzzle games
fps game 
i seem to remember that the other user never asked about efficiency either
can you guys take this to an ot channel?
i am not bringing anything up, was just reminding you :)
https://vcokltfre.dev here follow this guide
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
hey guys, what do you think is the best bot for moderation?
thx
eh
I meant wow

carl is sometimes offline
expected that
yeah, dyno best, hunter god gonna tell us
rip he stopped typing
welp
?
lol
how about YAGPDB? 
ewwww uhhh carl better
I LOVE that bot
Thanks to that, I don't have ban perms but can still ban people via the bot
I can't tell if you actually like it or if your sarcastically saying that
Both ig
šæ
You are off topic...
no?
Well this channel is for coding bots, not discussing famous ones.
who said that
That too (replied to Sten)
Channel topic Ig
The fact that this is a coding server and the channel topic
Hi!
||we can still talk about Lemon's uwuness|| alright
What the
Hello
after the prefix
He just didn't know bruv, no need to say that
I'm not trying to lie, I just didn't think so. š¤·āāļø
He was just tryna help u
No, he was lying
Stop it
If you say so
Well, the prefix still can't end with a space, can it?
I mean you can't say someone's lying if they don't know something
It can
why wouldnt it?
It just cannot start with a space, because discord strips the message content
there is also strip_after_prefix meaning it can have infinite spaces after
!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.
that is gonna remove all the spaces iirc
Would the command then be ! twospaces?
!d disnake.ext.commands.Bot.strip_after_prefix
Whether to strip whitespace characters after encountering the command prefix. This allows for ! hello and !hello to both work if the command_prefix is set to !. Defaults to False.
New in version 1.7.
yup
See this @slate swan
thats the point
Use infinite spaces now
Guess that isn't a feature in regular d.py?
Whether to strip whitespace characters after encountering the command prefix. This allows for ! hello and !hello to both work if the command_prefix is set to !. Defaults to False.
New in version 1.7.
Why dont i know anything
I also forgot about this dw
Caedan made me remember it
people forget about case insensitive 
what can I say? bows
I'm gonna go to bed
nobody forgets about that
cya gn
so you speak for everyone
im a people person
gn
I was wishing Sten, gn
ok

5 emojis in 5 messages
6 messages with 6 emojis*
whats that?
an asynchronous version of time.sleep
o where i found that?
!d asyncio.sleep
coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.
If *result* is provided, it is returned to the caller when the coroutine completes.
`sleep()` always suspends the current task, allowing other tasks to run.
Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.
Deprecated since version 3.8, removed in version 3.10: The `loop` parameter. This function has been implicitly getting the current running loop since 3.7. See [Whatās New in 3.10ās Removed section](https://docs.python.org/3/whatsnew/3.10.html#whatsnew310-removed) for more information.
Example of coroutine displaying the current date every second for 5 seconds:
whats the method that gets called of strip_after_prefix is True?
you want me to find it in the source code for you?
but how i make thwe giveaway bot thing?
Bruh, I am sleepy... I was googling what is the RGB value of red lmao
yes cayeden
!d discord.ext.tasks.loop @unkempt canyon
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
@slate swan*
```py
import time
async def sleep(delay: int) -> None:
time.sleep(delay)
discord/ext/commands/bot.py line 1204
if self.strip_after_prefix:```
discord/ext/commands/view.py line 72
def skip_ws(self) -> bool:```
merry christmas
thanks
???
nvm
I wish we could have the reaction perm here
same
Someone who can help with giveawy bot?
hm?
choose random member from ctx.guild.members
Not all of them has entered the giveaway I belive
ikr, every other help channel has it but this channel doesn't 
oh u need specify that 
I belive he wants something like this, if so the winner shouldn't be a random person from the server.
That was more off topic
Great!
we dont have it as this channel has a history of offensive reactions and because this channel is the most active out of topical channels its like the python general chat which doesnt have reactions on
When did you figure it out?
how do you know?
Uhhh, when I was using that for talking to someone all day long its ot
ive had a discussion about this topic with her before
Admin
admin
So i made a bot repos of a filtering bot for spam and swears, idk if it works i coded it ON github, not my ide - https://github.com/HRLO77/Discord-bot-filter
my eyes hurt
yesn't
How is that code related
yikers
Big yikes.
Nice!
i was wondering if anyone could review the code, because i haven't run it yet
i literally am chugging water as we speak
there isnt a need for another python file just for the words
Sounds like a big disaster.
use a text file because its still
it's cleaner
not rlly
š
looks like a waste of time putting it all in a dict
You made a bot in github bro.
chad or no chad?
that was the first of many mistakes
No chad
@quaint epoch you're 12?
13
Yes
He have a lot of em
who keeps calling me 12?
your about me.. 
it says 13
goddammit
why is flip a bad word š
Bro really against tos
You aren't even 20 days old š¤·āāļø
š
wait, u are reviewing the set, not the code?
no need for clusterfuck because fuck is already getting checked for. this itself is a clusterfuck
well i can't remove it now
why is slap a bad word
idk
and hac
Imagine barely going through discords age requirement
??
Your about me
its gonna censor rupee
okay no i don't remember adding that
yes, what's wrong with it
You did it all by hand????
butt
no
Phew
i wrote something to do it for me
regex 

You called someone 12 because of their about me, just funny that your says 20 days old
butt is not a bad word
are you criticizing what are considered bad words now?
Can you stop spamming images?
That filter sounds like a 6 year old saying your a bad boy for saying "blo".
it should be like 50 bro
you can never be too safe
theres no point for all of those
if your censoring "lo" and "it" i think its too safe
Bro just filter the whole english language
well you can choose which filter mode you're on
you have a cog inside of your main file š
Thats my birthday š
it's only one cog
in the entire thing
W h y i s e v e r y o n e s p a m m i n g i m a g e s
No list comps
well my on message function was in a cog, so when i took a bit of the filtering from that i just put it in a cog
because too lazy
thanks for contributing! unfortunately, no.
your "on message" function is overcomplicated asf
is everyone here just going through the dictionary?
no
im on the biohazard level 8 radioactive waste that is your bot
No im making fun of your function that can be done with lambda and list comps
i've been scrolling through reddit for so long i forgot to submit my music, art, dance, history, and geo assignments now science
why is the string called cache
i really cannot come up with a name
i would've named it a if i could
anyway i gotta go speedrun this
So much things that can be done better in that snippet.
you also dont need convert_to_list just use ```py
for i in string.replace(' ', ''):
if i == ',':
or better yet. just do this look for it in the message content
okay okay okay i get it
That whole snippet screams hardcoding
thnx
snippet?
Yes?
snippet?
That is so.
yes
what are you implying
Regex is the best thing for filters.
its easy
I mean.. don't make names misleading e.g
def get_coffee(obj: type):
return len(obj)
``` instead should be
```py
def get_len_of(obj: type):
return len(obj)
``` šæ š
and its like 3 lines
no return annotations 
(i don't have ocd okay)
then make all special characters change to a letter in the alphabet until they match
regex
optional
imma ignore
k
your point? on giving me information i already know?
its like 20 lines tops
@quaint epoch use https://pypi.org/project/better-profanity/ to filter swear words itās clean.



