Tumgik
#discord.py
the-pipistrelle · 1 year
Text
my first medium article is live now! we will be going through how to create the most bare-bones discord.py bot out there. this is a tutorial for very new beginners of discord.py, so if you have made a discord bot before, this may not be the tutorial for you. i will have more coming out in the coming weeks, so please stay tuned!
here are some code snippets from the tutorial :
Tumblr media Tumblr media Tumblr media
there weren't many to choose from unfortunately...but in future tutorials i will definitely have quite a few!
well anyways guys. i'm glad i could tear myself away from my new red dead addiction to get this out there for you. i will be teasing the next tutorial soon...and that will be a lot more fun than this simple old bot here. we love tobey though, he's a good bot.
thanks for checking it out! consider giving my github and medium a follow if you're interested in these discord tutorials. i'll be linking them here on tumblr, but will be posting those on medium.
thanks for checking it out! i'm off for some apex.
39 notes · View notes
a-fox-studies · 10 months
Text
Tumblr media
July 8, 2023
It's going great! I planned a little, creating a board in Milanote (I would advertise that platform forever, milanote should sponsor me).
Here's the plan: (click for better quality)
Tumblr media
I'm making progress, and I'm having a lot of fun with this project! (I should really started projects that add to my resume buttttttttt my hyperfixated ass disagrees)
I'm really enjoying coding dropdown menus instead of embeds, and there's a lot of flexibility with the UI components! I can make the bot more interactive rather than sticking with commands, which is awesome!
🎧 High on Love - Sid Sriram, Yuvan Shankar Raja
15 notes · View notes
octobrushwizard · 4 months
Text
hey guys I'm making a squid yaoi discord bot but I don't have any squid yaoi can you give me some
remember: give me the artist's name/handle, a link to the source of the image, and the image link itself
1 note · View note
developerhelp · 1 year
Text
Praw & Discord.py: The bot keep sending the same meme. I want the bot to send different meme whenever it is asked
Praw & Discord.py: The bot keep sending the same meme. I want the bot to send different meme whenever it is asked
There is no need for you to iterate over anything. Praw provides a method which allows you to grab a random submission from a subreddit. Documentation: random() Code: @nd.listen() async def on_message(message): if message.author == nd.user: return def findCoindences(w): return re.compile(r'\b({0})\b'.format(w)).search content = message.content reaction = "👍" if…
View On WordPress
0 notes
Text
Alright once anaconda finishes installing I can start on the project I came up with about two weeks ago: making discord bot that interfaces with an arduino so that your friends can yell at you for not drinking enough water
8 notes · View notes
rickybabyboy · 6 months
Text
Whatever is going on with the ricky bot is some sort of upstream issue with libraries that discord.py uses, I'm gonna try upgrading python entirely but if that doesn't work I'll just switch languages, either way, ricky bot will be stable soon
65 notes · View notes
kaiasky · 1 day
Text
i love discord.py bc it's this wonderful combination between something that a lot of new programmers want to try, and a difficult-to-debug thing in an unintuitive paradigm with a lot of footguns. it feels like if you got into a competition over beers over "who could make the library with the most stackoverflow questions after 3 years" it'd be the library you create
7 notes · View notes
intercal · 2 years
Text
dealing with dependencies is like pulling teeth
I wanted to update my fortune bot for Discord. This required a full update of Debian, because they lock software versions so I could go from Python 3.7 -> 3.9, which supports the feature I wanted.
After the upgrade, I get errors indicating that Python wasn't updated. It actually was, but Pipenv doesn't appear to update the version of Python unless you tell it to - and even telling it to update the version of Python you're using doesn't actually seem to work. So I have to delete the virtualenv directory so it can get recreated with the appropriate version.
The Discord library I'm using was on version 1.7, and the newest version (which uses Discord API version 10) is a major upgrade to 2.0. My main mistake was here: I hadn't specified that I want to stay on the 1.x branch and just used the * which brought in breaking changes. Now I have to go in to change code, so that it works with "intents". Discord API version 10 requires you to get special permissions to read incoming messages, so I get that set up. However, it simply doesn't work even though I've followed their guides (and according to their documentation, I shouldn't even need to use these permissions unless my bot is part of 100 or more servers - which it's not). I get back a blank "content" field for every message I receive.
OK, so it's time to downgrade to a known working version. I update the Pipfile to specify discord.py to use version 1.7.3, the last in the major version. This does seem to do something, but it doesn't actually update the version of the library. pipenv run pip freeze shows that we're still on version 2.0.1. So I have to go in and set it to ==1.7.3, even though you'd think that specifying a different major version would convince the dependency management to kick it back to a previous version. OK, so now we're back to this whole thing back to the original state we were at before any upgrades had taken place. Now I'm able to use `from typing import Protocol` in Python, which was introduced in Python 3.8.
All this headache for a 100-line bot that chooses a random line of text to send back to someone when prompted. It should really not be this difficult to update to a new version of software, and yet I feel like I run into shit like this pretty much every time I try to update my software. Is this just me? I never read stories about anyone running into bullshit like this, where one small change cascades so catastrophically down the chain and causes me to waste an hour just pleading the computer to do what I'm telling it to.
29 notes · View notes
chorus-communities · 2 years
Text
it’s the year 2022 and i’ve decided to, after years of not touching discord.py or any of it’s api, code a bot again
Tumblr media
it’s been going great
6 notes · View notes
noxiatoxia · 2 years
Text
i may make kaoru bot open source one day i.e release his coding files but what holds me back is
1. the code is. not optimized. i started him when i knew nothing of discord.py so it now looks super messy compared to what i DO know but it works so i dont wanna change it. its just messy but its embarrassing
2. the amount of Hitachiincest and kill yourself jokes will get me at least one callout post
2 notes · View notes
Text
Embark on a coding adventure with me as we explore the fascinating world of Discord bot development using Python and the discord.py library. In this blog post, we dive into the creation of an engaging trivia game that will put your knowledge to the test!
If you're passionate about coding, Discord, or bot development, this blog post is a must-read. Feel free to share it with your fellow Tumblr community members who might find it interesting and valuable.
I'm eager to hear your thoughts and engage in meaningful discussions. Let's connect and continue our coding journey together!
Thank you for your support, and I hope you enjoy the blog post as much as I enjoyed creating it!
0 notes
the-pipistrelle · 1 year
Text
Tumblr media
I have officially scheduled the jinx-bot tutorial for tomorrow morning! any guesses on what the command will be?
I am so proud to release this tutorial as from conception to frankenstein moment, it is my mind's baby lol. the bot I am basing jinx-bot off of was my first independent discord.py bot and will be have more of its commands featured in tutorials in the future.
more to come soon!
16 notes · View notes
fw3d · 1 year
Text
How to Create your Own Discord Bot
Discord bots are a great way to add a little extra spice to your Discord server. With a few lines of code, you can make your own bot to respond to messages and do some fun stuff. In this blog post, we'll go through the basics of creating a Discord bot using Python and the popular Discord.py library.
Getting Started
First, you'll need to install Discord.py, which can be done with pip install discord.py. Then, create a new Python file where you'll write the code to control the bot.
Next, create a new Discord bot by going to the Discord Developer Portal and clicking the "New Application" button. Name your bot and click "Create". Once you've created the app, go to the "Bot" tab and click "Add Bot".
Finally, click on the "OAuth2" tab, select "bot" under "Scopes" and click "Copy" under "Bot Permissions". This will give your bot all the necessary permissions it needs to run.
Writing the Code
Now that we have the necessary components in place, it's time to write some code.
The first thing we'll do is create an instance of the Discord.Client class:
client = discord.Client() `</pre> This will create a new client object that we can use to interact with the Discord API.
Next, we'll need to create an event handler. This is a special function that runs whenever a particular event occurs on the server. For example, the on_message event is triggered whenever a new message is sent in the server:
`@client.event async def on_message(message): # Code goes here
This event handler takes one argument, which is the message object. This object contains all the information about the incoming message, such as the author, content, and more.
Now we can start writing the code to actually respond to the incoming messages. In this example
0 notes
suprcream · 1 year
Text
Basic Discord Bot with Python
Tutorial how to make a Basic Discord Bot using Python (discord.py v2 library) - Twitch
I made a tutorial on my Twitch. The tutorial is still in very basic part.
In this tutorial I teach some of discord bot feature such as Activate the bot, send message, send message in specific channel, mention user, get user information, error handling, using random to the command, and send Discord Embed. The next part will be streamed on the next stream.
This is the example from my tutorial
Tumblr media
Here is the code suprcream/basic-discord-bot: This is a template basic of discord bot using Discord.py v2 library (github.com)
1 note · View note
polhman · 2 years
Text
Discord stock
Tumblr media
DISCORD STOCK HOW TO
DISCORD STOCK SOFTWARE
Before we add our bot, we want to make sure we’ve got our permissions selected as well.įor this project we’ll only need Send Messages, Attach Files, and Add Reactions. We’ll select the bot OAuth scope, which will generate an invite link that we can use to add our bot to a server. Permissions and scopes we’ll need for this project We can get our bot going without requiring us to setup user authentication and redirects. This is done by going to the OAuth2 side menu option. I’m speaking from experienceįinally, the last step is to invite your bot to your server. Once our bot is created, we can grab our DISCORD_TOKEN for our Dockerfile.ĭO. This is an irreversible action and Discord will make sure to tell you that. Before we made our bot After we added a bot. YOU HAVE TO DO THIS TO CREATE A BOT USER. To make our application an actual bot, we need to click on the Bot sidebar option and then Build-A-Bot. This will bring us to the General Information page. Once you’re logged in you should find a page that looks similar to this screenshot: Taken from my own developers homepageįrom here, we’ll click on New Application and name our wonderful new application. I’m assuming that you, the reader, have a discord account. Since we’re only making a chat bot without any special kinds of permission, we don’t need to worry about messy OAuth stuff.
DISCORD STOCK HOW TO
Note that I’m writing this tutorial after slash commands were introduced, but before I really explored how to use them. With this file structure and docker installed, all we need to do to get up and running is just run the following command.Īny time we add a change, we just rerun docker build and docker run and we’ll be able to see our changes deployed live!Īt the end of this step, we’ll have a Discord bot user that we can invite to our server, as well as an application token to add to our Docker file.įirst thing we need to do is get our Discord bot set up and ready to go. The base image for this Dockerfile was built with the discord.py library in mind. This corresponds to our Docker looking like this. We’ll be starting this project off with the following file structure. We’ll be deploying Dockerfiles to Caprover in this tutorial, so any other hosting options or local docker runs will work just as well. Just make sure that you’ve got a domain name ready to go. Their marketplace has an easy to deploy image that gets you started pretty quickly. I found Caprover since I use DigitalOcean as my hosting provider.
DISCORD STOCK SOFTWARE
This tutorial won’t go into the nitty-gritty details of my development setup, but I will discuss how I’m hosting this bot and my process in getting changes out into 'production.'Ĭaprover is a deployment platform that I’ve found myself using over the last couple of months to simplify self hosting some of the open source software I use (bitwarden, etc.), as well as small personal projects. Here are some useful resources in general: Any actions you take outside of that recommendation is your own decision. My recommendation is that you too don’t give other people control over your money. I do not know what those ramifications are the knowledge that they exist is enough to keep me away from giving other people that sort of control. If you decide to use real money, be very mindful that there could be legal and tax ramifications for allowing other people trading securities in your name. This tutorial will be using a paper account on, so there is no real money involved. I’ll walk through my steps of building this potentially horrible idea so that others can also share their wealth amongst their friends, with no accountability (yet… stay tuned for part 2). Personally, I decided to help my friends find financial ruin with a stock trading Discord bot!Īlong this journey I’ve decided to build my new Discord friend, Dispaca the Alpaca! Sitting at home for a year, one starts to explore a variety of new and different hobbies to try and keep their sanity. This article originally appeared on Medium, written by Irving Derin Alpaca does not recommend any specific securities or investment strategies. The views and opinions expressed are those of the author and do not reflect or represent the views and opinions of Alpaca. All screenshots are for illustrative purposes only. Please note that this article is for educational and informational purposes only.
Tumblr media
0 notes
codehunter · 2 years
Text
RuntimeError: Timeout context manager should be used inside a task
Background: I am hosting a flask server alongside a discord client
The flask server just needs to pass on messages from the client to discord and from messages from discord to the client.
I am getting the error when I call loop.run_until_complete(sendMsg(request))I have tried wait_for in sendMsg and wait_for loop.run_until_complete()
I have looked everywhere and haven't found anything so any help would be appreciated.
Code:
import discordimport jsonimport osimport asynciofrom flask import Flask, request, render_templatefrom async_timeout import timeoutfrom threading import Threadfrom time import sleepclient = discord.Client()messages = []app = Flask(__name__)def startClient(): loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) client.run('token')## Discord Events#@client.eventasync def on_ready(): print('Discord Client Ready')@client.eventasync def on_message(message): global messages message.append(message)## Flask Stuff#async def sendMsg(request): await client.send_message(discord.Object('channel id'), request.form['message'])@app.route("/chat/", methods=['GET', 'POST'])def chatPage(): global messages if request.method == 'GET': return render_template('main.html') elif request.method == 'POST': loop = asyncio.new_event_loop() loop.run_until_complete(sendMsg(request)) return ''@app.route("/chat/get", methods=['GET'])def chatGet(): return json.dumps(messages[int(request.args['lastMessageId']):])# Start everythingos.environ["WERKZEUG_RUN_MAIN"] = 'true'print('Starting discord.py client')Thread(target=startClient).start()print('Starting flask')app.run(host='0.0.0.0', debug=True)
Traceback:
Traceback (most recent call last): File "/home/SuperKooks/.local/lib/python3.5/site-packages/flask/app.py", line 2309, in __call__ return self.wsgi_app(environ, start_response) File "/home/SuperKooks/.local/lib/python3.5/site-packages/flask/app.py", line 2295, in wsgi_app response = self.handle_exception(e) File "/home/SuperKooks/.local/lib/python3.5/site-packages/flask/app.py", line 1741, in handle_exception reraise(exc_type, exc_value, tb) File "/home/SuperKooks/.local/lib/python3.5/site-packages/flask/_compat.py", line 35, in reraise raise value File "/home/SuperKooks/.local/lib/python3.5/site-packages/flask/app.py", line 2292, in wsgi_app response = self.full_dispatch_request() File "/home/SuperKooks/.local/lib/python3.5/site-packages/flask/app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/SuperKooks/.local/lib/python3.5/site-packages/flask/app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File "/home/SuperKooks/.local/lib/python3.5/site-packages/flask/_compat.py", line 35, in reraise raise value File "/home/SuperKooks/.local/lib/python3.5/site-packages/flask/app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "/home/SuperKooks/.local/lib/python3.5/site-packages/flask/app.py", line 1799, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/mnt/c/Users/SuperKooks/Documents/Coding/HTML/kindle-discord/app.py", line 51, in chatPage loop.run_until_complete(sendMsg(request)) File "/usr/lib/python3.5/asyncio/base_events.py", line 387, in run_until_complete return future.result() File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result raise self._exception File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step result = coro.send(None) File "/mnt/c/Users/SuperKooks/Documents/Coding/HTML/kindle-discord/app.py", line 39, in sendMsg await client.send_message(discord.Object('382416348007104513'), request.form['message']) File "/home/SuperKooks/.local/lib/python3.5/site-packages/discord/client.py", line 1152, in send_message data = yield from self.http.send_message(channel_id, content, guild_id=guild_id, tts=tts, embed=embed) File "/home/SuperKooks/.local/lib/python3.5/site-packages/discord/http.py", line 137, in request r = yield from self.session.request(method, url, **kwargs) File "/home/SuperKooks/.local/lib/python3.5/site-packages/aiohttp/client.py", line 555, in __iter__ resp = yield from self._coro File "/home/SuperKooks/.local/lib/python3.5/site-packages/aiohttp/client.py", line 197, in _request with Timeout(timeout, loop=self._loop): File "/home/SuperKooks/.local/lib/python3.5/site-packages/async_timeout/__init__.py", line 39, in __enter__ return self._do_enter() File "/home/SuperKooks/.local/lib/python3.5/site-packages/async_timeout/__init__.py", line 76, in _do_enter raise RuntimeError('Timeout context manager should be used 'RuntimeError: Timeout context manager should be used inside a task
https://codehunter.cc/a/flask/runtimeerror-timeout-context-manager-should-be-used-inside-a-task
0 notes