Skip to content

Commit

Permalink
Merge pull request #11 from eYuM-coder/draft/adoring-turing
Browse files Browse the repository at this point in the history
Draft/adoring turing
  • Loading branch information
eYuM-coder authored Jan 30, 2024
2 parents 0ad0cf3 + af79b8b commit b0ea176
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 163 deletions.
37 changes: 37 additions & 0 deletions .codesandbox/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
// These tasks will run in order when initializing your CodeSandbox project.
"setupTasks": [
{
"name": "n",
"command": "npm install"
}
],

// These tasks can be run from CodeSandbox. Running one will open a log in the app.
"tasks": {
"node": {
"name": "node",
"command": "npm run node"
},
"dev": {
"name": "dev",
"command": "npm run dev",
"runAtStart": true,
"preview": {
"port": 5003
}
},
"start": {
"name": "start",
"command": "npm run start"
},
"npm start": {
"name": "npm start",
"command": "npm start",
"runAtStart": true,
"preview": {
"port": 5003
}
}
}
}
22 changes: 22 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node
{
"name": "Node.js",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/javascript-node:1-20-bullseye"

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "yarn install",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
35 changes: 0 additions & 35 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,35 +0,0 @@
{
"clientId": "1168994296989483058",
"developers": ["969655699154042940"],
"status": "!help | website here",
"discord": "https://discord.gg/",
"dashboard": "true",
"server": "",
"prefix": "!",
"webhooks": {
"logs": "https://discord.com/api/webhooks/1200147590424035479/SV45K30_66Scc94FKbCKOnqXu-z41IyI_qYqtUPuk45ehJRcT3wd5Jtav5oAfeNN59_P",
"maintenance_logs": "https://discord.com/api/webhooks/1200147590424035479/SV45K30_66Scc94FKbCKOnqXu-z41IyI_qYqtUPuk45ehJRcT3wd5Jtav5oAfeNN59_P",
"ratelimit_logs": "https://discord.com/api/webhooks/1200147590424035479/SV45K30_66Scc94FKbCKOnqXu-z41IyI_qYqtUPuk45ehJRcT3wd5Jtav5oAfeNN59_P",
"blacklist": "https://discord.com/api/webhooks/1200147590424035479/SV45K30_66Scc94FKbCKOnqXu-z41IyI_qYqtUPuk45ehJRcT3wd5Jtav5oAfeNN59_P",
"report": "https://discord.com/api/webhooks/1200147590424035479/SV45K30_66Scc94FKbCKOnqXu-z41IyI_qYqtUPuk45ehJRcT3wd5Jtav5oAfeNN59_P",
"contact": "https://discord.com/api/webhooks/1200147590424035479/SV45K30_66Scc94FKbCKOnqXu-z41IyI_qYqtUPuk45ehJRcT3wd5Jtav5oAfeNN59_P",
"bugs": "https://discord.com/api/webhooks/1200147590424035479/SV45K30_66Scc94FKbCKOnqXu-z41IyI_qYqtUPuk45ehJRcT3wd5Jtav5oAfeNN59_P",
"premium": "https://discord.com/api/webhooks/1200147590424035479/SV45K30_66Scc94FKbCKOnqXu-z41IyI_qYqtUPuk45ehJRcT3wd5Jtav5oAfeNN59_P",
"suggestions": "https://discord.com/api/webhooks/1200147590424035479/SV45K30_66Scc94FKbCKOnqXu-z41IyI_qYqtUPuk45ehJRcT3wd5Jtav5oAfeNN59_P",
"votes": "https://discord.com/api/webhooks/1200147590424035479/SV45K30_66Scc94FKbCKOnqXu-z41IyI_qYqtUPuk45ehJRcT3wd5Jtav5oAfeNN59_P",
"errors": "https://discord.com/api/webhooks/1200147590424035479/SV45K30_66Scc94FKbCKOnqXu-z41IyI_qYqtUPuk45ehJRcT3wd5Jtav5oAfeNN59_P",
"auth": "https://discord.com/api/webhooks/1200147590424035479/SV45K30_66Scc94FKbCKOnqXu-z41IyI_qYqtUPuk45ehJRcT3wd5Jtav5oAfeNN59_P",
"joinsPublic": "https://discord.com/api/webhooks/1200147590424035479/SV45K30_66Scc94FKbCKOnqXu-z41IyI_qYqtUPuk45ehJRcT3wd5Jtav5oAfeNN59_P",
"joinsPrivate": "https://discord.com/api/webhooks/1200147590424035479/SV45K30_66Scc94FKbCKOnqXu-z41IyI_qYqtUPuk45ehJRcT3wd5Jtav5oAfeNN59_P",
"leavesPublic": "https://discord.com/api/webhooks/1200147590424035479/SV45K30_66Scc94FKbCKOnqXu-z41IyI_qYqtUPuk45ehJRcT3wd5Jtav5oAfeNN59_P",
"leavesPrivate": "https://discord.com/api/webhooks/1200147590424035479/SV45K30_66Scc94FKbCKOnqXu-z41IyI_qYqtUPuk45ehJRcT3wd5Jtav5oAfeNN59_P"
},
"maintenance": "false",
"maintenance_threshold": "5",
"invite_link": "https://discord.com/api/oauth2/authorize?client_id=1135714988493910136&permissions=70368744177663&scope=bot+applications.commands",
"seo": {
"enabled": "false",
"title": "Bot Name",
"description": "Bot description"
}
}
141 changes: 28 additions & 113 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,64 +21,24 @@ jointocreate(client);
// end imports
const userData = require("./src/data/users.json");
// getPlayerData function with base64 encoding
async function getPlayerData(username) {
try {
console.log(`Fetching UUID for ${username}`);
const responseUUID = await axios.get(
`https://api.mojang.com/users/profiles/minecraft/${username}`
);

// Check if the player was found
if (!responseUUID.data) {
console.log("Player not found");
return null;
}

const uuid = responseUUID.data.id;
console.log(`UUID for ${username}: ${uuid}`);

console.log(`Fetching skin for UUID: ${uuid}`);
const responseSkin = await axios.get(
`https://api.mineatar.io/head/${uuid}`,
{ responseType: "arraybuffer" }
);

// Check if the skin was found
if (!responseSkin.data) {
console.log("Skin not found");
return null;
}

console.log("Skin found");
const skinUrl = `data:image/png;base64,${Buffer.from(
responseSkin.data,
"binary"
).toString("base64")}`;

return {
uuid,
skinUrl,
};
} catch (error) {
console.error("Error:", error.message);
return null;
}
}

// Load user data from the JSON file

// This assumes you have a function getGuildConfig defined in your levelUtils
client.on("messageCreate", async (message) => {
if (message.author.bot) {
return;
} else {
const userId = message.author.id;
let delay =
userData.guilds[message.guild.id].users[message.author.id].messageTimeout;
if (delay >= Date.now() + 60000) {
userData.guilds[message.guild.id].users[userId]?.messageTimeout || 60001;
if (Date.now() - delay >= 60000) {
if (message.author.bot) return;

const userId = message.author.id;
const guildId = message.guild.id;
const lastMessage = new Date(
userData.guilds[guildId].users[userId].messageTimeout,
);

// Check if the guild exists in userData, if not, initialize it
if (!userData.guilds[guildId]) {
Expand All @@ -102,13 +62,16 @@ client.on("messageCreate", async (message) => {
"https://img.freepik.com/premium-photo/abstract-blue-black-gradient-plain-studio-background_570543-8893.jpg"; // Replace with your default background URL
}

//if(!userData.guilds[guildId].users[userId].messageTimeout)
if (!userData.guilds[guildId].users[userId].messageTimeout) {
userData.guilds[guildId].users[userId].messageTimeout = Date.now();
}

// Increment XP for the user in the specific guild
userData.guilds[guildId].users[userId].xp +=
Math.floor(Math.random() * 15) + 10;

let nextLevelXP = userData.guilds[guildId].users[userId].level * 75;
userData.guilds[guildId].users[userId].messageTimeout = Date.now();

// Check for level-up logic
let xpNeededForNextLevel =
Expand All @@ -125,7 +88,7 @@ client.on("messageCreate", async (message) => {
userData.guilds[guildId].users[userId].level,
guildId,
userId,
userData
userData,
);

// Add the role to the user if a valid role ID is found
Expand All @@ -142,31 +105,29 @@ client.on("messageCreate", async (message) => {
.setTitle("Level Up!")
.setAuthor(message.author.username, message.author.displayAvatarURL())
.setDescription(
`You have reached level ${userData.guilds[guildId].users[userId].level}!`
`You have reached level ${userData.guilds[guildId].users[userId].level}!`,
)
.setFooter(
`XP: ${userData.guilds[guildId].users[userId].xp}/${xpNeededForNextLevel}`
`XP: ${userData.guilds[guildId].users[userId].xp}/${xpNeededForNextLevel}`,
);

const row = new MessageActionRow().addComponents(
new MessageButton()
.setCustomId("levelup")
.setLabel("Level Up")
.setStyle("SUCCESS")
.setStyle("SUCCESS"),
);
message.channel.send({
embeds: [levelbed],
components: [row],
});

const userDataPath = "./src/data/users.json";

// Save updated data back to the JSON file
fs.writeFile(
userData,
JSON.stringify(userData, null, 2),
(err) => {
if (err) console.error("Error writing user data file:", err);
}
);
fs.writeFile(userDataPath, JSON.stringify(userData, null, 2), (err) => {
if (err) console.error("Error writing user data file:", err);
});
}
}
}
Expand Down Expand Up @@ -279,7 +240,7 @@ client.on("messageCreate", async (message) => {

// Notify the user about the new advancement in the channel
message.channel.send(
`Congratulations, ${message.author}! You have earned the 'MessageMaster' advancement for reaching 20 messages!`
`Congratulations, ${message.author}! You have earned the 'MessageMaster' advancement for reaching 20 messages!`,
);

// Reset the message count
Expand All @@ -298,7 +259,7 @@ client.on("messageCreate", async (message) => {

// Notify the user about the new advancement in the channel
message.channel.send(
`Congratulations, ${message.author}! You have earned the 'Active chatter' advancement for reaching 100 messages!`
`Congratulations, ${message.author}! You have earned the 'Active chatter' advancement for reaching 100 messages!`,
);

// Reset the message count
Expand All @@ -323,7 +284,7 @@ const moreinfo = new MessageEmbed()
.setTitle("More Info")
.setURL("https://394wkx-3000.csb.app//invite")
.setDescription(
"Chaoticis a discord bot with a lot of features. You can invite Pogy to your server by clicking the button below"
"Chaoticis a discord bot with a lot of features. You can invite Pogy to your server by clicking the button below",
)
.setFooter("Pogy", "https://394wkx-3000.csb.app//assets/images/pogy.png")
.addField("Invite Pogy", "https://394wkx-3000.csb.app//invite")
Expand All @@ -335,21 +296,21 @@ const levelupbutton = new MessageEmbed()
.setTitle("Level Up")
.setFooter("Pogy", "https://394wkx-3000.csb.app//assets/images/pogy.png")
.setDescription(
`Hm this doesnt seem to do much. But you can click it anyways`
`Hm this doesnt seem to do much. But you can click it anyways`,
)
.setURL("https://394wkx-3000.csb.app//invite");

const invitebutton = new MessageActionRow().addComponents(
new MessageButton()
.setLabel("Invite Pogy")
.setStyle("LINK")
.setURL("https://394wkx-3000.csb.app//invite")
.setURL("https://394wkx-3000.csb.app//invite"),
);

const infobutton = new MessageEmbed()
.setTitle(`Info`)
.setDescription(
" hello there poger. If you want more info on this bot you can check out the github repo or join the support server"
" hello there poger. If you want more info on this bot you can check out the github repo or join the support server",
)
.setURL("https://github.com/hotsu0p/Pogy/")
.addField("Github Repo", "https://github.com/hotsu0p/Pogy/");
Expand Down Expand Up @@ -399,7 +360,7 @@ client.on("interactionCreate", async (interaction) => {
.setColor("#00FF00")
.setTitle("Rock Paper Scissors")
.setDescription(
`You chose ${emojis[userChoice]}, and the bot chose ${emojis[botChoice]}.`
`You chose ${emojis[userChoice]}, and the bot chose ${emojis[botChoice]}.`,
);

let resultMessage;
Expand All @@ -414,7 +375,7 @@ client.on("interactionCreate", async (interaction) => {
resultMessage = userWins ? "You win!" : "You lose!";
resultEmbed.addField(
"Result",
`${resultMessage} ${emojis[userChoice]} beats ${emojis[botChoice]}`
`${resultMessage} ${emojis[userChoice]} beats ${emojis[botChoice]}`,
);
if (userWins) {
resultEmbed.setColor("#00FF00");
Expand Down Expand Up @@ -462,7 +423,7 @@ client.on("interactionCreate", async (interaction) => {
const buttonRow = new MessageActionRow().addComponents(
rockButton,
paperButton,
scissorsButton
scissorsButton,
);

await interaction.update({
Expand All @@ -478,52 +439,6 @@ client.on("interactionCreate", async (interaction) => {
}
});


const filePath = require("/home/vboxuser/Pogy-3/src/data/badwords.json");


client.on('messageCreate', async message => {
try {
if (message.author.bot) return; // Ignore messages from bots

const guildId = message.guild.id;

if (fs.existsSync(filePath)) {
const data = JSON.parse(fs.readFileSync(filePath, 'utf8'));
const serverData = data.servers[guildId];

if (!serverData || !serverData.badWords) return;

const content = message.content.toLowerCase();
const foundBadWords = serverData.badWords.filter(word => content.includes(word));

if (foundBadWords.length > 0) {
// Delete the message or take appropriate action
await message.delete();
message.channel.send('Your message contains inappropriate language.');
}
}
} catch (error) {
console.error('Error handling message:', error);
message.channel.send('An error occurred. Please try again later.');
}
});
const sharedPlayer = null;

// Function to access or create the shared player
async function getSharedPlayer(message) {
const connection = message.member.voice.channel.connection;
if (!connection) {
return message.channel.send('Not connected to a voice channel.');
}

if (!sharedPlayer) {
sharedPlayer = createAudioPlayer();
connection.subscribe(sharedPlayer);
}

return sharedPlayer;
}
Pogy.react = new Map();
Pogy.fetchforguild = new Map();

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@
"url": "https://github.com/eYuM-coder/Pogy/issues"
},
"homepage": "https://github.com/eYuM-coder/Pogy#readme"
}
}
Loading

0 comments on commit b0ea176

Please sign in to comment.