Saravanan666/pypi-org huggingface dataset:
Package: discord-interactions
discord-interactions-pythonTypes and helper functions for Discord Interactions webhooks.InstallationAvailable viapypi:pip install discord-interactionsUsageUse theInteractionTypeandInteractionResponseTypeenums to process and respond to webhooks.Useverify_keyto check a request signature:ifverify_key(request.data,signature,timestamp,'my_client_public_key'):print('Signature is valid')else:print('Signature is invalid')Useverify_key_decoratorto protect routes in a Flask app:importosfromflaskimportFlask,request,jsonifyfromdiscord_interactionsimportverify_key_decorator,InteractionType,InteractionResponseTypeCLIENT_PUBLIC_KEY=os.getenv('CLIENT_PUBLIC_KEY')app=Flask(__name__)@app.route('/interactions',methods=['POST'])@verify_key_decorator(CLIENT_PUBLIC_KEY)definteractions():ifrequest.json['type']==InteractionType.APPLICATION_COMMAND:returnjsonify({'type':InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE,'data':{'content':'Hello world'}})ExportsThis module exports the following:InteractionTypeAn enum of interaction types that can be POSTed to your webhook endpoint.InteractionResponseTypeAn enum of response types you may provide in reply to Discord's webhook.InteractionResponseFlagsAn enum of flags you can set on your response data.verify_key(raw_body: str, signature: str, timestamp: str, client_public_key: str) -> bool:Verify a signed payload POSTed to your webhook endpoint.verify_key_decorator(client_public_key: str)Flask decorator that will verify request signatures and handle PING/PONG requests.
Package: discord-interactions-flask
discord-interactions-flaskAFlaskextension to support interacting withDiscord Interactions.Check out thequickstartor theexamples directoryfor an idea of how to use it.importosfromflaskimportFlaskfromdiscord_interactions_flaskimportDiscordfromdiscord_interactions_flaskimporthelpersfromdiscord_interactions_flask.interactionsChatInteractionapp=Flask(__name__)app.config['DISCORD_PUBLIC_KEY']=os.environ['DISCORD_PUBLIC_KEY']app.config['DISCORD_CLIENT_ID']=os.environ['DISCORD_CLIENT_ID']app.config['DISCORD_CLIENT_SECRET']=os.environ['DISCORD_CLIENT_SECRET']discord=Discord()@discord.command("slash-example")defchat_command(interaction:ChatInteraction)->types.InteractionResponse:returnhelpers.content_response("Hello, World!")chat_command.description="Say hello via a slash command"discord.init_app(app)
Package: discord-interactions-styled
Write easier code usingdiscord-interactionswithinteractions-styled.About|Installation|Examples|Discord|PyPI|DocumentationAboutWhat?discord-interactions-styled is a set of already coded functions, decorators an more for the knowndiscord-py-interactionslibrary.Why?Well, discord-py-interactions is already pretty easy right? but, when you're working on a large-size bot it becomes repetitive to write always the same code to get results, it's redundant, that's when interactions-styled comes to the scene with a full set of functions to get results so much faster.How?Just look at this example, we're denying permissions for@everyoneand allowing them for two role ids456and789:# base library@slash.slash(...,permissions={123:[create_permission(123,SlashCommandPermissionType.ROLE,False),create_permission(456,SlashCommandPermissionType.ROLE,True)create_permission(789,SlashCommandPermissionType.ROLE,True)]})# With discord-interactions-styled@slash.slash(...)@only_allow_roles(123,[456,789])That's someclean & prettycode right there huhInstallationYou can install this lib using pip, just type the following line below:pip install -U discord-interactions-styledExamplesCreating options for a slash commandfromdiscord_slash.utils.manage_commandsimportcreate_option# discord-py-interactions@slash.slash(...,options=[create_option("option1","my description",3,True),create_option("option2","another description",4,True)create_option("option3","and another",3,False)])# discord-interactions-styledfromdiscord_styled.slashimportoption@option("option1","my description")@option("option2","another description",4)@option("option3","and another",required=False)@slash.slash(...)Denying permissions for@everyonein a slash command# discord-py-interactionsfromdiscord_slash.utils.manage_commandsimportcreate_permission@slash.slash(...,permissions={123:[create_permission(123,SlashCommandPermissionType.ROLE,False)]})# discord-interactions-styledfromdiscord_styled.permissionsimportdeny_all@slash.slash(...)@deny_all()DocumentationThese are just a few examples, we recommend you to go and visit theofficial documentationdiscord-interactions-styledis not an independant library, all the logic comes fromdiscord-py-interactions, so this isn't an alternative to that lib, we're just providing a set of tools to use discord-py-interactions more easily.
Package: discord-interactive
Discord Interactive HelpA Discord python framework to display an interactive help easily.Features•Usage•Example•AdvancedRunning in Docker•NotesDocumentationFeatures🔆Easy to naviguate: Use reactions to naviguate through the Help manual.⚙Customized reaction: Use any emoji as naviguation icon.🎮Commands support: Go even further with interactive commands.UsageInstall the package :pip install discord-interactiveImport thePageandHelpobjects into your bot's code, and create your own help manual :fromdiscord_interactiveimportPage,Help# Define each pageroot=Page('Welcome !\n')page_1=Page('This is page 1')page_2=Page('This is page 2')# Link pages togetherpage_1.link(page_2,description='Click this icon to access page 2',reaction='💩')root.link(page_1,description='Click this icon to access page 1')# Set the root page as the root of other page (so user can come back with a specific reaction)root.root_of([page_1,page_2])# Create the Help objectclient=discord.Client()h=Help(client,root)...# And display the help !@client.eventasyncdefon_message(message):ifmessage.author!=client.user:# Do not answer to myselfifmessage.content.startswith('/help'):awaith.display(message.author)ExampleYou can try the interactive help inthis Discord server!Simply join the server, and type/helpin the chat.Also, take a look at the code for this interactive help ! Check out the scriptmain.py.AdvancedIf you are interested inadvanced usagesuch asinteractive commands, take a look at thefull documentation.Example of advanced usage :If you can't find what you are looking for, or need help about this library, you can open adiscussion threador anissue, we will be glad to help !Running in DockerA Dockerfile is available to run the example easily. Just build the image :docker build -t discord_interactive_help .And then start it with your Discord bot token :DISCORD_BOT_SECRET="<your_token>" docker run -e DISCORD_BOT_SECRET discord_interactive_helpNotesThis idea was already known for some time, I didn't get the idea myself. I just wanted to share an easy framework to implement it for your own bot.This is working only with the Python Discord API.
Package: discord.io
Asynchronous Discord API Wrapper for PythonFeaturesSane Handling of 429sUser friendly interfaceInstallingTo Install discord.io Just run the following command:pipinstalldiscord.ioTo install our speed requirements just run the following command:pipinstalldiscord.io[speed]For voice support run the following command:pipinstalldiscord.io[voice]ExamplesThis is a quick usecase example for the library!importdiscordclient=discord.Client()@client.eventasyncdefon_ready():print('ready!')@client.slash_command()asyncdefping(interaction):awaitinteraction.respond('pong!')client.run('my_bot_token')This is another example but with a prefixed commandimportdiscordclient=discord.Client()@client.eventasyncdefon_ready():print('ready!')@client.eventasyncdefon_message(msg):ifmsg.author.bot:returnifmsg.content.startswith('!ping'):awaitmsg.send('Pong!')client.run('my_bot_token')Useful LinksThe discord.iodiscord server
Package: discord-ipc
discord-ext-ipcExample Clientimportdiscordfromdiscord.extimportipcsclient=discord.Client(intents=discord.Intents.all())ipc_client=ipcs.Client(client,"TopSecretKey")@client.eventasyncdefon_ready():asyncwithipc_client:awaitipc_client.connect("ws://localhost/ipc")@client.eventasyncdefon_ipc_connect():print("ipc connected")@client.eventasyncdefon_ipc_close():print("Ipc closed")@ipc_client.listen("ready")asyncdefipc_ready():print("ready")
Package: discord.js
discord.jsThis module lets you use discord.js in python by offering a similar syntax to the actual discord.js.InstallationStable version:pip install discord.jsWorking version:pip install git+https://github.com/CodeWithSwastik/discord-jsSimple botfromdiscordjsimportClientfromjavascriptimportconsoleclient=Client()client.on("ready",lambda:console.log("Bot is ready"))asyncdefmsg(message):ifmessage.content.startswith("!ping"):awaitmessage.channel.send("pong")client.on("message",msg)client.login('Token')
Package: discord-limits
discord_limitsA simple library to asynchronously make API requests to Discord without having to worry about ratelimits.Currently this library has only been tested on Python 3.9Basic usageimportdiscord_limitsimportosimportasynciolimitsClient=discord_limits.DiscordClient(os.environ.get('TOKEN'))asyncdefmain():awaitlimitsClient.create_message(123456789012345678,content='Hello World!')asyncio.get_event_loop().run_until_complete(main())Requires:aiolimiteraiohttpBased off of:unbelipydiscord.py
Package: discord-linker-pythonAPI
DescriptionThis package allows python to communicate with a wordpress plugin "discord-linker" that allows you to link discord with wordpress.This api is used to create discord bots that can communicate with the website and perform actions on behalf of the discord users.Requirementsrequests =>pip install requestsInstallationpip install discord-linker-pythonAPIUsagefrom discord_linker_pythonAPI.wordpress_client import WP_Client

