Im trying to change my own profiles status (not a bots) to invisible at specific times of day using discord.py.
What the code was supposed to do is, it gets the current time from my computer and returns True or False depending on time of day and going online/offline under those circumstances.
Even though the code is not raising any exceptions, it doesn't make my profile go invisible/online.
Also, Im using version 1.7.0 since they removed selfbots after the 2.0.0 version
This what I came up with so far:
from discord import *
from discord.ext import commands
from essentials import *
from datetime import time
import time as t
import datetime
import discord
import asyncio
intents = discord.Intents().all()
intents.typing = False
intents.presences = False
#Local variables
token = "my-token"
prefix = "."
bot = commands.Bot(command_prefix=prefix, intents=intents, help_command=None, self_bot=True)
# ---------------------------------------------------------
# Definitions
def getTime():
dt = datetime.datetime
timestamp = dt.now().time() # Throw away the date information
t = string.before(str(timestamp), ".")
t = dt.strptime(t, '%H:%M:%S')
hour = t.hour
return hour
def goInvis():
hour = getTime()
time_stamps = [12,22]
if time < time_stamps[0] or time > time_stamps[1]:
return True
else:
return False
# -------------------------------------------------------------------------
@bot.event
async def on_ready():
print("Ready")
while True:
if goInvis:
print("Went invis")
await bot.change_presence(status=discord.Status.offline)
else:
print("Went online")
await bot.change_presence(status=discord.Status.online)
t.sleep(2)
bot.run(token, bot=False)
It It is absolutely strictly against the ToS. Nobody can tell you whether Discord will take any action on it. However, since it is prohibited to automate user accounts in any way, they very definitely could.
I would argue that unless you're up to no good, there's no reason to automate a personal account.
Having said that, rich presence allows you to legitimately automate your presence. Although it wouldn't appear exactly like a custom status, but maybe that would work to you?