Package: python-discord-client
Welcome to python-discord-clientUnofficial Python Discord SDK📍 Note: We have nothing to do with Discord and have not contributed to the Discord documentation!📍 This project is worked on daily. The releases available on PyPi may differ from those in the Github repository. So please see PyPi for working examples.FeaturesConnect to your Discord accountSimple handling of authenticationAccess nearly all Discord REST endpoints (synchron and asynchron)Websocket Client to receive almost all eventsCreate your custom Bots and manage your GuildsQuick StartRegister atDiscordCreate a new app or use an existing one athttps://discord.com/developers/applicationsCreate a bot, set permissions and save your tokenpython3-mpipinstallpython-discord-clientSynchron REST ClientsfromdiscoPy.rest.clientimportApplication,User,Guild,Channel,Stage,Webhooktoken='your-discord-token'channel=Channel(token=token)channel.create_message(channel_id='<some-channel-id>',content='Hello World!')guild=Guild(token=token)print(guild.get_guild(guild_id='<some-guild-id>'))stage=Stage(token=token)print(stage.get_stage_instance(channel_id='<some-channel-id>'))app=Application(token=token)print(app.get_application_commands(application_id='<some-app-id>'))user=User(token=token)print(user.get_current_user())# ...Websockets / WS Client (asynchron)fromdiscoPy.core.WSClientimportWSClientimportasyncioclassCustomClient(WSClient):asyncdefon_event(self,event)->None:print(event)# <- comment this outifnoteventor'op'notinevent:returnifevent['op']==0:# Dispatchtry:print(f'Channel:{data["d"]["channel_id"]}|{data["d"]["author"]["username"]}:{data["d"]["content"]}')# if condition:#    await self.create_message(#           channel_id=channel_id, content='I love it!'#    )except:# handle...passelifevent['op']==3:# Presence Updateprint(f'This is OP 3 -{event}')elifevent['op']==4:# Voice State Updateprint(f'This is OP 4 -{event}')elifevent['op']==6:# Resumeprint(f'This is OP 6 -{event}')elifevent['op']==7:# Reconnectprint(f'This is OP 7 -{event}')elifevent['op']==8:# Request Guild Membersprint(f'This is OP 8 -{event}')elifevent['op']==9:# Invalid Sessionprint(f'This is OP 9 - Invalid Session!{event}')elifevent['op']==10:# Helloprint('Hearbeat interval received!')elifevent['op']==11:# Heartbeat ACKprint('Heartbeat Received')else:print(f"huh?{event}")asyncdefmain()->None:token='<discord-bot-token>'#all_intents: list = WSClient.get_intents_list()ws_client=CustomClient(token=token,intents=['DIRECT_MESSAGES','GUILDS'],)# Almost every endpoint can be accessed via the websocket client.print(awaitmyclient.get_current_user())print(awaitmyclient.get_channel('<some-channel-id>'))# ...myclient.run()# opens the websocket connection to receive eventswhileTrue:awaitasyncio.sleep(30)if__name__=='__main__':asyncio.get_event_loop().run_until_complete(main())Important notesThe implementation of the methods was based on the official documentation of the Discord API. Parameters and endpoints have been adapted to it.
On the official page of the Discord API documentation you can see which requirements and parameters are needed for the respective methods.Note: We have nothing to do with Discord and have not contributed to the Discord documentation!MethodsAll methods below are available via the REST and Websocket Clients.ApplicationMethodDocumentationget_application_commandshttps://discord.com/developers/docs/interactions/application-commands#get-global-application-commandscreate_application_commandhttps://discord.com/developers/docs/interactions/application-commands#create-global-application-commandget_global_application_commandhttps://discord.com/developers/docs/interactions/application-commands#get-global-application-commandedit_global_application_commandhttps://discord.com/developers/docs/interactions/application-commands#edit-global-application-commanddelete_global_application_commandhttps://discord.com/developers/docs/interactions/application-commands#delete-global-application-commandbulk_overwrite_global_application_commandhttps://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-global-application-commandsget_guild_application_commandshttps://discord.com/developers/docs/interactions/application-commands#get-guild-application-commandscreate_guild_application_commandhttps://discord.com/developers/docs/interactions/application-commands#create-guild-application-commandget_guild_application_commandhttps://discord.com/developers/docs/interactions/application-commands#get-guild-application-commandedit_guild_application_commandhttps://discord.com/developers/docs/interactions/application-commands#edit-guild-application-commanddelete_guild_application_commandhttps://discord.com/developers/docs/interactions/application-commands#delete-guild-application-commandbulk_overwrite_guild_application_commandhttps://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commandsget_guild_application_command_permissionshttps://discord.com/developers/docs/interactions/application-commands#get-guild-application-command-permissionsget_application_comman_permissionshttps://discord.com/developers/docs/interactions/application-commands#get-application-command-permissionsedit_application_command_permissionshttps://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissionsbatch_edit_application_command_permissionshttps://discord.com/developers/docs/interactions/application-commands#batch-edit-application-command-permissionsUserMethodDocumentationget_current_userhttps://discord.com/developers/docs/resources/user#get-current-userget_userhttps://discord.com/developers/docs/resources/user#get-usermodify_current_userhttps://discord.com/developers/docs/resources/user#modify-current-userget_current_user_guildshttps://discord.com/developers/docs/resources/user#get-current-user-guildsget_current_user_guild_memberhttps://discord.com/developers/docs/resources/user#get-current-user-guild-memberleave_guildhttps://discord.com/developers/docs/resources/user#leave-guildcreate_dmhttps://discord.com/developers/docs/resources/user#create-dmcreate_group_dmhttps://discord.com/developers/docs/resources/user#create-group-dmget_user_connectionshttps://discord.com/developers/docs/resources/user#get-user-connectionslist_voice_regionshttps://discord.com/developers/docs/resources/voice#list-voice-regionsget_invitehttps://discord.com/developers/docs/resources/invite#get-invitedelete_invitehttps://discord.com/developers/docs/resources/invite#delete-inviteGuildGeneralMethodDocumentationcreate_guildhttps://discord.com/developers/docs/resources/guild#create-guildget_guildhttps://discord.com/developers/docs/resources/guild#get-guildget_guild_previewhttps://discord.com/developers/docs/resources/guild#get-guild-previewmodify_guildhttps://discord.com/developers/docs/resources/guild#modify-guilddelete_guildhttps://discord.com/developers/docs/resources/guild#delete-guildget_guild_channelshttps://discord.com/developers/docs/resources/guild#get-guild-channelscreate_guild_channelhttps://discord.com/developers/docs/resources/guild#create-guild-channelmodify_channel_positionshttps://discord.com/developers/docs/resources/guild#modify-guild-channel-positionslist_active_threadshttps://discord.com/developers/docs/resources/guild#list-active-threadsget_guild_memberhttps://discord.com/developers/docs/resources/guild#get-guild-memberlist_guild_membershttps://discord.com/developers/docs/resources/guild#list-guild-memberssearch_guild_membershttps://discord.com/developers/docs/resources/guild#search-guild-membersadd_guild_memberhttps://discord.com/developers/docs/resources/guild#add-guild-membermodify_current_memberhttps://discord.com/developers/docs/resources/guild#modify-current-memberadd_guild_member_rolehttps://discord.com/developers/docs/resources/guild#add-guild-member-roleremove_guild_member_rolehttps://discord.com/developers/docs/resources/guild#remove-guild-member-roleremove_guild_memberhttps://discord.com/developers/docs/resources/guild#remove-guild-memberget_guild_banshttps://discord.com/developers/docs/resources/guild#get-guild-bansget_guild_banhttps://discord.com/developers/docs/resources/guild#get-guild-bancreate_guild_banhttps://discord.com/developers/docs/resources/guild#create-guild-banremove_guild_banhttps://discord.com/developers/docs/resources/guild#remove-guild-baget_guild_roleshttps://discord.com/developers/docs/resources/guild#get-guild-rolescreate_guild_rolehttps://discord.com/developers/docs/resources/guild#create-guild-rolemodify_guild_role_permissionshttps://discord.com/developers/docs/resources/guild#modify-guild-role-positionsmodify_guild_rolehttps://discord.com/developers/docs/resources/guild#modify-guild-roledelete_guild_rolehttps://discord.com/developers/docs/resources/guild#delete-guild-roleget_guild_prune_counthttps://discord.com/developers/docs/resources/guild#get-guild-prune-countbeginn_guild_prunehttps://discord.com/developers/docs/resources/guild#begin-guild-pruneget_guild_voice_regionshttps://discord.com/developers/docs/resources/guild#get-guild-voice-regionsget_guild_inviteshttps://discord.com/developers/docs/resources/guild#get-guild-invitesget_guild_integrationshttps://discord.com/developers/docs/resources/guild#get-guild-integrationsdelete_guild_integrationshttps://discord.com/developers/docs/resources/guild#delete-guild-integrationWidgets and StylesMethodDocumentationget_guild_widget_settingshttps://discord.com/developers/docs/resources/guild#get-guild-widget-settingsmodify_guild_widgethttps://discord.com/developers/docs/resources/guild#modify-guild-widgetget_guild_widgethttps://discord.com/developers/docs/resources/guild#get-guild-widgetget_guild_vanity_urlhttps://discord.com/developers/docs/resources/guild#get-guild-vanity-urlget_guild_widget_imagehttps://discord.com/developers/docs/resources/guild#get-guild-widget-imageget_guild_welcome_screenhttps://discord.com/developers/docs/resources/guild#get-guild-welcome-screenmodify_guild_welcome_screenhttps://discord.com/developers/docs/resources/guild#modify-guild-welcome-screenmodify_current_user_voice_statehttps://discord.com/developers/docs/resources/guild#modify-guild-welcome-screenmodify_current_user_voice_statehttps://discord.com/developers/docs/resources/guild#modify-current-user-voice-statemodify_user_voice_statehttps://discord.com/developers/docs/resources/guild#modify-user-voice-stateget_guild_audit_loghttps://discord.com/developers/docs/resources/audit-log#get-guild-audit-logScheduled EventsMethodDocumentationlist_scheduled_events_for_guildhttps://discord.com/developers/docs/resources/guild-scheduled-event#list-scheduled-events-for-guildcreate_guild_scheduled_eventhttps://discord.com/developers/docs/resources/guild-scheduled-event#create-guild-scheduled-eventget_guild_scheduled_eventhttps://discord.com/developers/docs/resources/guild-scheduled-event#get-guild-scheduled-eventmodify_guild_scheduled_eventhttps://discord.com/developers/docs/resources/guild-scheduled-event#modify-guild-scheduled-eventdelete_guild_scheduled_evendhttps://discord.com/developers/docs/resources/guild-scheduled-event#delete-guild-scheduled-eventget_guild_scheduled_event_usershttps://discord.com/developers/docs/resources/guild-scheduled-event#get-guild-scheduled-event-usersGuild TemplatesMethodDocumentationget_guild_templatehttps://discord.com/developers/docs/resources/guild-template#get-guild-templatecreate_guild_templatehttps://discord.com/developers/docs/resources/guild-template#create-guild-from-guild-templateget_guild_templateshttps://discord.com/developers/docs/resources/guild-template#get-guild-templatescreate_guild_templatehttps://discord.com/developers/docs/resources/guild-template#create-guild-templatesync_guild_templatehttps://discord.com/developers/docs/resources/guild-template#sync-guild-templatemodify_guild_templatehttps://discord.com/developers/docs/resources/guild-template#modify-guild-templatedelete_guild_templatehttps://discord.com/developers/docs/resources/guild-template#delete-guild-templateEmojiMethodDocumentationlist_guild_emojishttps://discord.com/developers/docs/resources/emoji#list-guild-emojisget_guild_emojihttps://discord.com/developers/docs/resources/emoji#get-guild-emojicreate_guild_emojihttps://discord.com/developers/docs/resources/emoji#create-guild-emojimodify_guild_emojihttps://discord.com/developers/docs/resources/emoji#modify-guild-emojidelete_guild_emojihttps://discord.com/developers/docs/resources/emoji#delete-guild-emojiStickerMethodDocumentationget_stickerhttps://discord.com/developers/docs/resources/sticker#get-stickerlist_nitro_sticker_packshttps://discord.com/developers/docs/resources/sticker#list-nitro-sticker-packslist_guild_stickershttps://discord.com/developers/docs/resources/sticker#list-guild-stickersget_guild_stickerhttps://discord.com/developers/docs/resources/sticker#get-guild-stickercreate_guild_sticker'https://discord.com/developers/docs/resources/sticker#create-guild-stickermodify_guild_stickerhttps://discord.com/developers/docs/resources/sticker#modify-guild-stickerdelete_guild_stickerhttps://discord.com/developers/docs/resources/sticker#delete-guild-stickerChannelGeneralMethodDocumentationget_channelhttps://discord.com/developers/docs/resources/channel#get-channelmodify_channelhttps://discord.com/developers/docs/resources/channel#modify-channeldelete_close_channelhttps://discord.com/developers/docs/resources/channel#deleteclose-channelget_channel_messageshttps://discord.com/developers/docs/resources/channel#get-channel-messagesget_channel_messagehttps://discord.com/developers/docs/resources/channel#get-channel-messagecreate_messagehttps://discord.com/developers/docs/resources/channel#create-messagecrosspost_messagehttps://discord.com/developers/docs/resources/channel#crosspost-messagecreate_reactionhttps://discord.com/developers/docs/resources/channel#create-reactiondelete_own_reactionhttps://discord.com/developers/docs/resources/channel#delete-own-reactiondelete_user_reactionhttps://discord.com/developers/docs/resources/channel#delete-user-reactionget_reactionshttps://discord.com/developers/docs/resources/channel#delete-user-reactionget_reactionshttps://discord.com/developers/docs/resources/channel#get-reactionsdelete_all_reactionshttps://discord.com/developers/docs/resources/channel#delete-all-reactionsdelete_all_reactions_for_emojihttps://discord.com/developers/docs/resources/channel#delete-all-reactions-for-emojiedit_messagehttps://discord.com/developers/docs/resources/channel#edit-messagedelete_messagehttps://discord.com/developers/docs/resources/channel#delete-messagebulk_delete_messagehttps://discord.com/developers/docs/resources/channel#bulk-delete-messagesedit_channel_permissionshttps://discord.com/developers/docs/resources/channel#edit-channel-permissionsget_channel_inviteshttps://discord.com/developers/docs/resources/channel#get-channel-invitescreate_channel_invitehttps://discord.com/developers/docs/resources/channel#create-channel-invitedelete_channel_permissionhttps://discord.com/developers/docs/resources/channel#delete-channel-permissionfollow_news_channelhttps://discord.com/developers/docs/resources/channel#follow-news-channeltrigger_typing_indicatoehttps://discord.com/developers/docs/resources/channel#trigger-typing-indicatorget_pinned_messagehttps://discord.com/developers/docs/resources/channel#get-pinned-messagespin_messagehttps://discord.com/developers/docs/resources/channel#pin-messageunpin_messagehttps://discord.com/developers/docs/resources/channel#unpin-messagegroup_dm_add_recipienthttps://discord.com/developers/docs/resources/channel#group-dm-add-recipientgroup_dm_remove_recipienthttps://discord.com/developers/docs/resources/channel#group-dm-remove-recipientThreadsMethodDocumentationstart_thread_with_messagehttps://discord.com/developers/docs/resources/channel#start-thread-with-messagestart_thread_without_messagehttps://discord.com/developers/docs/resources/channel#start-thread-without-messagejoin_threadhttps://discord.com/developers/docs/resources/channel#join-threadadd_thread_memberhttps://discord.com/developers/docs/resources/channel#add-thread-memberleave_threadhttps://discord.com/developers/docs/resources/channel#leave-threadremove_thread_memberhttps://discord.com/developers/docs/resources/channel#remove-thread-memberget_thread_memberhttps://discord.com/developers/docs/resources/channel#get-thread-memberlist_thread_memberhttps://discord.com/developers/docs/resources/channel#list-thread-memberslist_active_threadshttps://discord.com/developers/docs/resources/channel#list-active-threadslist_public_archived_threadshttps://discord.com/developers/docs/resources/channel#list-public-archived-threadslist_private_archived_threadshttps://discord.com/developers/docs/resources/channel#list-private-archived-threadslist_joined_private_archived_threadshttps://discord.com/developers/docs/resources/channel#list-joined-private-archived-threadsStageMethodDocumentationcreate_stage_instancehttps://discord.com/developers/docs/resources/stage-instance#create-stage-instanceget_stage_instancehttps://discord.com/developers/docs/resources/stage-instance#get-stage-instancemodify_stage_instancehttps://discord.com/developers/docs/resources/stage-instance#modify-stage-instancedelete_stage_instancehttps://discord.com/developers/docs/resources/stage-instance#delete-stage-instanceWebhookMethodDocumentationcreate_webhookhttps://discord.com/developers/docs/resources/webhook#create-webhookget_channel_webhookshttps://discord.com/developers/docs/resources/webhook#create-webhookget_guild_webhookshttps://discord.com/developers/docs/resources/webhook#get-guild-webhooksget_webhookhttps://discord.com/developers/docs/resources/webhook#get-webhookget_webhook_with_tokenhttps://discord.com/developers/docs/resources/webhook#get-webhook-with-tokenmodify_webhookhttps://discord.com/developers/docs/resources/webhook#modify-webhookmodify_webhook_with_tokenhttps://discord.com/developers/docs/resources/webhook#modify-webhook-with-tokendelete_webhookhttps://discord.com/developers/docs/resources/webhook#delete-webhookdelete_webhook_with_tokenhttps://discord.com/developers/docs/resources/webhook#delete-webhook-with-tokenexecute_webhookhttps://discord.com/developers/docs/resources/webhook#execute-webhookdelete_webhook_messageshttps://discord.com/developers/docs/resources/webhook#delete-webhook-messageget_original_interaction_responsehttps://discord.com/developers/docs/interactions/receiving-and-responding#get-original-interaction-responsedelete_original_interaction_responsehttps://discord.com/developers/docs/interactions/receiving-and-responding#delete-original-interaction-responsecreate_followup_messagehttps://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-messageget_followup_messagehttps://discord.com/developers/docs/interactions/receiving-and-responding#get-followup-messageedit_followup_messagehttps://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-messagedelete_followup_messagehttps://discord.com/developers/docs/interactions/receiving-and-responding#delete-followup-messageNot implemented:MethodDocumentationexecute_webhookhttps://discord.com/developers/docs/resources/webhook#execute-webhookexecute_github_compatible_webhookhttps://discord.com/developers/docs/resources/webhook#execute-slackcompatible-webhookget_webhook_messageshttps://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhookedit_webhook_messageshttps://discord.com/developers/docs/resources/webhook#edit-webhook-messageedit_original_interaction_responsehttps://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-responseTodoTesting