Code Not working

const Discord = require('discord.js');

const client = new Discord.Client({
intents: {
typing: false,
presences: false
}
});

client.on('ready', async () => {
console.log('Logged in as ' + client.user.name);
updatePresence();
});

const updatePresence = () => {
setInterval(() => {
const currentTime = new Date().toLocaleString('en-US', {
weekday: 'long',
hour: 'numeric',
minute: 'numeric',
hour12: true
});

client.user.setPresence({
activity: {
type: 'watching',
name: currentTime
}
});
}, 60000);
};

client.login('');
const Discord = require('discord.js');

const client = new Discord.Client({
intents: {
typing: false,
presences: false
}
});

client.on('ready', async () => {
console.log('Logged in as ' + client.user.name);
updatePresence();
});

const updatePresence = () => {
setInterval(() => {
const currentTime = new Date().toLocaleString('en-US', {
weekday: 'long',
hour: 'numeric',
minute: 'numeric',
hour12: true
});

client.user.setPresence({
activity: {
type: 'watching',
name: currentTime
}
});
}, 60000);
};

client.login('');
28 Replies
d.js toolkit
d.js toolkit•13mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
ThourCS
ThourCS•13mo ago
discord.js@14.13.0 Node v18.17.1 I just want to show GMT -7 Timezone in my presence
Unknown User
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
ThourCS
ThourCS•13mo ago
can you please help me out, much appreciated. I am new to discord.js
Unknown User
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs•13mo ago
guide Popular Topics: Gateway Intents read moreguide Popular Topics: Bot Configuration and Utility - How do I set my status to "Watching/Listening to/Competing in ..."? If you would like to set your activity upon startup, you can use the ClientOptions object to set the appropriate Presence data. read more
ThourCS
ThourCS•13mo ago
can u please fix it for me?
Unknown User
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
ThourCS
ThourCS•13mo ago
client.user.setPresence({ activities: [{ name: 'activity' }], status: 'idle' });
Unknown User
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
ThourCS
ThourCS•13mo ago
workin on it I am actually from Python discord.py to discord.js so idk javascript much my python code:
import discord
import datetime
from discord.ext import commands, tasks

intents = discord.Intents.default()
intents.typing = False
intents.presences = False

bot = commands.Bot(command_prefix='!', intents=intents)

@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name}')
update_presence.start()

@tasks.loop(minutes=1)
async def update_presence():
current_time = datetime.datetime.utcnow() - datetime.timedelta(hours=7)
timestamp = current_time.strftime('%A, %I:%M %p')
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=f'{timestamp}'))

@update_presence.before_loop
async def before_update_presence():
await bot.wait_until_ready()
import discord
import datetime
from discord.ext import commands, tasks

intents = discord.Intents.default()
intents.typing = False
intents.presences = False

bot = commands.Bot(command_prefix='!', intents=intents)

@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name}')
update_presence.start()

@tasks.loop(minutes=1)
async def update_presence():
current_time = datetime.datetime.utcnow() - datetime.timedelta(hours=7)
timestamp = current_time.strftime('%A, %I:%M %p')
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=f'{timestamp}'))

@update_presence.before_loop
async def before_update_presence():
await bot.wait_until_ready()
Unknown User
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
ThourCS
ThourCS•13mo ago
This discord is for my community server i would love if u can fix it, need to make it online asap 😦
Unknown User
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
ThourCS
ThourCS•13mo ago
I was using python, now new VPS not working with python oh ok. np
Want results from more Discord servers?
Add your server