#discord-bots
1 messages · Page 624 of 1
?
fuck
sorry im brain dead
👍
but it works the first 1 2 days
my code is open src, https://github.com/TechnoFrost27/chad-the-discord-bot/blob/main/cogs/tasks.py
i do hv tht
shows no error
there a way to fix this?
code
code
you're sending the get_prefix directly. Use Context.prefix for getting the prefix for the guild
ok so i have a bot for a server i'm in and it's sole purpose is to be annoying (it's approved by the server owner)
@bot.event
async def on_message(message):
if "im" or "i'm" and "sad" in message.content.lower():
await message.channel.send(f"{random.choice(okandgifs)}")
await bot.process_commands(message)```
i want it to check if "i'm" or "im" are in a message, and if either of those are in a message check if it contains "sad"
if it contains "i'm" or "im" and also "sad" it's supposed to send a gif
how would i go about this? i just tried using "or" to check if "i'm" or "im" is in the message but that clearly didn't work
if i take out the "or" and just use one version of "i'm" it works though
Use brackets
!or
When checking if something is equal to one thing or another, you might think that this is possible:
if favorite_fruit == 'grapefruit' or 'lemon':
print("That's a weird favorite fruit to have.")
While this makes sense in English, it may not behave the way you would expect. In Python, you should have complete instructions on both sides of the logical operator.
So, if you want to check if something is equal to one thing or another, there are two common ways:
# Like this...
if favorite_fruit == 'grapefruit' or favorite_fruit == 'lemon':
print("That's a weird favorite fruit to have.")
# ...or like this.
if favorite_fruit in ('grapefruit', 'lemon'):
print("That's a weird favorite fruit to have.")
just plain and simple change the description to description=f'{ctx.prefix}ban...'?
Kayle you need to await that function
kayle and i are different people lol
you cant use it in description
so would i do something like defprefix = ctx.prefix?
Oh , sorry
and then f'{defprefix}'?
no
Yes
Why define a variable for it and not use directly tho?
apperently i cant use it in description
¯_(ツ)_/¯
Any reasons for that?
so you will do like
@bot.command(description=f"{defprefix}ban...")
async def ban(ctx):
defprefix = ctx.prefix
```?
you cant access ctx from decorator
They meant the embed's description and not command's description
.
@bot.command()
async def ban(ctx):
eb = discord.Embed(title=f'', description=f'{ctx.prefix}ban', color=clr)
...```
File "D:\acrella\bot.py", line 59, in get_prefix
prefix = prefixes[str(message.guild.id)]
KeyError: '900421408402866257'``` KeyError is the server id, its happening because its not in the prefixes.json file, how can i make it so that if the server doesnt have a custom prefix defined in the json file than the prefix is the default `('^')`?
```py
def get_prefix(bot, message):
if not message.guild:
return commands.when_mentioned_or("^")(bot, message)
else:
with open("data/prefixes.json", "r") as f:
prefixes = json.load(f)
prefix = prefixes[str(message.guild.id)]
return commands.when_mentioned_or(prefix)(bot, message)```this is what i have as of now
guyssssssssss
^
if prefixes.get(str(message.guild.id), None) is None:
...
im guessing that this goes at the bottom?
like
if prefixes.get(str(message.guild.id), None) is None:
prefix = "^"
else:
prefix = prefixes[str(message.guild.id)]
return commands.when_mentioned_or(prefix)(bot, message)
```something like this
try moving your self.statusandfiles.start() to __init__ as on_ready could be dispatched multiple times. And see if it makes any difference
and by the way, you could replace this with len(self.bot.users) tho
for guild in guilds:
guild_count += 1
for _ in guild.members:
member_count += 1
!d discord.Message.delete
await delete(*, delay=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Deletes the message.
Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission.
Changed in version 1.1: Added the new `delay` keyword-only parameter.
so this deletes the user's message?
yes, if you mean !ping or smth
perfect thanks
you can use ctx.message for it
Commands have ctx argument don't they
Context.message returns the discord.Message instance of the message the command was invoked with
@bot.command()
async def cmd(ctx):
await ctx.message.delete()```
ok hold on
Oh
Hmm
I had same problem with changing voice chat name
I actually went to discord support and they said there were some issues with socket or smth
They sometimes happen for certain bots
Pretty sure you don't need websockets to change voice channel names
It's a simple PATCH request to /channels/:id
hmmm
well thn wht shld i do
aha no..... i hv tht too. Bot.user excludes bots and repeat members... i want len of all members of all guilds
member_count = 0
for guild in guilds:
for _ in guild.members:
member_count += 1```
this wont slow down bot tht much right?
no but it isn't the most efficient way
Hello I am currently making a bot about displaying my minecraft server's status
bot.users includes bots and to not repeat members you can set() it
this is the code:
import discord
from discord.ext import commands
import requests
client = commands.Bot(command_prefix="!")
@client.command()
async def minecraft(ctx, arg):
r = requests.get('https://aternos.org/server/' + arg + '?byName=true')
json_data = r.json()
description = json_data["server"]["motd"]
online = str(json_data["server"]["online"])
playerCount = str(json_data["server"]["playerCount"])
embed = discord.Embed(
title=arg + " Server Info",
description='Description: ' + description + '\nOnline: ' + online + '\nPlayers: ' + playerCount,
color=discord.Color.dark_green()
)
embed.set_thumbnail(url="https://i1.wp.com/www.craftycreations.net/wp-content/uploads/2019/08/Grass-Block-e1566147655539.png?fit=500%2C500&ssl=1")
await ctx.send(embed=embed)
i have bot.users too
It says there is no module named requests.
how
pip install requests```
basic py man cmon
See this is this is the difference rn
why does this happen everytime i restart my bot?
is your bot verified?
oh and add await self.bot.wait_until_ready() in the tasks.loop
@gloomy coral before the on_ready is called gateway already starts sending events and the code already starts accepting them
on_guild_remove receives test data I think
ohh
If your bot is written in cogs, just create a function with decorators
@yourLoop.before_loop
async def loop_waiter(self):
await self.bot.wait_until_ready()```
hmm
You can put several decorators for one function if you have several loops
Better do it in separated function
I don't think doing like you will cause performance issues, but it might slow loop down a bit
Anything wrong with them?
You're not following the naming conventions
It is up to you how to name them and I prefer camel case for loops
It's not really "up to you"
you can do that , but that's not correct according to pep rules
What happens if they dont vote for you, here and now?
sad
they cease to exist
ExtensionFailed: Extension 'cogs.games' raised an error: ImportError: cannot import name 'create_option' from 'discord_slash.utils.manage_components' (/usr/local/lib/python3.8/dist-packages/discord_slash/utils/manage_components.py)```
why?? it works everywhere else
Im still alive and i didnt ping you on reply
Does it do anything to code performance? No. It may only affect code reading. Such a pointless topic to argue about
i ignore
Lol
That does not change any kind of performance , but just the clearity of your code
As I said
Use from discord_slash.utils.manage_commands import create_option instead of your import
Slash commands are not components
And since loops in terms of style of code are usually used like classes are (someLoop.start() for example), I prefer naming them like classes but with lower camel case
Wrong
I never said they are classes lol
Classes are named like : ClassName iirc
Fine
I know that 
ok
what is iirc
If I remember correctly
whats wrong with some_loop.start() tho
Nothing?
Did I say there's anything wrong with it
Just move on
Yeah
how to DM user
!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**.
def batonPass(friends, time):
# Write your code here
array = []
if friends > time:
array.append(time-1)
array.append(time)
elif friends < time:
array.append(time+1)
array.append(time)
```
whats wrong whtis this code
How is that related to discord bots
There's nothing wrong with the code , depends on what you want to do
@bot.event
async def on_message(message):
await bot.handler.propagate(message)
await bot.process_commands(message)
muted = message.guild.get_role(912979586495684618)
message_split = message.content.split(".")
for message_word in message_split:
for bad_word in Filter:
if(bad_word == message_word.lower()):
await message.delete()
await message.author.add_roles(muted)
``` The bot is not deleting the message when the bad word is in between the message
because you split words at every . ,
I never saw anyone typing like : this.is.a.bad.word
no if my message is like this
Hi bad_word hello
Then the bot is not deleting
because you split words with .
It deltes when it is
bad_word
So how should change it
But there is a bad_word in the message
How?
You ain't checking if it's in the message , you check if message is bad word
ohh
Replace . With a space
I also want to make a discord invite check How can I do that
I am thinking of adding https://discord.gg/ in a list
but I am splitting up the message
hello I'm back
wdym splitting it up
I am spliting up the message
like h t t p s?
like dividing message into parts where there is a space
if there is a space in the message but I thought to change that
change that to...what?
for bad_wor in invite:
if(bad_wor == message.lower()):
await message.delete()
print(bad_wor)
print(message.content)
``` I thought that this code will check if there is a invite in a message
The split thing, I removed it
but this is not working 😕
well you did if(bad_wor == mesage.lower()) which literally makes no sense
remove the brackets
the small brackets ?
no
around if?
for bad_wor in invite:
if bad_wor == message.lower():
await message.delete()
print(bad_wor)
print(message.content)
lemme show you the whole function
and invite to make sure nothing is wrong with these as well?
👌
@bot.event
async def on_message(message):
await bot.handler.propagate(message)
await bot.process_commands(message)
muted = message.guild.get_role(912979586495684618)
message_split = message.content.split(" ")
for message_word in message_split:
for bad_word in Filter:
if(bad_word == message_word.lower()):
await message.delete()
await message.author.add_roles(muted)
for bad_wor in invite:
if bad_wor == message.lower():
await message.delete()
print(bad_wor)
print(message.content)
``` the first for loop is to check bad words
invite and Filter are 2 list
yeah remove the brackets around the first if as well
it is working fine
still remove them?
and where is invite declared?
yes, it looks ugly
invite = ['https://discord.gg']
and bad_wor?
for bad_wor in invite:
if bad_wor == message.lower():
await message.delete()
print(bad_wor)
print(message.content)
ohhhh
Look bad_wor after for
nevermind I forgot python for a sec, lemme think about this
is there any error message or has the bot suddenly stopped working?
no I think
so...the bot stopped working?
No it didn't
ahhh....
I get this Run time error but the bot didn't stop
try text = message.content
what is text?
and then if bad_wor == text.lower()
just declare any variable you like
make sure the value is message.content
yes let's test the bot again
yes
it works?
It works but there is a problem
what's the problem?
50%
if I send https://discord.gg/ it deletes
but when I send a full server invite it doesn't
because message_word IS ALWAYS going to be bad_word
It also doesn't work when I put the link after some text
are you an Admin?
^ look at the message above
wdym
did you pass all the required arguments?
yes
I was asking @tropic briar
what should I do
but cannot still
When trying to get the bots top role do i use
bot.user.top_role
or
bot.top_role
To solve the division problem 😭
idk why
bot doesnt have permissions
already done
I was gonna say bot.kick
hmm...
do you have an on message?
I have to go urgently I'll leave it to kayle
:bye:
on_message event?
anyone pls say how to get rid of this error
its probably just a replit error
O
Thanks @jaunty terrace i am coding a snakes and ladder bot
ok any other probs i will come back Cya :3
admin just to ban? and do you have a on_message event?
What error
i am writeing everything in the main.py file and i am not createing any file or folder is it ok? @boreal ravine or @jaunty terrace or anyone say is it ok?
- Why wouldn't it be ok
- you don't need to ping us, and my name is literally no ping
np
vouch_channel = bot.get_channel(891960155225350206)
if 'https://discord.gg/' in message.content.lower():
if message.channel.id == vouch_channel:
await message.delete()
await message.channel.send(f'{message.author.mention} was Advertising, If you think this was a mistake then try contacting our staff about it.')
await message.author.add_roles(muted)
``` Why is this not working
I want to make the code work only when there the channel ID = vouch_channel
Not related to discord
Ok, looking into it
if message.channel is vouch_channel:
@tropic briar that should work if im not wrong
I dont think vouch_channel returns an ID
vouch_channel = bot.get_channel(896754891882655764)
if 'https://discord.gg/' in message.content.lower():
if message.channel.id == vouch_channel.id:
await message.delete()
await message.channel.send(f'{message.author.mention} was Advertising, If you think this was a mistake then try contacting our staff about it.')
await message.author.add_roles(muted)
This is working, Thanks
Every object on discord returns an ID (if it exists)
Also you might need to remove https:// from the url since invite works even without them
oh yeh
advertise = bot.get_channel(893321334577303583)
if 'https://discord.gg/' in message.content.lower():
if message.channel.id != advertise.id:
await message.delete()
await message.channel.send(f'{message.author.mention} was Advertising, If you think this was a mistake then try contacting our staff about it.')
await message.author.add_roles(muted)
``` I want this code not to work in advertise channel but it is not working
The code is not working in any channel
Why do you even need to get_channel and just use it's ID? Just do if message.channel.id != 123456...
anyways I made it work 😅
it's better to make a variable
yes but you're getting the whole channel object from cache, which might lead to obvious errors related to caching
Like if the channel exists but is not cached, this will raise AttributeError
If you just need id of the channel and you already have it, you don't really need to have a complete channel object for it
Ayyy aman
It's working right now , let it work 😄
if you have guild intents enabled then it should be cached
Hi icy
hi
howdy, anyone wanna explain to me if there is a way to apply async or multithreading to this ?? :>
headers = {
'authorization': token
}
def get_discord_ids(channel):
counter = 0
response = requests.get(f'https://discord.com/api/v9/channels/{channel}/messages?limit=100', headers=headers)
r = json.loads(response.text)
present = r[99]['id']
print(present)
while(counter < 10):
try:
response_history = requests.get(f'https://discord.com/api/v9/channels/{channel}/messages?before={present}&limit=100', headers=headers)
r_history = json.loads(response_history.text)
present = r_history[99]['id']
kill_rep = []
for item in r_history:
current = (item['author']['username']+'#'+item['author']['discriminator'])
kill_rep.append(current)
kill_rep = set(kill_rep)
kill_rep = list(kill_rep)
print(present)
with open('accounts-semi.txt', 'a+', encoding='utf-8') as f:
for item in kill_rep:
f.write(item + '\n')
counter = 0
except:
print('error')
counter += 1
get_discord_ids('401019644938289153')
!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.
this channel is for discord bots
It is discord related
that's a part of a bot
looks like it isnt
my bad i am a script kiddie
Look at the last line
How can we detect mass ping in a single message
yeah, a function what about it
!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.
get_discord_ids
yes
howdy, anyone wanna explain to me if there is a way to apply async or multithreading to this ?? :>
async def
What
I don’t really understand either
😐
🤷♂️
like I said, this isn't the place to ask this
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.
Something wrong
Yes
Random.choice
oh thanks
!d random
Source code: Lib/random.py
This module implements pseudo-random number generators for various distributions.
For integers, there is uniform selection from a range. For sequences, there is uniform selection of a random element, a function to generate a random permutation of a list in-place, and a function for random sampling without replacement.
On the real line, there are functions to compute uniform, normal (Gaussian), lognormal, negative exponential, gamma, and beta distributions. For generating distributions of angles, the von Mises distribution is available.
!d random.choice you use this
random.choice(seq)```
Return a random element from the non-empty sequence *seq*. If *seq* is empty, raises [`IndexError`](https://docs.python.org/3/library/exceptions.html#IndexError "IndexError").
hi guys
Well
pass in an iterable
help me pls
like random.choice(reponse, response2) ?
What’s the error
No make a list
why does not work: specify the reason?
e ?
Not related to discord bots at all
wat
No e.g
list = [1, 2]
print(random.choice(list))
What’s your problem
oh tank
Learn python
Just a question why don't u use .reply instead of mentioning them in the embed
If you’re still learning you shouldn’t be doing discord bots
english?
oof
lol
We don’t know unless you show us the problem lmao
do basic practice things like a test or a game
Right, but just in case if api don't return any data due to some glitch or whatever, you should handle it too
copied code
You don’t have the right permissions
wdym???
idk
Your bot doesn’t have the right permissions
idk wut are u tolking
im noob
uh these guys are so lucky they get help for their problems, everyones ignoring the issue i got 
What’s your problem
#help-falafel message
@velvet tinsel
Bruh just delete the last code
I sent you a screenshot
Turn administrator on in your bot
done
Yeah do it again
Yeah
this?
Yep
where specify the reaskn
Run the bot again
@velvet tinsel
Do you have intents?
where specify the reason?
@slate swan HELP ME IM HELPING THREE PEOPLE
where specify the reason error?
Hi
Hello!
I don’t understand what you’re talking about
You all have to turn intents on
how
!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.
thx
THANK YOU KAYLE
YOU ARE MY SAVIOUR
!d intents
A tag already exists
I mean this already clears it out that they need to turn it on first if they even read what we give them
i om writed this intents
Control what
The bot
also
what
Whats hard to control in the bot?
@unkempt canyon
Uh well the !d command
Whats hard about it though
i have
Can’t find commands
And?
Show us the errors
2 is specify the reason
Ok
You mean the objects in dpy?
Yes
@velvet tinsel
Thats easy imo don't know whats hard about it 🤷♀️
Right let’s see
The guild name.
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User").
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.
hash(x) Returns the member’s hash.
str(x) Returns the member’s name with the discriminator.
What does *, do in your code?
Because that may be the error
And also disable the error handler
To see the error
@wheat heart
Am I doing it right kayle?
!e
def command(*a):
return a
print(command(1, 2, 3, 4, 5))
``` I don't really know what its called but I know you can use it and then pass in all the arguments after that into the parameter next t it
@boreal ravine :white_check_mark: Your eval job has completed with return code 0.
(1, 2, 3, 4, 5)
No I meant the *, argument
@wheat heart disable the error handler to see the error
It means
!cmd Hi there bro
arg will be equal to Hi there bro
Ok, that may be the error
there was no * argument
.
It's only like that in dpy, also that's known as a kwarg
** ** yes
👌
it's called a parameter
Ok
But still disable the error handler to see the error
?
@wheat heart hello?
I think he is offline
hm
can someone help me
how i can get the user's time zone ?
you cant
then how all bots show the time same like user's time
skyra and giveaway bot also shows
the giveaway's ending time
<t:1111111111:R>
what ?
i cannot giet the time of user?
skyra can show the time of user
how it do that ?
no but discord can convert it to the user's time zone
!d discord.utils.format_dt
discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.9)") for presentation within Discord.
This allows for a locale-independent way of presenting data using Discord specific Markdown...

