I'm trying to put my discord bot on my raspberry pi (using ssh to code it) and as soon as I close terminal the bot stops working and the guide I've used: https://www.gngrninja.com/code/2017/3/24/python-create-discord-bot-on-raspberry-pi
I've looked everywhere and I can't find anything, I have been using replit but I have decided to switch to my raspberry pi and I have ran into this problem
My code (the '.' is a racist word that I've changed):
import discord
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send('Hello! ')
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.content.startswith('$trainingt'):
channel = client.get_channel
(886960656081887282)
await channel.send('test....')
if message.author == client.user:
return
if message.content.startswith('$ping'):
await message.channel.send('Pong! :ping_pong:')
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.author == client.user:
return
if message.content.startswith('$cmds'):
await message.channel.send('I sent them through your dms!')
if message.content.startswith('$help'):
embedVar = discord.Embed(title="Hello", description="If you need help", color=0x71368a)
embedVar.add_field(name="Help", value="If you need help with my commands, the command is $cmds and it will send you a dm! If you need help with anything dm any of the heads or me <@!727846710029713409>", inline=False)
await message.channel.send(embed=embedVar)
if message.author == client.user:
return
if message.content.startswith('$owner'):
await message.channel.send('My owner is <@!727846710029713409> !')
if message.author == client.user:
return
if message.content.startswith('$hi'):
channel = client.get_channel(816926625551220736)
await channel.send('Hello how’s everyones day?')
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.author == client.user:
return
if message.content.startswith('$how are you?'):
channel = client.get_channel(816926625551220736)
await channel.send('I’m good you?')
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.author == client.user:
return
if message.content.startswith('$sad'):
await message.author.send('Don’t be sad! listen to this song https://m.youtube.com/watch?v=ZbZSe6N_BXs')
if message.content.startswith('$sad'):
await message.channel.send('check your dms !')
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.content.startswith('$bruh'):
await message.channel.send('https://cdn.discordapp.com/attachments/816926625551220736/895971333651963924/image0.jpg')
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.content.startswith('$sm'):
await message.author.send(' click this link! for the profile pictures! https://drive.google.com/drive/folders/1slb9g_HvFLVgPypfOAyNYqx6cgwjdhFI?usp=sharing')
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.content.startswith('$sm'):
await message.delete()
if message.content.startswith('$sm'):
await message.channel.send('check your dms!')
if message.content.startswith('$heads'):
embedVar = discord.Embed(title="hello", description="these are the heads", color=0x71368a)
embedVar.add_field(name="the heads", value="the 01 <@!521351916937019432>. the 02 <@!756035683209969775> the 03 <@!481730153798434817> the 04 <@!695068421880152074> the 05 <@!277102202026459136> the 06 <@!685784710047203348> the 07 (vacant) and the bot manager <@!727846710029713409>", inline=False)
await message.channel.send(embed=embedVar)
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.content.startswith('$cmds'):
embedVar = discord.Embed(title="hello", description="hello these are my commands!", color=0x71368a)
embedVar.set_thumbnail(url="https://media3.giphy.com/media/CpcpDSci3ljCU/giphy.gif?cid=ecf05e47il4ht62st4ri29liiaddpcm2edqs9iszt047ynmw&rid=giphy.gif&ct=g")
embedVar.add_field(name="$sm", value="This command sends you a dm with a link to all the SM profile pictures", inline=False)
embedVar.add_field(name="$ping or $pong", value="play ping pong with me", inline=False)
embedVar.add_field(name="$update", value="Look at the most recent update for the bot", inline=False)
embedVar.add_field(name="$sad", value="The bot sends you a happy DM ", inline=False)
embedVar.add_field(name="$owner", value="Have a look at who coded me!", inline=False)
embedVar.add_field(name="$requestt", value="Request a training!", inline=False)
embedVar.add_field(name="$spam", value="sends you a spammed message", inline=False)
embedVar.add_field(name="$request interview", value="Request an interview!", inline=False)
embedVar.add_field(name="$dead", value="sends you a link to 'f yo homie dead'", inline=False)
embedVar.add_field(name="and alot more commands coming soon!", value="thanks", inline=False)
embedVar.set_footer(text="coded by whatic!")
await message.author.send(embed=embedVar)
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.content.startswith('$training1'):
mention = message.author.mention
response = f" {mention}, will be hosting a training today in 1 hour <@&817077039102164994> Be sure to come with your UNIFORM and LOAD-OUT ready. The Uniform can be found in - Channel in the discord. If you do not mark your attendance you will not attend. Applicants that intend on attending please mark attendance with a :thumbsup:"
channel = client.get_channel(817187149514276954)
await channel.send(response)
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.content.startswith('$near'):
mention = message.author.mention
response = f" {mention}, training in 5 mins!! <@&817077039102164994> "
channel = client.get_channel(817187149514276954)
await channel.send(response)
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.content.startswith('.'):
await message.delete()
if message.content.startswith('.'):
await message.channel.send('dont say that!')
if message.content.startswith('.'):
mention = message.author.mention
response = f" {mention}, said a racist word! <@&817072866913812490>"
channel = client.get_channel(887320940575350824)
await channel.send(response)
if message.content.startswith('.'):
await message.delete()
if message.content.startswith('.'):
await message.channel.send('dont say that!')
if message.content.startswith('.'):
mention = message.author.mention
response = f" {mention}, said a homophobic word! <@&817072866913812490>"
channel = client.get_channel(887320940575350824)
await channel.send(response)
if message.content.startswith('.'):
await message.delete()
if message.content.startswith('.'):
await message.channel.send('dont say that!')
if message.content.startswith('.'):
mention = message.author.mention
response = f" {mention}, said a racist word! <@&817072866913812490>"
channel = client.get_channel(887320940575350824)
await channel.send(response)
if message.content.startswith('.'):
await message.delete()
if message.content.startswith('.'):
await message.channel.send('dont say that!')
if message.content.startswith('.'):
mention = message.author.mention
response = f" {mention}, said a racist word! <@&817072866913812490>"
channel = client.get_channel(887320940575350824)
await channel.send(response)
if message.content.startswith('.'):
await message.delete()
if message.content.startswith('.'):
await message.channel.send('dont say that!')
if message.content.startswith('.'):
mention = message.author.mention
response = f" {mention}, said a racist word! <@&817072866913812490>"
channel = client.get_channel(887320940575350824)
await channel.send(response)
if message.content.startswith('$update'):
mention = message.author.mention
response = f" {mention},for the most recent update click the link! https://docs.google.com/document/d/e/2PACX-1vRRqeRM6DPanEM2tLdIBdGO-9QzT5nyh_xQo_4NcXVgOm-wdKhTmb2ckLuxiTjBu33zrJXjzXMx0J5M/pub"
channel = client.get_channel(816926794401054731)
await channel.send(response)
if message.content.startswith('$requestt'):
channel = client.get_channel(887320940575350824)
embedVar = discord.Embed(title="hello", description="", color=0x71368a)
embedVar.add_field(name="", value=f"{message.author.mention} has requested a training! please do $aceptt to post a training or dm the bot $training30 to post a training!", inline=False)
await channel.send(embed=embedVar)
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.content.startswith('$training30'):
channel = client.get_channel(817187149514276954)
await channel.send('<@&817077039102164994>')
if message.content.startswith('$training30'):
channel = client.get_channel(817187149514276954)
embedVar = discord.Embed(title="Training in 30 mins!", description= f" {message.author.mention} will be hosting a training today in 30 mins <@&817077039102164994> Be sure to come with your uniform and load-out ready. The Uniforms can be found in #:levitate:- channel in the discord. If you do not mark your attendance you will not be counted in the training so please mark your attendance. Applicants that intend on attending please mark your attendance with a :thumbsup:.", color=0x71368a)
embedVar.add_field(name="", value=f" DM {message.author.mention} if you have any questions", inline=False)
await channel.send(embed=embedVar)
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.content.startswith('$requestt'):
mention = message.author.mention
response = f" {mention}, training cetified has been notified! that you you are avalible for a training!"
await message.author.send(response)
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.content.startswith('$acceptt'):
mention = message.author.mention
response = f" {mention}, will be hosting a training today in 30 mins <@&817077039102164994> Be sure to come with your uniform and load-out ready. The Uniforms can be found in #:levitate:- channel in the discord. If you do not mark your attendance you will not be counted in the training so please mark your attendance. Applicants that intend on attending please mark your attendance with a :thumbsup:. "
channel = client.get_channel(817187149514276954)
await channel.send(response)
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.content.startswith('$he2'):
embedVar = discord.Embed(title="test", description=f"hello!, {message.author.mention} ", inline=False)
await message.channel.send(embed=embedVar)
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.content.startswith('$poo'):
await message.channel.send(f"Bugger off, {message.author.mention}!")
if message.content.startswith('$activityp'):
channel = client.get_channel(816926625551220736)
embedVar = discord.Embed(title="hello", description="", color=0x71368a)
embedVar.add_field(name="JOIN THOSE RADIOS!", value=f"{message.author.mention} would like more activity! lets get in those radios!!!", inline=False)
await channel.send(embed=embedVar)
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.content.startswith('$activityp'):
await message.author.send('everyone has been notified!')
await message.delete()
if message.content.startswith('$activityp'):
channel = client.get_channel(816926625551220736)
await channel.send('<@&817076146176262175>')
if message.content.startswith('$suggest'):
embedVar = discord.Embed(title="hello", description="", color=0x71368a)
embedVar.add_field(name="If you would like to suggest a feature to the bot please click on this link: ", value=f"{message.author.mention} https://docs.google.com/forms/d/1d5i5uwRArX7aPFu8ut1nyrD4YZVUCkf-vbjCc15IjOE/edit", inline=False)
await message.author.send(embed=embedVar)
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.content.startswith('$spam'):
embedVar = discord.Embed(title="SPAM!", description="", color=0x71368a)
embedVar.add_field(name="", value=" ✋ ✌️ ☝️ ✊ ✍️ ♀️ ♂️ ♀️ ♂️ ♀️ ♂️ ♀️ ♂️ ♀️ ♂️ ️♀️ ️ ️♂️ ⚕️ ⚕️ ⚕️ ✈️ ✈️ ✈️ ⚖️ ⚖️ ⚖️ ♀️ ♂️ ♀️ ♂️ ♀️ ♂️ ♀️ ♂️ ♀️ ♂️ ♀️ ♂️ ♀️ ♂️ ♀️ ♂️ ♀️ ♂️ ♀️ ♂️ ♀️ ♂️ ♀️ ♂️ ♀️ ", inline=False)
await message.author.send(embed=embedVar)
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.content.startswith('$leadershipcmds2'):
embedVar = discord.Embed(title="hello", description="my commands", color=0x71368a)
embedVar.add_field(name="commands", value="$training30 ( post a training in 30 mins)", inline=False)
embedVar.add_field(name="commands", value="$training1 ( post a training in 1 hour)", inline=False)
embedVar.add_field(name="commands", value="$activityp (pings everyone to get in radios and be more active)", inline=False)
embedVar.add_field(name="commands", value="$acceptt (if someone requests a training just do $acceptt to post a training) ", inline=False)
embedVar.add_field(name="commands", value="$near (when theres 5 minutes until the training starts)", inline=False)
embedVar.add_field(name="commands", value="and more coming soon!!)", inline=False)
embedVar.add_field(name="commands", value="$clear (then how many messages you want to clear) ", inline=False)
await message.author.send(embed=embedVar)
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
await message.delete()
if message.content.startswith('$request interview'):
channel = client.get_channel(888411047441072138)
embedVar = discord.Embed(title="hello", description=f"{message.author.mention} would like an interview! <@&875174557043011677>", color=0x71368a)
await channel.send(embed=embedVar)
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.content.startswith('$request interview'):
await message.channel.send('<@&875174557043011677>')
await message.delete()
if message.content.startswith(''):
await message.channel.send('')
if message.content.startswith(''):
await message.channel.send('lets box!!')
if message.content.startswith('What’s up'):
await message.channel.send('the sky!')
if message.content.startswith('whats up'):
await message.channel.send('the sky!')
if message.content.startswith('$secret'):
embedVar = discord.Embed(title="hello", description=f"{message.author.mention} you have found my secret! ", color=0x71368a)
await message.channel.send(embed=embedVar)
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.content.startswith('$963'):
channel = client.get_channel(816926625551220736)
embedVar = discord.Embed(title="hello", description="we are doing a 963 raid join the radio!", color=0x71368a)
await channel.send(embed=embedVar)
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.content.startswith('$best'):
channel =client.get_channel (816926625551220736)
await channel.send(' !!')
if message.content.startswith('$3019'):
channel = client.get_channel(816926625551220736)
embedVar = discord.Embed(title="hello", description="we are doing a 3019 robbery join the radio!", color=0x71368a)
await channel.send(embed=embedVar)
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.content.startswith('$event'):
channel = client.get_channel(816926625551220736)
embedVar = discord.Embed(title="hello", description="we are doing an event join the event radio!", color=0x71368a)
await channel.send(embed=embedVar)
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.content.startswith('$dead'):
embedVar = discord.Embed(title="", description=" https://www.youtube.com/watch?v=qPOmWF1pheo ", color=0x71368a)
await message.channel.send(embed=embedVar)
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.content.startswith('bruh'):
await message.channel.send('bruh')
if message.content.startswith('$rap'):
await message.channel.send('Its everyday bro with that Disney channel flow 5mil on youtube in 6 months,never done before passed all the competition man, PewDiePie is next! (help me i was forced to say this)')
if message.content.startswith('$gang'):
channel = client.get_channel(816926625551220736)
await channel.send('gang!')
if message.content.startswith('$god'):
await message.channel.send('The gods are: Xander, Fuzion, Phantom, Snakey and Jackson(They are in no specific order)')
if message.content.startswith('What do we think of Mee6?'):
await message.channel.send('He sucks i am way better')
if message.content.startswith('$pong'):
await message.channel.send('Ping! :ping_pong:')
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
if message.content.startswith('$join'):
await message.channel.send('https://cdn.discordapp.com/attachments/816926625551220736/896506787665166367/sm_bvanner.gif')
emoji = '\N{THUMBS UP SIGN}'
await message.add_reaction(emoji)
@client.event
async def on_ready():
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name='over 150 sm members!'))
print('Connected to bot: {}'.format(client.user.name))
print('Bot ID: {}'.format(client.user.id))
my_secret = ('(token taken out')
client.run(my_secret) ```