How do I enable slowmode via a command? - discord

I want to enable slowmode via a command, in the form as >slowmode <seconds>, like >slowmode 10. My current code:
#has_permissions(manage_channels=True)
async def slowmode(ctx, amount):
await ctx.channel.edit.slowmode.delay(int(amount))
and I get this error:
Ignoring exception in command slowmode:
Traceback (most recent call last):
File "C:\Users\dante\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\core.py", line 83, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\dante\Desktop\Utilly\Utilly.py", line 116, in slowmode
await ctx.channel.edit.slowmode.delay(int(amount))
AttributeError: 'function' object has no attribute 'slowmode'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\dante\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\bot.py", line 892, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\dante\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\core.py", line 797, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\dante\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\core.py", line 92, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'function' object has no attribute 'slowmode'

Use discord.TextChannel.edit(slowmode_delay=amount)
#has_permissions(manage_channels=True)
async def slowmode(ctx, amount):
try:
await ctx.channel.edit(reason='Bot Slowmode Command', slowmode_delay=int(amount))
except discord.Errors.Forbidden:
await ctx.send('I do not have the permission to do this, please try again')

Related

pycord send discord.ui.View object to specific channel

I'm trying to send View object to specific channel.
I've tried this :
#bot.event
async def on_ready():
ch = _bot.get_channel(927913185766436885)
await ch.purge(limit = 100)
v = discord.ui.View()
v.add_item(Vrb())
await ch.send(view=v)
There is view in ch.send's hint, But when i put view=v to ch.send, It raises:
Traceback (most recent call last):
File "C:\Users\CENSORED\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 352, in _run_event
await coro(*args, **kwargs)
File "CENSORED", line 2344, in on_ready
await ch.send(view=v)
File "C:\Users\CENSORED\AppData\Local\Programs\Python\Python39\lib\site-packages\discord_components\dpy_overrides.py", line 350, in send_override
return await send(channel, *args, **kwargs)
TypeError: send() got an unexpected keyword argument 'view'
how can i fix this?
i don't want to use slash commands or things.
Edit : I'm using version py-cord-2.0.0a4739+g128a9e97.
Uninstall discord.py or any other discord.py fork if you have any, then install the Development version of Pycord.
pip install -U git+https://github.com/Pycord-Development/pycord

Im Trying to create a custom bot status but im getting this error again and again

This is my code:
#client.event
async def on_ready():
await client.change_presence(status=discord.Status.idle, activity=discord.Game('test" '))
But I'm getting this error:
Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\XaiZaiRo\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "e:\coding\Discord Bots\Undercons\bot\main.py", line 30, in on_ready
await client.change_presence(status=discord.Status.idle , activity=discord.Game('Managing "discord.gg/crepling" '))
AttributeError: 'Command' object has no attribute 'Status'
I'm pretty sure this is what you are looking for.
client = Bot(command_prefix=">",
help_command=None,
case_insensitive=True,
max_messages=100,
activity=Activity(type=ActivityType.watching,
name=f"over your server."),
intents=discord.Intents.all())
It will basically say "Watching over your server." as an activity.

'Subsystems' object has no attribute 'rcp'

Any chance I could get a tip on how to debug this error in the volttron.log file? 'Subsystems' object has no attribute 'rcp' what does this mean?
Traceback:
Traceback (most recent call last):
File "/var/lib/volttron/volttron/platform/vip/agent/core.py", line 117, in _loop
method(*self.args, **self.kwargs)
File "/home/volttron/.volttron/agents/4f27247d-e6bf-4e30-8ffe-6d895ac52047/setteroccvavagent-0.1/setteroccvav/agent.py", line 222, in raise_setpoints_up
result = self.vip.rcp.call('platform.actuator', 'set_multiple_points', self.core.identity, topic_values).get(timeout=30)
AttributeError: 'Subsystems' object has no attribute 'rcp'
My agent code with the function running:
# now we can send our set_multiple_points request, use the basic form with our additional params
result = self.vip.rcp.call('platform.actuator', 'set_multiple_points', self.core.identity, topic_values).get(timeout=3)
This is a gist of my agent code.
This is a typo, now fixed in the original post.
result = self.vip.rpc.call('platform.actuator', 'set_multiple_points', self.core.identity, topic_values).get(timeout=3)