wpclient = WP_Client("<URL>", "<Username>", "<Application Password>")LinksDocumentation:https://vbrawl.github.io/discord-linker-pythonAPI/PyPi:https://pypi.org/project/discord-linker-pythonAPI/
Package: discordlogger
discord-loggerA Python logger to send information to Discord Webhooks.InstallationInstall this package viapipby executingpip install discordloggerUsageBasic UsageimportloggingfromdiscordloggerimportDiscordFormatterlogger=logging.getLogger(__name__)logger.setLevel(logging.INFO)h=DiscordHandler(webhook_url=URL)h.setLevel(logging.INFO)logger.addHandler(h)logger.info('Hello World')Advanced FormatingimportloggingfromdiscordloggerimportDiscordFormatter,DiscordHandlerlogger=logging.getLogger(__name__)logger.setLevel(logging.INFO)h=DiscordHandler(webhook_url=URL)h.addFormatter(DiscordFormatter())logger.addHandler(h)logger.info('Hello World')logger.warning('Warning!')try:print(data['hello'])exceptException:logger.exception('Exception!')logger.critical('Emergency here!')FilteringimportloggingfromdiscordloggerimportDiscordFormatter,DiscordLogFilterlogger=logging.getLogger(__name__)logger.setLevel(logging.INFO)h=DiscordHandler(webhook_url=URL)h.addFilter(DiscordLogFilter())logger.addHandler(h)# Now this doesn't activate the discord webhooklogger.info("Hello World")# Whereas this doeslogger.info("Hello World",extra={'notify_discord':True})
Package: discord-logging
discord_loggingdiscord_logging is a logging extension module.By using this module, logs can be sent by webhook.installingInstall and update using pip:pip install discord_loggingA simple example.importdiscordimportloggingimportdiscord_logginglogger=logging.getLogger()WEBHOOK_URL="Your webhook url"handler=discord_logging.Discord_Handler(WEBHOOK_URL)logger.addHandler(handler)client=discord.Client()@client.eventasyncdefon_ready():print('login！(\'◇\')ゞ')@client.eventasyncdefon_message(message):ifmessage.author.bot:returnifmessage.content=='/hello':awaitmessage.channel.send('hello')client.run('THi5IsDuMMyaCCesSTOK3nQ4.Cl2FMQ.ThIsi5DUMMyAcc3s5ToKen7kKWs')
Package: discord-logging-fork1
discord_loggingdiscord_logging is a logging extension module.By using this module, logs can be sent by webhook.installingInstall and update using pip:pip install discord_loggingA simple example.importdiscordimportloggingimportdiscord_logginglogger=logging.getLogger()WEBHOOK_URL="Your webhook url"handler=discord_logging.Discord_Handler(WEBHOOK_URL)logger.addHandler(handler)client=discord.Client()@client.eventasyncdefon_ready():print('login！(\'◇\')ゞ')@client.eventasyncdefon_message(message):ifmessage.author.bot:returnifmessage.content=='/hello':awaitmessage.channel.send('hello')client.run('THi5IsDuMMyaCCesSTOK3nQ4.Cl2FMQ.ThIsi5DUMMyAcc3s5ToKen7kKWs')
Package: discord-lumberjack
discord-lumberjackA Python logging handler which sends its logs to a Discord Channel or Webhook.DocumentationYou can find the documentationhere.InstallationTo install this python module, run the following command$ pip install discord-lumberjackHandlersThis python module provides several logging handlers (located in thediscord_lumberjack.handlersmodule) which will send the logs it recieves to a Discord webhook, server channel, or DM channel.The available handlers are:DiscordChannelHandler- Uses a bot token and a channel ID to send logs to the given channel from the given bot.DiscordDMHandler- Uses a bot token and a user ID to send logs to the given user from the given bot.DiscordWebhookHandler- Uses a webhook URL to send the logs to.DiscordHandler- This is the base class for the other three. You probably don't want to use this unless you're creating your own fancy handler.Message CreatorsIn order to send nice looking messages, there are a few message creators available (located in thediscord_lumberjack.message_creatorsmodule). These are responsible for converting alogging.LogRecordinto a message structure that will be sent to Discord's API.The message creators provided currently will split extremely long messages into several in order to fit within Discord's message limits. If you decide to create your own one, keep that in mind too.The available message creators are:BasicMessageCreator- This is a simple message creator which will use the handler's set formatter to send the message as plain text. By default, the message will be formatted in monospace, but this can be disabled via the constructor.EmbedMessageCreator- This message creator will create a fancy-looking embed message from the log record. It will ignore the handler's formatter.UsageThe easiest way to get started is to create a webhook and use that, but if you're using this to log a Discord bot, you can use it's token directly, without needing to create webhooks.ImportFirst, you should import the handlers you want to use. For this example, we'll assume we have a Discord bot and we'd like to use it to log every message to a channel and also to send errors to a DM.We'll be using theDiscordChannelHandlerto send all messages of levelINFOand above to the channel andDiscordDMHandlerto send messages of levelERRORand above to a DM.fromdiscord_lumberjack.handlersimportDiscordChannelHandler,DiscordDMHandlerBasic SetupYou should really read thedocumentation for theloggingmoduleto learn how to set up your logging, but here's a quick snippet to get you started.importlogginglogging.basicConfig(level=logging.INFO,handlers=[DiscordChannelHandler(token=my_bot_token,channel_id=my_channel_id),DiscordDMHandler(token=my_bot_token,user_id=my_user_id,level=logging.ERROR),])Once you've set up your logging, you can start logging messages like this:logging.info("This is an informative message that will be sent to the channel.")logging.error("This is an error, so it will also be sent to the DM.")
Package: discord-markdown
Discord MarkdownI needed to render some Discord chat logs as HTML, and found that the Markdown implementation in Discord isn't quite compliant with Common Markdown as Discord uses a simplified version.So I wrote this library that allows you to convert a discord message written in the Markdown formatting syntax specifiedhereto html.InstallationYou can install the library frompypi:pipinstalldiscord-markdownUsagefromdiscord_markdown.discord_markdownimportconvert_to_htmltext="_This_ **is** an __example__.\nThis should be a different paragraph."html=convert_to_html(text)asserthtml=='<p><i>This</i> <b>is</b> an <u>example</u>.</p><p>This should be a different paragraph.</p>'
Package: discord-message-components-polarsbear
Discord Message ComponentsA python library that adds message component support to discord botsUsageI will add proper documentation very soonfromdiscord_message_componentsimport*fromdiscord.ext.commandsimportBotimportdiscordbot=Bot("prefix")components=ComponentHelper()button=Button("visible label",1,"custom_id")components.addComponent(button)@bot.eventasyncdefon_socket_raw_receive(msg):interaction=awaitwebsocket_wrap(msg)ifinteractionisnotNone:# Making sure the interaction actually happened and was for message componentsawaitrespond(interaction,f"{interaction.member_data.username}clicked button{components.getFirstComponent(interaction.data.custom_id)}")# This acts just like discord_message_components.send_message, except it requires an interaction, and cannot have a message reference@bot.command()asyncdefmycommand(ctx):awaitsend_message(ctx.channel,"content",components=components)config.token="My Token"#the token is required for sending the messages with components
Package: discord-msg-lite
Discord message liteThis is a simple and lightweight Python PyPI module to send messages easily using Discord Webhooks.InstallationRun the following to install:pipinstalldiscord-msg-liteUsagefromdiscord_msg_liteimportDiscord_msgwebhook_url='https://discordapp.com/api/webhooks/123456789012345678/8xZhP4Zj-8KMVN7wLw6jE04VEK5BIfRxpzCwCwgHxpaNOQzZOTR95dPW53EMRjybXjAO'dmsg=Discord_msg(webhook_url)dmsg.send('test 12345 ㄱㄴㄷㄹ')
Package: discord-musicbot
Discord bot made with Python which is aimed to control Spotify.Getting startedExplanations for setting up and running the bot.RequirementsPython 3.6aiohttp 2.1.0Selenium-PythonSpotipyInstallation$pipinstalldiscord-musicbotRunning$python-mmusicbotIf you entered wrong user credentials, you can restart
the configuration as follows:$python-mmusicbotresetConfigurationAt the first start of the bot, some configurations questions
are asked to the user from command line. These are the following:Channel ID of the botDiscord tokenSpotify tokenSpotify Client ID/SecretOnce they’re configured, there’s no need to configure them again.webdriverThe bot may use a chrome webdriver in order to manage the Spotify app by itself.
The driver can be found here:Chrome webdriverNote that the driver must be in the user’s PATH.BibliographyA Discord bot with asyncioDiscord API ReferenceSpotify API ReferenceTravisbot
Package: discord-notify
discord_notifydiscord_notifyis a minimal Discord API webhooks wrapper for easily sending messages to a Discord channel.Use CasesRemote logging for lengthy Python scripts, such as:Providing notifications during neural network training (e.g. logging validation accuracy after each training epoch)Providing notifications on the status of a Python web serverRegularly displaying information on a Discord channel without configuring a botInstallationpip install discord_notifyUsageFirst, you'll need to create a new webhook for one of your Discord channels (Edit Channel > Integrations > Webhooks).Then you can use this webhook in your code by creating an instance of theNotifierclass and using the webhook's URL:importdiscord_notifyasdnnotifier=dn.Notifier(URL)Sending Messages OnceMessages can be sent through the webhook by using thesendmethod of theNotifierclass.notifier.send("Hello, world!",print_message=False)print_messageindicates whether or not the provided message should be printed to the console. It defaults toTrue.Sending Messages RepeatedlyThe send_repeat method can be used to send messages over a regular interval of time.x=0notifier.send_repeat(lambda:x,1.5,print_message=False)whilex<100000:x+=0.0001The first parameter is a callable that returns the value to send, and the second parameter is the number of seconds to wait between webhook executions.The method'sdaemonparameter can be set toFalse, forcing the timer thread to be stopped manually with thestop_repeatmethod. This requires atimer_idwhich is returned fromsend_repeat:x=0timer_id=notifier.send_repeat(lambda:x,1.5,print_message=False,daemon=False)whilex<100000:x+=0.0001ifx>10000:notifier.stop_repeat(timer_id)
Package: discord-oauth2
discord_oauth2A python library that uses discord's api for easy authentication for your application!InstallationInstall discord-oauth2 with npmpip3installdiscord-oauth2DocumentationRead the docshereContributingContributions are always welcome!If you want to contribute please open an issue first.FAQThis is my very first python library.When you select a function on VSCode, it will show some messages on how you will use it and what are the parameters.Author@paulablazaLicenseMIT
Package: discord-oauth2.py
DiscordOAuth2.pyUse Discord's OAuth2 effortlessly! Turns the auth code to a access token and the access token into scope infomation.Useful LinksDiscord Server:https://discord.gg/DJ9xbbZAP5Documentation is coming soon, don't worry.QuickstartInstallingI've finally published the library to PyPi! So now you can use pip.pip install discord-oauth2.pyExample With FlaskDon't forget to replace all the client information with your application's own information. You can leave bot token empty if your not adding members to guilds.importdiscordoauth2fromflaskimportFlask,requestclient=discordoauth2.Client(849930878276993044,secret="very-secret-code",redirect="https://findingfakeurlsisprettyhard.tv/oauth2",bot_token="bot-token-only-required-for-guild-joining-or-updating-linked-roles-metadata")app=Flask(__name__)client.update_linked_roles_metadata([{"type":2,"key":"level","name":"Level","description":"The level the user is on"},{"type":7,"key":"supporter","name":"Supporter","description":"Spent money to help the game"}])@app.route('/')defmain():returnredirect(client.generate_uri(scope=["identify","connections","guilds","role_connections.write"]))@app.route("/oauth2")defoauth2():code=request.args.get("code")access=client.exchange_code(code)access.update_metadata("Platform Name","Username",level=69,supporter=True)identify=access.fetch_identify()connections=access.fetch_connections()guilds=access.fetch_guilds()returnf"""{identify}<br><br>{connections}<br><br>{guilds}"""app.run("0.0.0.0",8080)
Package: discordoauth.py
discordwebhook.pyA python package for using Discord Oauth2 with any webserver.
Designed to be simple to use with as little input as possible.
Asynchronous webservers (eg Quart) are reccomendedFor downloads see thePyPi pageFor documentation see the /docs directory.
For extra support jointhe Discord serverInstallationpip install discordoauth.pyExamplesSee Examples in the examples/ directoryQuart example"""Basic Quart example for using Discord Oauth2"""importquartimportdiscordoauthapp=quart.Quart(__name__)# The application ID and secret to use for Oauth.app_id=999999999999999999app_secret="app_secret_here"# Initialise client and choose scopes.# Supported scopes can be seen in the README.mdclient=discordoauth.Client(app_id,app_secret)scopes=discordoauth.Scopes(identify=True)# The address that flask is currently running onaddress="localhost:5000"@app.route("/login",["GET"])def_login():# Generate an oauth URL and redirect the user to itreturnquart.redirect(client.get_oauth_url(scopes,rediret_uri=address+"/return"))@app.route("/return",["GET"])asyncdef_discord_return():# Get the code discord responds with from URI argumentscode=quart.request.args.get("code")# Start a sessionsession=client.new_session(code,scopes,address+"/return")# Use scope identify to fetch user information. Automatically converts code to access tokenuser=awaitsession.fetch_user()returnf"""Username:{user.name}<br>User ID:{user.id}"""# Run the app locally on port 5000app.run("0.0.0.0",5000)