A Discord bot to control your Raspberry Pi
- For this script to work, it will have to run on a Raspbarry Pi. That said, the discord bot will still connect if you are running it on another device, but the commands won't work.
- The dependancies are
discord
(discord.py) andRPi
, a library installed as default with the raspberry os. - You will have to put your Discord bot token in the
TOKEN
file, or modify the code to hard code it (bad practice). - Then, simply run the code with python 3 and it should work 😃
The main and only command is raspberry
alias rpi
. The syntax of that command is raspberry [pin] <get/set/toggle> <mode>
.
pin
is, the pin number according to the GPIO pins table: This can be changed to BCM by changing the lineGPIO.setmode(GPIO.BOARD)
toGPIO.setmode(GPIO.BCM)
. Simple Guide to the Raspberry Pi GPIO Headeraction
is eitherget
,set
ortoggle
.mode
is needed if the action isget
orset
. It can be true(1 / one / true / on)
or false(0 / zero / false / off)
.
Usually, when I publish an open-source bot, I provide an instance of the bot that you can invite to your server. I do have a bot running this script on my raspberry, but I'm not going to make it public, simply because my raspberry is connected to essential items in my house. And even if you don't have any malicious intent, I don't want my bedroom lamp to be turned on at 3 in the morning just because we're not in the same timezone 😉 That said, you can still join my server to use a limited private demo.
Copyright (c) 2020 Wylarel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.