can someone help me in #help-orange i am trying to make an economy discord bot pls
😭
Winrar
What’s the best coding laptop
Ok
There is none
It depends what you want to code
If you want to code some bots you don't need a really performant laptop
Whereas if you want to code stuff w/ backend that requires you to run a server in background, you need something more performant
I've heard of a gaming laptop, but never a coding laptop
i have a laptop with 4gigs of ram , intel i3 , and its enuf to suffice my coding needs
i would have been doing video editing and other cool stuff today if i had a good pc
its a timestamp
does get_user_info still work or has it been updated to something else
!d discord.Embed.timestamp
The timestamp of the embed content. This is an aware datetime. If a naive datetime is passed, it is converted to an aware datetime with the local timezone.
thats a timestamp too
i tried that it is not showing correct time
unix timestamps
ohk let me try once more
get_user_info , may i know what object had that function?
how to use that timestamp ?
gimme a sec
ok
Sup bud, haha.
DMs?
you would need a timestamp int for that , which datetime objects have
these are the valid timestamp types
!e py from datetime import datetime print(int(datetime.now().timestamp()))
@slate swan :white_check_mark: Your eval job has completed with return code 0.
1637835641
this is how you may get the timestamp
all good
that was an example , you need to use the timestamp function on your own datetime object
Now that I think of it, a giveaway bot is really easy 🤔
so pls tell how they show the time of user?
you dont need to show the time of the user
formatting it inside the unix timestamp will change it automatically
what does : <t:1637835641:T> show for you?
eh , you from india?
ic, it (the timestamp )would have appeared different if you were from some other region
yea
different users can see this different ?
what is this ?
its a unix timestamp
should i use datetime.now().timestamp() ?
<t: the timestamp int : type of timestamp> is how it works
.this a list of available time stamp types
type of timestamp ?
<t: the timestamp int : type of timestamp>
? what to fill inplace of that ?
yes there are many
<t:1637835641:F> , <t:1637835641:R> , <t:1637835641:f>
for example if i have my timestamp int as 1637835641 , i can use
<t:1637835641:F> for <t:1637835641:F>
i got it above from eval command
ohk
literally sent that a minute ago , its the timestamp type
how this happened?
<t:1637835641:F> ?
ohh
😓
so how i can get the time of the user ?
property roles: List[Role]```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [‘@everyone](mailto:'%40everyone)’ role.
These roles are sorted by their position in the role hierarchy.
like this
", ".join(role.mention for role in member.roles[1:])
only that code???
aaaa my bot users are using the bot
for giveaway can @slate swan u pls tell me
how to get the user's time ?
by that
User's current time?
make them input their timezone ig
?
Don't think you can get user's timezone
what is .join?
but other bots are doing
this is different in different timezones
!d str.join
str.join(iterable)```
Return a string which is the concatenation of the strings in *iterable*. A [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") will be raised if there are any non-string values in *iterable*, including [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "bytes") objects. The separator between elements is the string providing this method.
change your local timezone and see it will change 🤷♂️
They use guild region's timezone
but now we cannot get guild's region
that created a problem for me
just use utc time, the users will convert it to their local time
and i am finding new way :(
!d discord.Guild.region
that is showing wrong time
The region the guild belongs on. There is a chance that the region will be a str if the value is not recognised by the enumerator.
not working now
what?
@steep estuary 🤷♂️ i changed my timezone and see this
?
That's what I've been trying to explain for past 10 minutes
The Unix timestamps change according to the region
hmm
but that is not showing correct time
it's correct time , for that region
yeah coz i changed my timezone from IST to other one
🤷♂️ it is different for different timezone
is that current time ?
yeah
🤦♂️
:/
you have used the previous unix timestamp
thats the value of the timestamp you sent
use the current unix timestamp
hmm
how i can get the number ? ?
datetime module
<t:what is the number ?:F>
time module
^ @steep estuary
Yes
No
now = datetime.now()
then ?
¯_(ツ)_/¯
how i will get the number ?
<t:1637837431:F>
datetime module
but how by it ?
datetime.datetime.now().timestamp()
i did that
Then sub it into the correct format and send to discord for formatting
ohhh finally
i understood
i was doing datetime.utcnow().timestamp()
that was giving me wrong
you need to use int() around it since it returns a float
how i can add timedelta on it ?
int(datetime.now().timestamp()) + dt.timedelta(seconds=int(seccs))
```this will work ?
the + operator
??
smh
yes
try it and see 🤦♂️
not working
Whats the error
it is showing that int object will not work with timedelta
guys can someone help
def mute(user: discord.Guild.member.Guild.member, member: getattr(discord.Guild, 'member')):
if not member:
res = user
else:
res = member
guild = discord.utils.get(bot.guilds, name=str(discord.utils.get(bot.guilds, id=member.guild.id).name))
if not guild:
return
else:
pass
mute_role_list = []
mute_role_list.append(discord.utils.get(bot.get_guild(res.guild.id).roles, name="m"+"u"+"t"+"e"+"d"))
user.add_roles(mute_role_list[0])
class Response:
def __init__(self, guild):
self.guild = guild
pass
def reply(self, arg):
return "You have successfully been given the Muted role"
response = Response(user.guild.get_member(user.id))
await getattr(Response, "self.guild").get_channel(343944376055103488).send(str(int(bool(str(response.reply(None))))))
await bot.wait_for("mess"+"age", check=lambda m: m.channel == m.channel.guild.get_channel(m.channel.id), timeout=int(0.06 * 600 / 60 * 10))
return
please help
🤨
everyone knows it's getattr(discord.Guild, "member")
Whats the issue
you cant add an integer to a timedelta
I have no idea what getattr is
aa i got it
But sure
guys can someone help
def mute(user: discord.Guild.member.Guild.member, member: getattr(discord.Guild, 'member')):
if not member:
res = user
else:
res = member
guild = discord.utils.get(bot.guilds, name=str(discord.utils.get(bot.guilds, id=member.guild.id).name))
if not guild:
return
else:
pass
mute_role_list = []
mute_role_list.append(discord.utils.get(bot.get_guild(res.guild.id).roles, name="m"+"u"+"t"+"e"+"d"))
user.add_roles(mute_role_list[0])
class Response:
def __init__(self, guild):
self.guild = guild
pass
def reply(self, arg):
return "You have successfully been given the Muted role"
response = Response(user.guild.get_member(user.id))
await getattr(Response, "self.guild").get_channel(343944376055103488).send(str(int(bool(str(response.reply(None))))))
await bot.wait_for("mess"+"age", check=lambda m: m.channel == m.channel.guild.get_channel(m.channel.id), timeout=int(0.06 * 600 / 60 * 10))
return
that's the issue
but whats the issue
whats wrong
I just sent the issue
then what's this
exactly
the code..?
yeah but whats the issue
the code
oh my lord
send the error
no
ok
@velvet tinsel can you help
mf whats the error
my bot send commands double someone know how fix that? I think its error in code
Send the code
find our yourself smartass 😤😤😤😤
in which async def its can be?
😐
Ok we’re not helping you
mean :(
You didn’t send the error
lazy
😂😂
find out yourself
???
stop being lazy
I think he’s trolling
should be obvious with the code I sent
obviously not trolling
Tell us then?
😂
tell you what
Obviously not
Whats the issue in the code
@velvet tinsel
what is a command invoke error
😤😤😤 find out yourself lazy ass 😤😤😤
?
!d discord.ext.commands.CommandInvokeError
exception discord.ext.commands.CommandInvokeError(e)```
Exception raised when the command being invoked raised an exception.
This inherits from [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError")
I have programmed millions of frameworks for my company you can't underestimate me 😤😤😤😤
@prisma spoke read the docs
Bruh
😝 I know when someone’s trolling
he's trolling, just don't reply
Annoying
or you will add the mess
@velvet tinsel its error
Exception raised when the command being invoked raised an exception... now what does this mena?
what exception
who
read the error there should be more to it
You
use get_emoji(id) for custom emojis
this is from the docs
not icy but ok
but emoji working normal
yes "Exception raised when the command being invoked raised an exception."
an exception raised when the command got invoked
what exception ?
your error
the error is the exception 🤦♂️
It was a raised error 😂
i used the ban cmd..and
File "C:\Python310\lib\site-packages\nextcord\ext\commands\core.py", line 168, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\admin\Downloads\ROG.py", line 952, in ban
await member.ban(reason=reason)
File "C:\Python310\lib\site-packages\nextcord\member.py", line 621, in ban
await self.guild.ban(self, reason=reason, delete_message_days=delete_message_days)
File "C:\Python310\lib\site-packages\nextcord\guild.py", line 2642, in ban
await self._state.http.ban(user.id, self.id, delete_message_days, reason=reason)
File "C:\Python310\lib\site-packages\nextcord\http.py", line 329, in request
raise Forbidden(response, data)
nextcord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\nextcord\client.py", line 351, in _run_event
await coro(*args, **kwargs)
File "c:\Users\admin\Downloads\ROG.py", line 627, in on_command_error
raise error
File "C:\Python310\lib\site-packages\nextcord\ext\commands\bot.py", line 995, in invoke
await ctx.command.invoke(ctx)
File "C:\Python310\lib\site-packages\nextcord\ext\commands\core.py", line 895, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Python310\lib\site-packages\nextcord\ext\commands\core.py", line 177, in wrapped
raise CommandInvokeError(exc) from exc
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions```
this reminds me of my dad
you have entered an invalid emoji id
Missing permissions
bot?
so which one exactly is your problem? There are 2 errors there
yes, or it's trying to do something impossible
bot send commands double
curious
dream stan #ot0-psvm’s-eternal-disapproval
the error is cuz i am banning the server owner.. ig but i have this line
return await ctx.send("The member is either higher than you or same as the post of you in the role hierchy")``` which didnt get invoken
invoked
urs
I know how to solve your error just rerun the program
out of the box answer..
you probably have 2 instances/scripts running paralelly
ranger being funny
@boreal ravine good afternoon
isn't even afternoon here
bre
good evening
good morning?
who here is British
It is here
!ot <= please
Off-topic channels
There are three off-topic channels:
• #ot2-never-nester’s-nightmare
• #ot1-perplexing-regexing
• #ot0-psvm’s-eternal-disapproval
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
I’m in Britain but not British
mods don't ban I just want to know if any bot dev here is British
Me but not British
@slate swan can you stop posting random things?
ctx.guild.name is correct?
ok
Because you said afternoon and mentioned British, and I recognised the connection
yes
There’s a reason why his name is “homoTROLLius”
we do a miniscule amount of trolling
Please leave if you’re gonna troll
I cant find any
yes it is. I already have the coding for playing the song, its the commands for making a queue I need, and it aint that simple.
Use an array?
I didn’t know anything about an economy bot and I learned it
what is that?
Or a list
🤦♂️
An array is literally a list though
🤦
👌
if I have a message object, how do I create a link to that message?
array of what then
Message ID
hm?
!d discord.Message.jump_url
property jump_url: str```
Returns a URL that allows the client to jump to this message.
🤦♂️
there are small differences
oh Thx
"Small" I'm not trying to start an argument smh
!d array.array
class array.array(typecode[, initializer])```
A new array whose items are restricted by *typecode*, and initialized from the optional *initializer* value, which must be a list, a [bytes-like object](https://docs.python.org/3/glossary.html#term-bytes-like-object), or iterable over elements of the appropriate type.
If given a list or string, the initializer is passed to the new array’s [`fromlist()`](https://docs.python.org/3/library/array.html#array.array.fromlist "array.array.fromlist"), [`frombytes()`](https://docs.python.org/3/library/array.html#array.array.frombytes "array.array.frombytes"), or [`fromunicode()`](https://docs.python.org/3/library/array.html#array.array.fromunicode "array.array.fromunicode") method (see below) to add initial items to the array. Otherwise, the iterable initializer is passed to the [`extend()`](https://docs.python.org/3/library/array.html#array.array.extend "array.array.extend") method.
Raises an [auditing event](https://docs.python.org/3/library/sys.html#auditing) `array.__new__` with arguments `typecode`, `initializer`.
I dont understnad. Im new to coding
Find a python library that plays music
just use a normal list
If you’re new you’re not supposed to be doing discord bots
eh so I do smth like ```py
url = message_object.jump_url()
its a property
the array module is bearly used
which means?
I have coded html websites and then I wanted to move to some more advanced stuff, and discord bots is acutally a good start.
Learn python or else you’ll be asking a looottt of questions that any simple python coder can j
no it isn't a good start lol
where?
It’s not
See 😂
what is a good start then
simple projects
Basic python
!e
class Message:
@property
def jump_url(self):
return "jumped"
print(Message().jump_url)
``` no need to call it
@boreal ravine :white_check_mark: Your eval job has completed with return code 0.
jumped
like?
Learn print at least
Lists, dictionaries, class, functions
printing, data types, oop
f strings, variables
and I don't need to await it?
you dont need to learn about f-strings, those are the basics smh
It isnt a coroutine, so no
Well he doesn’t know any basic stuff
print(thislist)```
He jumped straight to bots
thx alot, I'll try to figure out smth
this is a list right?
👍
ye
and what can I use that for exactly
🤦♂️
to group multiple items together
lots of things
image flipped 
but is a list only used for print commands
technically it's discords fault, 👍 is usually above 👎 and not the other way around
no
okay
You can do a lot with lists
do some simple projects, search on google for some ideas
you'll get the hang of it
If you really want to do discord bots, buy python crash course book, should get you up and going
DONT SKIP EVERYTHING READ EVERYTHING THROUGH OR YOU WONT UNDERSTAND
okay. Im guessing that its a bad sign that I search EVERYTHING i do in python up on google
just a reminder
A bit
kk
I search some stuff I don’t know
Section/Part | Importance rate in dpy (1-10)
---------------------------------------------
Variables | 10
Casting | 6
Operators | 5 (not that important, but you'll still use it)
Arrays | 7 (very important)
How to import something | 6
Functions | 9 (the base of dpy & all modules)
What asyncio does | 6
Scopes | 6
Typehinting | 9 (a must for commands)
Decorators | 6 (a function inside a function)
Object Oriented Programming (OOP) | 10 (a must for creating command groups AKA cogs)
Subclassing/Inheritance | 7
---------------------------------------------
``` made this myself, it shows you whats important in dpy and what you should learn before using dpy
not really, even senior devs need to google shit up. googling is ok, just that you shouldn't be doing discord bots as a beginner
what that for me?
variables should be 10
Yep.
sure
okay, but like the only thing a know how to do is the print command
what you should learn before diving into discord bots
Exactly
go do a py course on udemy or youtube
personally think web tuto's are better (realpython etc)
Did you write it in a code block just because you can or is there a reason?
Asyncio should be 7
or 8
just because I can
not that important
what was correct way to fetch a message ```py
await fetch_message(id)
fetch_message(id)
haha okay
Add dictionaries
videos were easier for me to follow when I was a beginner
so is discord bots what you guys are mainly coding?
how i can get timestamp of member.created_at ?
fk
For me yes, but I’m also doing bot and AI
!d discord.Member.created_at
property created_at```
Equivalent to [`User.created_at`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.created_at "discord.User.created_at")
for me not really. I do Android and web app development mainly
should I just copy it in to my vs code?
eh, me too, but I used web tutorials for the hard parts (oop)
games? or onyl apps?
Oh I’m blind
i guess if you want
apps
kk
what is correct format for this? Do I need smth like ctx.guild... ```py
await fetch_message(msg.id)
channel.fetch_message
Channel being ctx.channel?
hmm
can be any channel object
or ctx.guild.channel
doesn't need a guild
👌
afaik
Oh ok
msg: discord.Message can I give a message link to this obj?
I dont really use channels a lot
@boreal ravine what are the numbers for? how hard it is?
or only ID?
!d discord.TextChannel.fetch_message
await fetch_message(id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") from the destination.
I think so, but read the docs first
the importance rate in dpy
I alrd read that
dpy?
discord py
yeah, variable difficulty is like 0 or 1
!d discord.Message
class discord.Message```
Represents a message from Discord.
x == y Checks if two messages are equal.
x != y Checks if two messages are not equal.
hash(x) Returns the message’s hash.
ahhhh
???
an api wrapper for the discord api
What
how i can get timestamp of discord.Member.created_at ?
@boreal ravine do I just search the words up on google, or is there like a good website or a dictonairy?
googling works
I'm working on the whois command and I was inspired by this video https://www.youtube.com/watch?v=yeuuB7qiTbQ and I want to make a date like mee6
This my code
@bot.command(aliases=['user','info'])
@