prawcore.exceptions.NotFound: received 404 HTTP response

Hey guys I'm having trouble figuring this out:
Traceback (most recent call last):
File "SOLIS.py", line 62, in <module>
com_df1 = scraper.comments(sub_id_list,keywords1,keywords2)
File "/Users/CarranzaEE/Desktop/CDS 491:DEXIS/Reddit_SOLIS/Reddit_SOLIS.py", line 252, in comments
if((comment.author is None) or (hasattr(comment.author, 'id') != True)):
File "/Users/CarranzaEE/anaconda3/lib/python3.7/site-packages/praw/models/reddit/base.py", line 34, in __getattr__
self._fetch()
File "/Users/CarranzaEE/anaconda3/lib/python3.7/site-packages/praw/models/reddit/redditor.py", line 171, in _fetch
data = self._fetch_data()
File "/Users/CarranzaEE/anaconda3/lib/python3.7/site-packages/praw/models/reddit/redditor.py", line 168, in _fetch_data
return self._reddit.request("GET", path, params)
File "/Users/CarranzaEE/anaconda3/lib/python3.7/site-packages/praw/reddit.py", line 765, in request
json=json,
File "/Users/CarranzaEE/anaconda3/lib/python3.7/site-packages/prawcore/sessions.py", line 339, in request
url=url,
File "/Users/CarranzaEE/anaconda3/lib/python3.7/site-packages/prawcore/sessions.py", line 265, in _request_with_retries
raise self.STATUS_EXCEPTIONS[response.status_code](response)
prawcore.exceptions.NotFound: received 404 HTTP response
This error happens when I try to use author (an instance of Redditor) to try and call author.id. PRAW documents also say that Shadowbanned accounts are treated the same as non-existent accounts, meaning that they will not have any attributes, and that will only return name and is_suspended.
But is_suspended is no longer an attribute provided by reddit api. So I'm having trouble trying to handle cases where the account is a shawdowbanned account. Any tips or ideas?

TemplateDoesNotExist error for a simple ModelAdmin example

I've used Wagtail's ModelAdmin on a few other projects with great success, but this is the first time I'm attempting to use it with a model inheriting from Page.
I copied the simple example template and removed the parts that didn't relate to my BlogPageModel.
The link to the ModelAdmin appears as expected, but when I click it, I get TemplateDoesNotExist at /admin/blog/blogpage/.
I don't remember having to set up a template before. Is there a setting I'm missing?
Wagtail: 1.9 /
Django: 1.10.5 /
Python: 3.5.2
Update: I tried it with a model that inherits from models.Model as well with the same result.
Traceback follows:
Internal Server Error: /admin/blog/blogpage/
Traceback (most recent call last):
File "/Users/username/.virtualenv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 39, in inner
response = get_response(request)
File "/Users/username/.virtualenv/lib/python3.5/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
response = self._get_response(request)
File "/Users/username/.virtualenv/lib/python3.5/site-packages/django/core/handlers/base.py", line 217, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/Users/username/.virtualenv/lib/python3.5/site-packages/django/core/handlers/base.py", line 215, in _get_response
response = response.render()
File "/Users/username/.virtualenv/lib/python3.5/site-packages/django/template/response.py", line 109, in render
self.content = self.rendered_content
File "/Users/username/.virtualenv/lib/python3.5/site-packages/django/template/response.py", line 84, in rendered_content
template = self.resolve_template(self.template_name)
File "/Users/username/.virtualenv/lib/python3.5/site-packages/django/template/response.py", line 66, in resolve_template
return select_template(template, using=self.using)
File "/Users/username/.virtualenv/lib/python3.5/site-packages/django/template/loader.py", line 53, in select_template
raise TemplateDoesNotExist(', '.join(template_name_list), chain=chain)
django.template.exceptions.TemplateDoesNotExist: modeladmin/blog/blogpage/index.html, modeladmin/blog/index.html, modeladmin/index.html
[21/Feb/2017 07:56:38] "GET /admin/blog/blogpage/ HTTP/1.1" 500 110901
I suspect you've missed out adding 'wagtail.contrib.modeladmin' to INSTALLED_APPS.

Resources