#discord-bots
1 messages ยท Page 808 of 1
Id love to contribute but Iโm not much of a Python dev anymore
So it isn't presently in usable form?
Currently only a few models are semi-implemented, the only thing COMPLETELY usable is the backend stuff, caching, dispatching, event listeners, one-time events, event collectors, waiting for events, intents, gateway handling, member chunking, etc
Because you spelt it moai 
๐ฟ
It's in a form now where it's enough for anyone of a certain skill level to extend the wrapper itself
But it's not very good for new-users right now?
Or users who want a lot of syntactic sugars
it seems like your wrapper is for more experience devs
wait, you code C#, right?
docs are also a hurdle you need to jump
I'm an advanced python user, if it will improve time to implementation for the menu system I already want to build I'm willing to learn
As I don't have much documented
but making it better for beginners would mean very good docs
You'd be reading the source code to do your stuff
mhmm why
disnake.ButtonStyle cant set custom hex?
Is there a discord wrapper for C#?
yea
K
DSharp+ or something
that's fine if I can additionally ask you the occasional question via DM? If that's an acceptable thing I'd be willing to give it a try
D ๐
My DMs are off right now, but if you check the repo you will see the discord invite link to my Rin support server
There I recommend joining, as I post updates, talk with everyone for suggestions, etc
I also do some sneak peeks
I don't see the link in the repo, where is it?
I would say for now, if you plan on using the wrapper I wouldn't do any serious project. As the wrapper itself right now is in pre-alpha and is meant to be used bleeding edge
In the read me
The discord badge
Got it ๐ Never seen that in a git repo
I never knew how to do badges ๐ฟ
I had toxickids make a PR for me ๐
member = ctx.author
with open("users.json", "r") as f:
data = json.load(f)
data[str(member.id)] = {}
data[str(member.id)]["coins"] = 0
data[str(member.id)]["inventory"] = []
with open("users.json", "w") as f:
json.dump(data, f, indent=4)
Can anyone help me, I did import json
So if I'm understanding correctly, this is intended to be a wrapper for the entirety of dpy?
The only thing that I plan for the wrapper to have in common with discord.py is the native API part, I don't plan on adding chat command extensions, instead keep the wrapper fully native with discord's API, also adding a few syntactic sugars here and there
Since I see in client.py example you're handling starting the bot with a key I'd assume the intent is handling all of the methods/calls that dpy does, is that a correct assumption?
The client will handle the RESTful API, Keeping gateway alive, handling the gateway and then handle subscription of event listeners
Uh so im using digital ocean for the first time and ive been hit with a problemo
Very cool! I'm excited to see it as it grows, perhaps when it reaches some maturity I'll take the time to rebuild all my methods on your wrapper ๐
looks like you need to install tkinter
Done that
Tkinter in a discord bot?
Not sure why you would need Tk for a bot tho
No clue
on my local host it was going fine
but on remote host (im using digital ocean)
that message keeps poppin up
and ive never used Digital ocean so i dont wanna assume anythin i dont know around it lmao
nvm fixed it
guys got any good servers for js or nodejs?
servers that are big like this one
well at least 1/10th as big
Uh okay so now its running
how do i keep it running
If anyone knows could use the help. I normally use Repl it and im new to digitalocean so yh
Lol
Mhm
Are you a Muslim by any chance?
ofc lol
hey guyss
def check(message):
print(message)
return message.author.id == ctx.author.id
try:
message = await client.wait_for('message', timeout=15.0, check=check)```
Idk why its not working, when i print the object it shows the contents of the object like expected, but i cant grab it for some reason, some bullcrap about "typeerror: cant unpack"
based. accept req.
except asyncio.TimeoutError:
print('You need a timeout error')
return False
you need to try and catch both, not just try
is this alot ?
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
3803 xxx 20 0 814956 111612 12580 S 2.3 10.9 2:51.04 python3
Tasks: 102 total, 1 running, 101 sleeping, 0 stopped, 0 zombie
%Cpu(s): 4.3 us, 0.3 sy, 0.0 ni, 95.0 id, 0.0 wa, 0.0 hi, 0.3 si, 0.0 st
KiB Mem : 1020244 total, 472848 free, 178840 used, 368556 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 682936 avail Mem
its a discord with 7 users ๐
but it has 3databases, and runs 2 tasks
Is it possible to make sure that when a person deletes a photo or file, on_message_delete contains the name of the file, like this
i alreayd have that
lemme show the whole thing
!d discord.Attachment.filename
The attachmentโs filename.
Okay
Can anyone help me with starting a python file on DigitalOcean
im using PM2 but it wont work
Ty
Let's see the entire code and the entire error
If they're long you can use:
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
You asked at 12 am
What do you expect
Which channel is this in? I'll take a look and try my best to help
To answer your question, just use a dictionary
Already closed, and about to be claimed by someone else
Open a new one and let me know
!e
dict_ = {"a": "simple dict"}
print(dict_["a"])
@final iron :white_check_mark: Your eval job has completed with return code 0.
simple dict
how about that list of tuples idea?
a dict will only make things harder
well, tuple sounds good but i'd need to grasp it a bit better
How would a dict make things harder?
Since he needs to get a random question, then the corresponding answer
Would be easier to have a list of tuples
^
Just get the keys and use random.choice
questionsAndAnswers = [
("question 1", "answer 1"),
("question 2", "answer 2"),
]
Then to get a q & a, just do:
questionsAndAnswers = [
("question 1", "answer 1"),
("question 2", "answer 2"),
]
question, answer = random.choice(questionsAndAnswers)
instead of messing with indexes of dicts and whatnot
Feel free to ask any questions about it
oh how do i append tho
qAndA = []
qAndA.append(("question 1", "answer 1"))
How would I give a user permission to a channel upon a command, e.g. !add <user>
You'd have to assign to them a role that has the permissions to make channels
Then give them that role when they run the command
Or do you mean they should just be able to view it?
able to view that one channel and type in it
overwrites = {
guild.default_role: discord.PermissionOverwrite(read_messages=False),
payload.member: discord.PermissionOverwrite(read_messages=True)} this gives a user access when its created with
create_channel = await guild.create_text_channel("Middleman-Ticket", overwrites=overwrites)
just a question, im using motor client, so i don't have to import pymongo[srv] right
anyone got any suggestions on how I could implement a reminders system to my bot. I was thinking of having a remind <date/time> <message> command which logs ctx.author.id, ctx.guild.id, date/time and message to my database which I can setup (mostly) without issues (haven't made it yet) but I'm not sure how to make the bot actually send the reminder, I was thinking maybe use a task set to run every second or something but that seems excessive and expensive on my bot if it's making a database call every second and I also thought about just making the remind command sleep until the provided time but then how do i deal with the bot restarting. I'm mostly just wondering how y'all suggest I go about making the set send the reminders
https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.loop, you can pass in a datetime.datetime object to the time kwarg
tasks.loop(time=..., ...)
...
Unable to convert 'remindmef' to valid command, tag, or Cog.
!src remindme
Commands for managing your reminders.
def automate():
payload = {
"content":"SA",
"message_reference":{
"guild_id": "903733750062547025",
"channel_id": "904437095207170068",
"message_id": "939988992152203334"}}
header = {'authorization': token}
r = requests.post(f"https://discord.com/api/v9/channels/{channelId}/messages",data=payload, headers=header)
print(json.loads(r.text))
automate()```
hey does anyone know how to reply to a message with requests? i try this and i get the error
`{'code': 50035, 'errors': {'message_reference': {'_errors': [{'code': 'MODEL_TYPE_CONVERT', 'message': 'Only dictionaries may be used in a ModelType'}]}}, 'message': 'Invalid Form Body'}`
how do you get user game activity
like, i want the bot to get the name of the game a user is playing if they're playing a game and its connected with discord activity
AttributeError: 'User' object has no attribute 'guild'
guild = member.guild
anyone got a quick fix
okay thanks for showing me that as i wasn't aware i could pass time into the task, next question; since I'm storing the time in the db how do i then pass that to the loop? since i access the db data via await and await needs to be inside of a function to work but I can't put the await inside of the task since it nedds to have the data to give to the task function (if that makes sense)
I see what you're asking
Let me see how @unkempt canyon does it
Hm yeah, that's actually a very good question
I'm not sure how you would do that ๐ค
if a python helper doesn't know then it must be complicated
https://github.com/python-discord/bot/blob/ee5a2166e08805a31dd6141db663ccacfde0b551/bot/exts/utils/reminders.py perhaps you might have better luck than me
No it's just that i've never actually made a remind command, i thought the loop approach would work but with the database i'm not sure how it would
You could use asyncio.run()
That should only be used to kick start the event loop
Not as a "use coroutines outside of async"
I'm looking at reminders.py for @unkempt canyon and it's not immediately obvious what's alerting it that it's time for a reminder to be sent
also different thing, can i type hint datetime in commands?
Unfortunately no
Pretty sure there was a tag on the official discord.py server for a custom time converter, worth checking it out
You can type hint a custom time converter doh
If you run your task set on a separate thread, then it should not affect your bot. Though running a few tasks every few seconds won't really affect much (thanks to async).
I'd say... you should use apscheduler. Do something like: User runs command > Create a job and ask apscheduler to schedule it and store it in db > In case bot restarts, fetch pending jobs from db and reschedule them
worked for me
I've had a look and I keep seeing this self.bot.api_client but GitHub doesn't seem to be able to work out where it's coming from
could you send me some links about this? I've never used apscheduler (at least not knowingly)
https://apscheduler.readthedocs.io/en/3.x/userguide.html#configuring-the-scheduler
Use a BackgroundScheduler which will create background jobs and won't disturb your bot too
Seems like they have their own API: https://github.com/python-discord/api
This might be how the bot does it, I did see something about a Scheduler class in the__init__ of the reminders.py
Python Bot does not use apscheduler but instead create asyncio Tasks and store them in a list, not sure if it also handles comditions like bot restart https://github.com/python-discord/bot/blob/ee5a2166e08805a31dd6141db663ccacfde0b551/bot/utils/scheduling.py#L40-L61
And maybe you can use https://dateparser.readthedocs.io/en/latest/ to parse human time instead of typehinting a fixed format
Or make a custom time converter, yes
yeah I've just been checking out dpy's tags on time converters
guess learning apscheduler is my next big task
It's not that hard for simple use like this one.. ```py
from apscheduler.schedulers.background import BackgroundScheduler
scheduler = BackgroundScheduler() # Attach this instance to your bot as a botvar
Now to add and remove jobs, just do like ```py
def remind_user():
send_message_to_user_about_reminder_time_completion()
def command_to_create_reminder(time):
bot.scheduler.add_job(remind_user, 'interval', seconds=time, id="some_unique_id")
You can also create a cancel command like ```py
def command_to_cancel_existing_reminder():
bot.scheduler_remove_job("same_unique_id_which_you_used_while_adding_job")
Ofc you can do more customizations like storing jobs in cache or db, loading and unloading them on startup and cleanup, and more... It's the most basic usage you need to do to create a reminder command
Oh that's good to know, thanks for the explanation
a wait does somone have alr made currency script thingy ?
or economy idk what the name is
and idk am i allowed to ask that
Sure, you can ask help on how to make a currency functionality for your bot
a dam how can i make one ?
and now if u ask do i have a script uuuuh nop
First off I'd recommend choosing a database to work with, for keeping track of user balances
Relational:
- MySQL
- Sqlite
- Postgres
NoSQL: - mongodb
nani how i do that
Do some research and pick out which one you want. As a starting place, sqlite is probably the easiest to deal with but the most limiting. Postgres is a favourite of a lot of people, it's quite robust but at the cost of not being as easy to set up
a nani it cossts ?
If you're self hosting none of them cost anything
o
It should be bundled in with a VPS if you go the non-AWS route
If you go with AWS, they have a seperate service for databases
o alr
how to use a command inside of a slash command?
im using pycord
Basically, I call blackjack with /blackjack but now I need to figure out a way to allow the user to hit or stand
Maybe buttons on a message the bot responds with to show the starting cards?
buttons are a pain for me right now
how would i go about doing it with a on message event or something
Would be a problem considering bots don't get message intents starting april
Buttons would be your best bet
One for hit, one for stand
Yep
TypeError: can only concatenate str (not "Guild") to str what does this error mean?
show code and what line raises that
there is prolly something that returns an integer there (message.guild, message.author, message) prolly
you want to make it a string
and pls use f strings
!f-strings
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
You can't add together (if you can say that) a guild object and a string
You can only add strings to other strings
^
iirc str(guild) will return the guild name
alternatively, you can do guild.name if you like that better
and consider using f-strings for your purposes here
Hi, just checking in with a update on what I've done so far so i can check I'm on the right track```py
from apscheduler.schedulers.background import BackgroundScheduler
scheduler = BackgroundScheduler(bot)Is what I have on my main file, and this is what I have in my new reminder.py filepy
import asyncio
import logging
import typing
import discord
from discord.ext import commands
from discord.utils import get
from utils import checks
from datetime import datetime, timedelta
from typing import Optional, Union
from classes.converters import DateTime
log = logging.getLogger(name)
class Reminder(commands.Cog):
def init(self, bot):
self.bot = bot
def remind_user(self, member):
#send_message_to_user_about_reminder_time_completion()
user = await self.bot.get_member_guild(member.id, member.guild.id)
reminders = await self.bot.get_reminders(member.id, member.guild.id)
embed = discord.Embed(title = "Here's your reminder!", description = "{reminders[5]}", timestamp = reminders[6])
if user[9] == True:
await member.send(embed = embed)
else:
ctx_channel = await self.bot.fetch_channel(reminders[7])
await ctx_channel.send(embed = embed)
def create_reminder(self, time):
self.bot.scheduler.add_job(remind_user, 'interval', seconds=time, id="some_unique_id")
def cancel_reminder(self,):
self.bot.scheduler_remove_job("same_unique_id_which_you_used_while_adding_job")
@commands.command(description = "Create a reminder.", usage = "send <server ID> <message>")
async def remind(self, ctx, time: DateTime, *, message: str):
await ctx.reply(f"Okay {ctx.author}, I'll remind you about '{message}' in {time}")
await self.create_reminder(time)
def setup(bot):
bot.add_cog(Reminder(bot))```I don't think I'm doing remind_user correctly as I'm getting "await" allowed only within async function
async def remind_user
that makes more sense
๐
should my other functions also be async?
dont have to be
they should be though if'
they are api calls (in this case commands and listeners)
Im trying to import slash commands but uh
from discord_slash import SlashCommand, SlashContext
from discord_slash.utils.manage_commands import create_choice, create_option```
says discord_slash doesnt exist
oh no, not discord slash
it works but not in the way i want it to work ๐
!f-strings
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
it should be
f"{message.guild} {message.channel} {message.author} {message}"
so what is it then?
plus its not really my fault they making it mandatory anyways
use a fork like disnake that has slash commands and tons of extra features built in
id like to actually learn how to create slash commands first lmao
so how do i import?
i need disnake to install discord_slash or something?
i dont get it?
im just tryna import the module i need for slash commnds
yeah do you have discord_slash installed
this has nothing to do with disnake, i just brought it up because its a better alternative
oh okay
ill try it after i can figure this bit out
why is it saying module not found for me?
from discord_slash import SlashCommand, SlashContext ModuleNotFoundError: No module named 'discord_slash'
prolly isn't installed as i said
pip install discord-py-slash-command in your terminal
pretty sure thats the install
np
Slash command implementation is different from fork to fork
It's better to start with something that actually has good implementation like disnake than use discord slash now and have to relearn it when you eventually switch
^
The implementation varies greatly because the maintainers of the forks had to implement slash commands themselves
l
real quick what does it mean when in the error box it says "int/float is not subscriptable"
integers and floats are not subscriptable like lists and dicts. you can't index them
!e
a = 123456
print(a[:2])
@final iron :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | TypeError: 'int' object is not subscriptable
You can do
"this is a string"[0] # t
But you can't do:
123456789[0]
You'd need to do a bit of math to get the Xth digit of an integer
(i.e do integer division and % 10)
I was trying to multiply a number by a number in a table and it gave me that
so ig I have to make it a number?
Can we see the code?
what can i help him with
how to make slas command?
Well first you need to pick your preferred lib
I would suggest disnake
If you choose disnake give this a read: https://docs.disnake.dev/en/latest/ext/commands/slash_commands.html
alr
You can also use py-cord because discord.py got discontinued
or nextcord
all three have slash command capabilities.
mhm
if you do want discord.py, as stated here, there is a module for discord.py that allows slash commands
Py-cord is one of the worst forks
Even Danny has stated specifically that he doesn't like it
||https://github.com/XuaTheGrate/slash_util|| there's an officially supported discord.py slash command
alright
really?
yeah no shit, py-cord is literally discord.py but continued
im gonna try using disnake for now
py-cord works perfectly for me
Yes
same
i use pycord only because i dont care about slash commands
All of the forks are discord.py but continued
They're called forks for a reason
did they change their namespace?
Wdym?
discord.py has the namespace "discord" so does pycord
but did disnake change their namespace
Wdym?
then yes, they did change their namespace??
usually, discord.py is
import discord
after looking at disnake's github
i just saw its
import disnake not discord.
Disnake changes the namespace only if you use the shim
Well yeah, using the discord namespace is bad practice
shim?
!pip discord-disnake
ohh
@client.slash_command(description="Responds with 'World'")
async def hello(inter):
await inter.response.send_message("World")```
from disnake code
but ain't workin
Did you read the getting started I send?
I know of @ client.command()
But how can I just run a command in a loop? Say every 10 minutes to just have it log something to the chat?
!d discord.ext.tasks.loop
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
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").
@fickle bloom ^
you could do it multiple ways, like writing your functionality under the decorator function itself, or possibly call a command when the decorator is called with Context.invoke()
@client.slash_command(description="Responds with 'World'")
async def hello(inter):
await inter.response.send_message("World")```
I don't understand da error
i dont see an error.
well its quite self-explanatory
Seems.like you're not using Disnake but some other fork/og dpy
your bot object has no slash_command attribute. meaning, slash_command is not a thing with your bot object.
No
So how to fix it
that doesnt magically add an attribute to your bot.
change your bot object from discord.ext.commands.Bot to disnake.ext.commands.Bot
basically, use disnake. not discord.py
oof
async def send_message():
while True:
channel = channel = client.get_channel(mercspam)
await channel.send('sgfag')
time.sleep(15)
send_message()
RuntimeWarning: coroutine 'send_message' was never awaited
send_message()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
How can I call this function awaited?
new to python, sorry
Coming from react where you can just call a function like this
if your send_message() function is under the tasks.loop() decorator, you need to start it via your on_ready() function. await send_message.start()

unless there is a more efficient way?
I don't have any decorators setup
You might want to reconsider your time.sleep(), and have an asyncio.sleep() to not block your program
this is a library I can pip install?
Yes
asyncio is the back bone of every Python async program
Done
It's in the stdlib
regarding the question you asked earlier, your solution should be a tasks.loop() decorator from discord.ext
perfect, exactly what I need
@tasks.loop(seconds=5.0, count=5)
async def slow_count():
print(slow_count.current_loop)
@slow_count.after_loop
async def after_slow_count():
print('done!')
slow_count.start()
as far as im aware, you need to start them via your on_ready function
what's a type of discord bot that hasn't been done yet
this works, because it gives me the context of client to send my messages with. Thanks
you're welcome.
also, just a tip, dont name your bot object client this can be confusing and arguably incorrect as discord.Client() is a thing , you're naming the bot object "client".
@ client.event
async def on_ready():
slow_count.start()
print("BigChuckle Initialized")
@tasks.loop(seconds=5.0, count=5)
async def slow_count():
channel = client.get_channel(spam)
await channel.send('some message')
This worked perfectly.
- client = commands.Bot(command_prefix='$')
+ SomethingElse = commands.Bot(command_prefix='$')
like this?
Also, what's best practice for var names? I think SnakeCase right
it should be bot = commands.Bot(...)
ah, snake_case
this_is_snake_case
is for functions right
yes
PascalCase for vars?
pascal case is more for class definitions
Ah okay
pascal - class
snake - literally anything else
camelCase is just something else
Thatโs not camel case
other way around sorry
Capitalization is explicit in React, if you use PascalCase it's a component 100%
now it is
Won't even compile properly, so I figured I'd ask to clarify
but it seems python doesn't really care much, I heard it changes performance though
it doesnโt
var names can use different naming conventions, depending on whether its a global variable or not.
Itโs just a naming convention
other factors also play a role in the way you should name your variables
Do you have to declare or export vars for Globan python? Or can I just import X from Y?
In react we have to export var for example, for imports to work
Tbh, I should just read through pythons docs, unless there's a better resource
you dont need to export anything, you may directly from x import y
!pep8
Thanks
๐ตโ๐ซ tabs or spaces, oh no ๐
Who needs commands when you can just remember the links. Ez
faster lol
Tabs all day everyday baby
With a width of 4 spaces
1 space indents
actually. your indentions should be 4 spaces, but normally we use the tab key which will convert to 4 spaces.
You know thatโs what I meant smh.
mhmm
Cease your heresy.
@client.slash_command(description="Kicks a member")
@client.command(brief="Kicks a user")
async def kick(inter):
print("test")
try:
try:
await user.send(f"You've been kicked from {ctx.guild.name} for reason **{reason}**.")
except:
await ctx.send("Couldn't send a DM to the user.")
await user.kick()
await ctx.send(f"{user} was kicked for reason **{reason}**")
except Exception as e:
await ctx.send(e) ```
idk y aint workin
i did wrong ig as i copy normal kick code and put it under slash command
how can you call the send method with Context when your only parameter is inter?
Where is ctx
oof
and why is there a nested try and except
so wut i do?
Yeah these are not defined in this code block
i recommend you learn python before jumping into this library.
just simply, learn python.
you are far ahead of yourself.
ok
Oh your trying to error handle you can make a handler for that you don't need to wrap each command in a try catch
Try except*
async def remove_deafen():
marcus = 121466391231463###
user = await client.fetch_user(marcus)
await user.edit(deafen=True)
(# for redacted numbers)
in remove_deafen await user.edit(deafen=True) AttributeError: 'User' object has no attribute 'edit'
How come I can't edit this value?
use the member object
why is there a command decorator if its a slash command?
how exactly can i run psql for my discord.py bot?
anywhere I can look in discord py doc for that?
none of that code is correct
ikr lol
!d discord.MemberConverter
!d discord.Member
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.
ive wanted to make a postgresql database for it but i have no fucking clue how to use psql with it since it's running on a vps.
this object
can I get a discord.Member from an id?
but there is a member converter you can use to convert User to Member
if someone can help or point me in a direction of docs for it, it'd be helpful
but i forgot the exact tag
yes
but your bot does not have a get_member() or fetch_member() attribute
Im a bit confused I suppose
also why are you fetching the user? it seems like you're making an API call thats not needed.
Well, long story short. We have one person who constantly is getting deafened as a joke
and to help him I want to undefean him every 15 seconds
you are currently using ``fetch_user()` which returns a User object, im saying there is no fetch_member() attribute for the member object so you should probably use a member converter
right but using fetch_user() calls the API. which can get you ratelimited if its over used, this is not needed as you can use get_user(). the bot will grab the User from its cache if you use get_user() rather than calling the API to grab a member
doesn't guild require context though?
not if you use get_guild()
Only places I am using guild I have context
Well can't you find guild from bot idk
Do I need to import it from anywhere?
yes, bot.get_guild
client.get_guild?
Mhm
yes
Yes
Np my g anytime
get_guild() -> Returns a guild with the given ID.
Probably
!d discord.Guild.get_member
get_member(user_id, /)```
Returns a member with the given ID.
it does
what id do I pass to get_guild?
your guild id
The guild Id
the server you're using this bot on
Yeah
@fickle bloom now.
bot.get_guild(id)
guild.get_member(id)``` simple
you will then have accessed the Member object
wait, where can I find my guild id lol
right click on the guild name and copy the id
Right click the name of the guild and copy Id
you guys are awesome
no problem
This is what we do yes
If you ever need help I do the same thing you do here, but for React Native in reactiflux ๐
im actually in a call with a friend who needs help regarding react
React Native is Kotlin/Java, Swift/Obj-c and JSX
Objective c ๐
But, I mainly try to avoid anything on the native side as much as possible.
๐ฉ not today apple
React Native is heavily switching to C++ in it's core
Apple uses swift now
Good
Mmm c++ is great
I guess you like hurting yourself mentally
C++ with JSI (Javascript + C++ basically)
It's super cool, if you want to nerd out look at React Native Fiber and how they're using C++ and JSI to make mobile applications blazing fast
The beauty of RN is you can write C if you wanted to for your mobile apps. It's awesome
I love torturing myself and that is called bdsm or just b with extra steps in this case
That's wonderful
๐
Do I have to await these?
guild = await client.get_guild(guild_id)
user = await guild.get_member(marcus)
await user.edit(deafen=True)
Have this right now
Ok, it didn't like those awaits so I removed them.
But now I get this
await user.edit(deafen=True)
AttributeError: 'NoneType' object has no attribute 'edit'
make sure that the guild_id is an int
and marcus too
marcus = 121466391231463###
guild_id = 169220321365327###
guild = client.get_guild(guild_id)
user = guild.get_member(marcus)
await user.edit(deafen=True)
yea, what's the marcus variable?
Is the guild in the bots cache?
no
the guild is found, member is not
member in cache?
How can I check?
what are you trying to deafen your own bot in the server?
Nope, I want to ultimately undefean another user who is being constantly defeaned
weird reasons I know
ohok, seems like the member is not in the cache, do you have member intents?
if you want to undeafen, why are you setting deafen to True
import discord
import requests
import time
import asyncio
from discord import message
from discord.ext import commands, tasks
from discord.utils import get
from discord.ext.commands import has_permissions, CheckFailure
import random
import sqlite3
import json
import time
These are all my imports
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.
@fickle bloom
you imported time two times and sqlite3 will block your code like time and requests
need to test on myself first
sqlite is used for a game, it only fetches one time on start right now
use aiosqlite
Thank you :)!
!pypi aiosqlite
It's sqllite 3 but async await
reviewing this now
this was disabled, adding it now.
do I need to revalidate anything for the bot in the server?
Okay, it worked! I got it
Great!
Np np
Can we change the duration of a users timeout?
await timeout(*, duration=..., until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Times out the member from the guild; until then, the member will not be able to interact with the guild.
Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.
You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.
New in version 2.3.
or you can use Member.edit if you want to edit the user at the same time
is this a library I have to install?
Or just an import?
If you're using disnake, no
Never heard of disnake
ah
I'm using the discord py library
Oh
incorrect.
Discord
again, discord.Member.timeout isnt a thing, and never will be
any difference in using disnake over discord py?
yes
disnake has the new features discord is coming out with, such as timeout
they function the same
Its maintained with inbuilt slash commands
as they copied the internals and added onto them
And fixed those internals too
disnake is currently still maintained, so its updating accordingly to discords new features, as discord.py has been left unfinished, no longer being worked on.
yep
ok, installed and changed evertything to disnake and its working
id recommend disnake
going to try and implement this timeout
(pst.... if you are trying to make a music cog at somepoint ||stealthy wavelink ๐ ||)
Exactly one of duration or until must be provided. To remove a timeout, set one of the parameters to None.
Like this?
await user.timeout(duration=None)
Or like this?
await user.timeout(duration="None")
None
Missing Permissions
Seems I am missing permissions to timeout
!e
var = None
var_ = "None"
if var is None:
print("A")
if var_ is None:
print("B")
@final iron :white_check_mark: Your eval job has completed with return code 0.
A
"None" is not None
Got it working, thanks
user member how can I see if a user is in voice? I see voiceState but its a bit confusing
Check if member.voice is not none
if(user.voice != None):
print('user is dc')
user.voice output was large though
user.VoiceState.channel?
I mean just checking member.voice is enough
๐ค Alright give it a try
If they're not in VC then they wonโt have a VoiceState established
Yea, member*.voice failed to return anything if the user DC's actually
you're a helper now!
he do be helpin
anyone know if would be possible to import google translate into my bot, and have a built in translator? like you would input the text language, then the language you want to translate to, and finally the text and it would translate the text into the set language? I know google translate isn't very accurate but it might be some help
!pypi googletrans
Your js tendencies are really apparent here
:D yeah!
๐
You may need to install beta btw
what's that?
https://github.com/ssut/py-googletrans/issues/234#issuecomment-737229318
As of 03/12/2020 you can install googletrans==3.1.0a0 as an Alpha fix to the error.
You can just do
if not user.voice:
print("nop")
No parenthesis, I'm not going to lie. I kind of hate that ๐
AirBnB has a similar rule in JS where single line returns should never be multi-lines in paranthesis.
Then be lucky python supports both
Same here, but sort of biased since I mostly work with JS/TS these days :p
you've already become 10x better than most of the people here including myself for following pep8
May not be python
But it's a horror show for pep8 if it were


Pep8 I hear

await guild.unban(user=nicholas, reason=None)
user=nicholas here has an example of abc.SnowFlake Do I need to provide the users discord name? Or do I need to provide a member object? Very confusing
Wait what It's a single js file 
unban takes a snowflake
???
Discord.on("message", function (message) {
var boolean = true;
if (!!!!Boolean(boolean) !== false && Boolean(boolean) === true) {
{
{
{
{
{
{
{
{
{
{
if (!!!!Boolean(message.content.includes("discord.gg")) === true && Boolean(message.content.includes("discord.gg")) !== false) {
message.delete();
message.reply("No Invites!!1! You will get baned soon.")
}
}
}
}
}
}
}
}
}
}
}
}
});
Jesus.
what's wrong with the code lol
this shouldn't be allowed to exist
I'll have to look into the api, no idea what a snowflake is
I'm never seen !!!!Boolean and I've worked in JS for 7 years now
!d discord.abc.Snowflake
class discord.abc.Snowflake```
An ABC that details the common operations on a Discord model.
Almost all [Discord models](https://discordpy.readthedocs.io/en/master/api.html#discord-api-models) meet this abstract base class.
If you want to create a snowflake on your own, consider using [`Object`](https://discordpy.readthedocs.io/en/master/api.html#discord.Object "discord.Object").
almost all models in discord.py abstract it since almost everything in discord is a snowflake (an id)
you can make your own using: discord.Object(id)
On PC you'll see Luca in ascii art
Ohhh
Ah, is my member object a snowflake then?
user = guild.get_member(nicholas)
would this work?
await guild.unban(user=user, reason=None)
Or, instead do I have to pull it from a banned list, instead of guild?
https://github.com/top-gg/Luca/blob/dd4f4f0075906106dd50369cdebd61a40204eac5/bot.js#L318-L322 isnt it the bot token? altho expired mb
bot.js lines 318 to 322
if (process) {
process.token = 'MjY0ODExNjEzNzA4NzQ2NzUy.C0grJQ.dGhpc2lzYWZha2VfdDBrM251bnViLi4u';
} else {
window.token = 'MjY0ODExNjEzNzA4NzQ2NzUy.C0grJQ.dGhpc2lzYWZha2VfdDBrM251bnViLi4u';
}```
๐ why they do this
Stackoverflow type shit right here
Yes it will
How
guild.get_member would return None if they banned
Guild.unban(discord.Object(id=id))```
is the best way imo
^ it is the best way
Do I have to check if they're banned first to do this?
Also, does python have a map function like js?
Array.map((value) => {})
I'm assuming, for each or similar
Ah it does, sweet
no you dont need to check that, if the member is not banned, nothing happens
correction : it raises 404
Yea so I need to check
Of you could just try/catch
even easier
in py try/except
*except
Listen Iโm just talking in his native tongue of js
understandable :3
discord.HTTPException
Never leave blank unless your certain you have to
Bare exception clause
try:
await guild.unban(disnake.Object(id=nicholas))
except:
print('user not banned*')
**
PEP8 song ~ be specific
If you know what error your code is gonna throw than catch that specific error.
@discord.command()
def printer(ctx, user: User=None, link: str=None):
"Print. That's all."
params = {}
pattern = 'https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)'
if user is None and link is None:
params['image_url'] = ctx.author.avatar_url
elif user is None and link is not None and re.fullmatch(pattern, link):
params['image_url'] = link
elif user is not None and link is None:
params['image_url'] = user.avatar_url
elif user is not None and link is not None:
return "Sorry, but it looks like you can't fill all of the two arguments!"
answer = proc.request('print', params)
with open(f"{ctx.id}.png", "wb") as f:
f.write(answer)
ctx.send(Message(file=(f'{ctx.id}.png', open(f'{ctx.id}.png'), 'image/png')))
os.remove(f'{ctx.id}.png')
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/flask/app.py", line 2073, in wsgi_app
response = self.full_dispatch_request()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/flask/app.py", line 1518, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/flask/app.py", line 1516, in full_dispatch_request
rv = self.dispatch_request()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/flask/app.py", line 1502, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/flask_discord_interactions/discord.py", line 523, in interactions
return jsonify(self.run_command(request.json).dump())
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/flask_discord_interactions/discord.py", line 440, in run_command
return command.make_context_and_run(self, current_app, data)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/flask_discord_interactions/command.py", line 177, in make_context_and_run
result = self.run(context, *args, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/flask_discord_interactions/command.py", line 195, in run
return self.command(context, *args, **kwargs)
File "app.py", line 47, in printer
ctx.send(Message(file=(f'{ctx.id}.png', open(f'{ctx.id}.png'), 'image/png')))
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/flask_discord_interactions/context.py", line 399, in send
message = requests.post(
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/requests/api.py", line 117, in post
return request('post', url, data=data, json=json, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/requests/sessions.py", line 515, in request
prep = self.prepare_request(req)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/requests/sessions.py", line 443, in prepare_request
p.prepare(
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/requests/models.py", line 321, in prepare
self.prepare_body(data, files, json)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/requests/models.py", line 514, in prepare_body
(body, content_type) = self._encode_files(files, data)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/requests/models.py", line 161, in _encode_files
fdata = fp.read()
File "/usr/lib/python3.8/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x87 in position 10: invalid start byte
i am using flask-discord-interaction
Advent of code completionist using is None instead of just if not smh
Just kidding btw
discord.errors.NotFound: 404 Not Found (error code: 10026): Unknown Ban``` would be the error so you might be using `discord.NotFound`
well i usually use is None since it is a part of my dumb habit
i am new to this library so...
What's wrong with is None
I thought it throws HTTPExeption tho 
yeah i agree too
NotFound is a child class of HTTPException
.
not discord.py
!pip Flask-Discord-Interactions
could you link the library?
thnks
why not just use some discord.py fork? this library seems a bit confusing and not too well documented
it doesnt costs too much to host them
since replit sucks with hosting discord bot with gateway
do you mean "too much" in terms of resources?
Personally I believe it makes your code look cleaner and have less redundancy.
too much
Same reason why people use
if not something instead of using if something == False or some shit.
how to import intents
!d discord.Intents
class discord.Intents(**kwargs)```
Wraps up a Discord gateway intent flag.
Similar to [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.
To construct an object you can pass keyword arguments denoting the flags to enable or disable.
This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
New in version 1.5...
if you want to use presence and member intent you must beg discord for them
I mean. Only if your bot is verified ofc
status = disnake.Status.idle, intents = disnake.Intents.all(),
activity=disnake.Game(name="Watching people play minecraft")
client.central = client.get_user(933326881237905468)```
Any solution for it?
client.central? what is it
how to add embed to my bot?
!d discord.Embed
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if itโs within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
yw
!d client
!d discord.Client ?
class discord.Client(*, loop=None, **options)```
Represents a client connection that connects to Discord. This class is used to interact with the Discord WebSocket and API.
A number of options can be passed to the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
the docs command has 41 packages so youll have to be specific
discord.py stopped being maintained so no updates disnake is a fork and hikari is another wrapper
Dpy is still a valid option afaik. Aside from that any of the branches will work just as well from what ive heard and seen
dpy is still valid until breaking changes to the api
when will there be breaking changes to the api?
who knows
ok
i dont work in discord
Hopefully never unless they add new things the api can affect
message intents is big for verified bots ig
pycord
Disnake i think is the big one rn
like hard
disnake is gr8
i do not understand?
the help channels are dead
so?
oh i get it nvm
Honestly all the forks are overrated since they all suck balls

im to lazy to learn hikari tbh
Ive been using and plan on sticking with dpy for the time being
no timeout feature for you
you don't learn a library though
theres a way, edit internals or use d.py's http client
wut
i mean you can ig but who would?
d.py users
isn't that the point of the forks though
if someone is so smart to make a request how did he or she not consider to migrate?
idk i'm not that smart
be smarter
they simp for the wrapper to much
easy
Then keep up with them. If one person can then you probably can. Ez
i had a stroke reading that
Cant wait for all the crypto scams to come
ยฏ_(ใ)_/ยฏ
everybody cant
isnt a wrapper supposed to be user friendly?
i'm sure they're just trolling
Yeah, because I am.
tyler you cant troll bro
tyler are you trolling or you got confused and said you were trolling
I was trolling okimii
Anytime I add Ez to anything it often means Iโm joking.
im trolling
is it bad that i'm enjoying this
ik ik chilll
yes
Its anime pfp arguments
can you give code of kick command but in slash format?
yeah my pfp has anime in it๐
examples
I don't understand how to convert it into slash
you don't learn a library..
It used to, and i know you would
I'm not askin for spoonfeedin dude
๐
I want a rough example of how to convert normal command into slash
i hate how my keyboard doesnt copy paste
what library are you using
disnake
https://github.com/DisnakeDev/disnake/tree/master/examples/slash_commands if youre using disnake
Tysm
what is best discord library... i had to ask
any fork is good(for migration)
Its all preferance
They essentially all do the same thing just in slightly different ways
yeah but some are better than the others in src code
i prefer disnake
in python
in c# i use discordsharp+
djs
no?
djs is objectively trash due to the fact itโs built for a language that is trash.
CDISCORD!
discordrb
djs is one of the best discord libraries out there
wonder if some mad lad made a discord bot with assembly
dpy is dead in the water wdym
discordrb cuz its so raw you have to make request to the endpoint to make reactions
kayle you're actually trolling.
before it got archived
ah
no?
If you're trying to imply that d.js was better than d.py when it was still maintained istg.
i cant tell if this channel is trolling or not
yes
it was
I haven't even said anything bro
following ๐
because you take 5 years
to send a whole wikipedia page
of info
๐คธ
Well, all I'm gonna say is djs is a powerhouse, imo discord.py is after it
imo
djs literally has, a cluster manager, so many more features, voice receive etc
youre mad discordrb is the best
Also there events are more conventional than discord.py's
Emitters, subscribers, etc
if a discord bot hits 75 servers on April 2022 onwards, will it immediately become broken by discord?
nvm
Why?
yeah
technically its implied
youll need to ask for intents
i mean of course i assume its a mistaken implication that they accidentally missed out on
Must be the work of all of those maintainers that kayle speaks of.
When the trash lang runs 97% of the internet
That doesnโt mean anything 
If it was objectively trash, I'm sure the community would've switched to something better no?
PHP is used a lot in the internet but itโs still objectively trash.
Yes, and people upgraded from php to javascript

google has python in it
I mean thatโs whatever ig. I got nothing more to say. 
i'm just lazy to learn the intricacies of multiple languages
like i find it tiring to keep up
lans are easy after you know python all you need to learn is syntax
Learning different coding languages is just like learning a new library
Continuing on top of this. One of the key differences is that discord.py has a single maintainer plus the addition of pull requests. So you know it kinda makes sense that it has less features than something that has a surplus of maintainers 
nvm i have to learn js anyway
yeah
i might use discord js if it's that much better
gl with that ig
i mean yeah ofc python is simple compared to other lans
Youll probably do better just sticking with the language you know and using a different lib within it than learning a new langauge and library
ruby is like python but less powerful and easier compared to python which is for complicated stuff
it looks like the message intent update will not break the api, since it is just an approval process
it wont break the api ofc but it will break verified bots
that dont have slash commands
this update is really annoying
ยฏ_(ใ)_/ยฏ
oh i get it
it has workarounds built into it so actually its not as bad as i thought
its just a change to the api
it's annoying though it means having to refactor the bot
just apply for it
ok sure i'll try be positive about it
youll need to read what makes your bot acceptable to the intent
i mean, basically it means i should never use prefix, and only use mentions in all bots..
it looks like that is what the giant article sums up to
mentions or slash commands
Good thing i was planning on swapping to mentions
i prefer slash commands
I might do them at some point instead but im tired of prefixes overlapping other bots
slash commands dont overwrite or mentions since it contains a snowflake
Litterally changing the prefixes section to "@<bot>" should get around that right?
yeah but i have to learn how to do that
around what
Prefixes
and no thats not the write formatting
idk how it works, i do not think it is simple though
nope each user has a snowflake
I didnt think it would be that easy unfortunately
Fuuu
Ok
its not super hard but... like its important to start early instead of getting all the users used to prefixes and then changing to mentions
btw i ment no it doesnt overwrite*
dang i really have to put effort into refactoring the bot and learning how to make it adapt to these new rules though
What i meant was i cant just swap the ! On line 10 to a bot mention
actually the more i read it, discord really wants us to refactor our bots
We expect most bots and apps to migrate to new ways of engaging with users, like slash commands and other interactions. Please bear in mind that only bots that perform unique behaviors (that cannot be performed by Interactions) will be eligible for this intent.
it means that you could not fulfill your bots behavior without mentioning the user or using DM
in other words... they are banning prefixes
things which require message content intent, mostly moderation stuff
Ooo ok
i wish they were more straightforward about it 'we are banning prefixes', it took me so much analysis to figure that out
It still won't affect bots in less than 100 servers and unverified bots
They didn't frame it that way because it's more than just "banning prefixes"
Aight so im still good for quite a bit with my test bot
75 servers
This change affects only verified bots, bots that are in 75 or more servers. Unverified bots in fewer than 75 servers are not affected at all.
!d disnake.ext.commands.when_mentioned is a thing
not sure, it's probably 75 i guess then
disnake.ext.commands.when_mentioned(bot, msg)```
A callable that implements a command prefix equivalent to being mentioned.
These are meant to be passed into the [`Bot.command_prefix`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Bot.command_prefix "disnake.ext.commands.Bot.command_prefix") attribute.
its 75
Im using dpy
yeah ok
!d discord.ext.commands.when_mentioned
discord.ext.commands.when_mentioned(bot, msg)```
A callable that implements a command prefix equivalent to being mentioned.
These are meant to be passed into the [`Bot.command_prefix`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.command_prefix "discord.ext.commands.Bot.command_prefix") attribute.
!d discord.ext.commands.when_mentioned_or
discord.ext.commands.when_mentioned_or(*prefixes)```
A callable that implements when mentioned or other prefixes provided.
These are meant to be passed into the [`Bot.command_prefix`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.command_prefix "discord.ext.commands.Bot.command_prefix") attribute.
Example
```py
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'))
```...
if you want a prefix as well
i guess this means using discord py becomes a worse idea now
you think this will work with the new discord april 2022 thing?
what does "*" do
so i can use prefixes in april 2022 discord without mentioning the bot?
message content if it's pinged in it*
no
no... Only the mentioning part
wrong reply?
i mean.. i'm trying to design my bots so they can be used beyond 75 servers
help
use slash commands
@client.command(brief="DMs a user")
async def dm(ctx, user:disnake.Member, *, msg):
try:
try:
await user.send(f"You've recieved a message from {ctx.guild.name} saying '{msg}' .")
except:
await ctx.send("Couldn't send a DM to the user.")
await user.kick()
await ctx.send(f"{user} has recieved the message")
except Exception as e:
await ctx.send(e)```
Ain't workin
i do not want anything that would break
if it doesnt have message intents it cant access the message content dpy checks message mentions if it got mention
apply for message content if you really need it
in imports? or params?
what does "*" do
Pretty sure they specified it can see slash commands and pings in their thread where they announced message content intent
i don't need it in the sense that i could refactor my code... just that i have to now put in time learing how to refactor the code
makes everything after a kwarg
hi
yes but the bot doesnt check the message content that just defeats the purpose of the intent?
can you help me out?
@client.command(brief="DMs a user")
async def dm(ctx, user:disnake.Member, *, msg):
try:
try:
await user.send(f"You've recieved a message from {ctx.guild.name} saying '{msg}' .")
except:
await ctx.send("Couldn't send a DM to the user.")
await user.kick()
await ctx.send(f"{user} has recieved the message")
except Exception as e:
await ctx.send(e)```
alr
why nested
...
Its not indented correctly
only if it's pinged in the said message, will it check the message content
no it wont
bruh
it checks the message mentions not its content?
ok i might be wrong let me re check
Could you fix the code and send?
ok let's say it checked the mention, and? what will it do? what's the point of checking the mention then?
Im on mobile so the formating is litterally unreadable even if it was correct so sadly i cant
it checks if it was mention?



