rapptz / discord-ext-menus Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
My Python Version:
3.9.0
My Discord.py version:
1.5.1
Error message: No name 'menus' in module 'discord.ext'
Installed: Yes
I use python -m pip install -U git+https://github.com/Rapptz/discord-ext-menus
and pip install -U git+https://github.com/Rapptz/discord-ext-menus
but neither work...
/menus/init.py", line 700, in start
permissions = channel.permissions_for(me)
AttributeError: 'PartialMessageable' object has no attribute 'permissions_for'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 960, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 825, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 134, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'PartialMessageable' object has no attribute 'permissions_for'
Exception has occurred: TypeError
'<' not supported between instances of 'dict' and 'dict'
File "C:\Projects\Anastasia-bot-master\cogs\embeded_menus.py", line 34, in deals
pages = menus.MenuPages(source=Source(DATA, key=lambda t: t.key, per_page=12), clear_reactions_after=True)
File "C:\Projects\Anastasia-bot-master\app.py", line 62, in on_message
await bot.process_commands(message)
File "C:\Projects\Anastasia-bot-master\app.py", line 72, in
bot.run(TOKEN)
Running newest version of discord.py
python 3.7.3
It was just working a couple days ago, and then I redid a bunch of unrelated paths.
Current implementation of MenuPages.show_checked_page()
is the following:
async def show_checked_page(self, page_number):
max_pages = self._source.get_max_pages()
try:
if max_pages is None:
# If it doesn't give maximum pages, it cannot be checked
await self.show_page(page_number)
elif max_pages > page_number >= 0:
await self.show_page(page_number)
except IndexError:
# An error happened that can be handled, so ignore it.
pass
Before making a PR I wanted to check if the following implementation is something you would like to see implemented Danny.
async def show_checked_page(self, page_number: int) -> None:
max_pages = self._source.get_max_pages()
try:
if max_pages is None:
# If it doesn't give maximum pages, it cannot be checked
await self.show_page(page_number)
elif page_number >= max_pages:
await self.show_page(0)
elif page_number < 0:
await self.show_page(max_pages - 1)
elif max_pages > page_number >= 0:
await self.show_page(page_number)
except IndexError:
# An error happened that can be handled, so ignore it.
pass
This implementation would allow the menu to go to the last page when pressing back on Page 0, and go to first page when pressing Next on Page -1
Menu.start()
accepts a channel
argument of type discord.abc.Messageable
, which should mean menus can be sent to DMs. However, it looks like it calls permissions_for
here, which doesn't exist on the discord.Member
class, even though that class implements the Messageable
ABC.
For example, this returns an error AttributeError: 'Member' object has no attribute 'permissions_for'
:
@bot.command()
async def menu_example(ctx):
m = MyMenu()
await m.start(ctx, channel=ctx.author)
Let me know if I'm misunderstanding how this should work.
Maybe there can be a boolean argument provided to init of menu, telling the menu to whether accept reaction_remove or not. This can solve the issue of removal of the reaction of the user by the bot, since the bot isnt listening to the reaction_remove event. By default, the boolean can be True, meaning that the menu will observe reaction_remove event. I can open a PR if needed too
On using menus.AsyncIteratorPageSource
there are inbuild reaction emojis
How do I make it such that when a user adds a reaction it clears it
Hello,
I've been playing with this library for a while now.
From what it seems, the current buttons ecosystem does not take in count the possibility of the Menu class being subclassed and the button methods overridden (with it's own button decorator), right?
EDIT: I mean, subclassing for example MenuPages
, basically if I override stop_button
with it's own button decorator (because I want to change the emoji for it) but even after that I can still see the original MenuPages.stop_button
in self.buttons
. Like this I guess the only way would be to manually delete_button of meths that I've overridden (for example in init)
Hello, i created a bot and now want to completly switch from textcommands to slashcommands. everything working now exopect the menus. the bot is adding the reactions but if they become pressed nothing is happening. i not checked anything there and before at the point where i used textcommands it worked. i alredy asked in the slashcommand supportserver but the owner told me that he cant help cause its out of his knowlage. it would be nice if anyone could help me with that....
This is my code:
embeds = LeaderboardPages(leaderboard, per_page=10, base=emb, emoji=self.emoji, stat=stat)
menu = menus.MenuPages(
source=embeds, timeout=300.0, message=message, clear_reactions_after=True,
)
await menu.show_page(0)
await menu.start(ctx)
I followed the code example in README.md for AsyncIteratorPageSource
and it says to simply call the Menu Pages object and the await menu.start(ctx)
but any time I did that I had an empty response. Seems I needed to call await menu.show_page(0)
first
So I have a custom emojis from my bot's home server. However, I cannot add it as menu buttons like
@menus.button("<:GREEN_TICK_ALFRED:765020197765382174>")
async def do_confirm(self, payload):
self.result = True
self.stop()
@menus.button("<:RED_TICK_ALFRED:765020214001139743>")
async def do_deny(self, payload):
self.result = False
self.stop()
The syntax for displaying the custom emoji is correct [I tried sending it as a message and it worked] But the reaction cannot be added for custom emoji.
The bot has permission to use extenral emojis as well as add reactions, I checked.
Is this a bug or am I doing anything wrong?
Originally, I had all 5 of the default buttons working. Now, only 3 of the work. The buttons that show the first and last page of the menu have started showing up. They aren't being added as a reaction. I haven't changed anything.
When using remove button to remove a reaction (Assuming react=True), there is an issue if said "button" has already been reacted to once. Because self.message.remove_reaction
will only lower the count, instead of removing it entirely. Would changing this to self.message.clear_reaction
be an option?
Traceback (most recent call last):
File "main.py", line 37, in
from discord.ext import commands, menus
ImportError: cannot import name 'menus' from 'discord.ext' (unknown location)
I'm getting this error when I put the code on Repl.it, and in my home's computer I get this error too. But in my work's computer, wich is the one that I was making the bot, the code runs without any error.
how do i fix this?
Unresolved attribute reference 'current_page' for class 'Menu'
async def format_page(self, menu, entries):
offset = (menu.current_page * self.per_page) + 1
My bots worked perfectly fine before i installed menus on discord.py but after i tried to run it after installing it it give me this error
Ignoring exception in command Search:
Traceback (most recent call last):
File "C:\Users\NABEL\PycharmProjects\pythonProject\venv\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:/Users/NABEL/PycharmProjects/pythonProject/Bot.py", line 17, in Search
embed.add_field(name=GenshinWikiWebscrapper.var1[1], value=GenshinWikiWebscrapper.var1[2], inline=False)
IndexError: list index out of range
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\NABEL\PycharmProjects\pythonProject\venv\lib\site-packages\discord\ext\commands\bot.py", line 903, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\NABEL\PycharmProjects\pythonProject\venv\lib\site-packages\discord\ext\commands\core.py", line 859, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\NABEL\PycharmProjects\pythonProject\venv\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: IndexError: list index out of range
how do i send the oof
of async def idk(ctx, oof)
to my menu?
async def format_page(self, menu: menus.MenuPages, entries):
pages = []
for index, entry in enumerate(entries, start=menu.current_page * self.per_page):
pages.append(f"{index + 1}. {entry}")
maximum = self.get_max_pages()
if maximum > 1:
footer = f"Page {menu.current_page + 1}/{maximum} ({len(self.entries)} entries)"
menu.embed.set_footer(text=footer)
if self.initial_page and self.is_paginating():
pages.append("")
pages.append("Confused? React with \N{INFORMATION SOURCE} for more info.")
self.initial_page = False
menu.embed.description = "\n".join(pages)
return menu.embed
Hello, i just asking if buttons will be inplemented into the menus libary. so you can easy replace the reactions with buttons. it would be useful so i not need to waste my time on searching another libary that i then somehow implement into the menus i alredy have.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.