Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated index.ejs to pull users discord profile image and fill the user card #117

Merged

Conversation

X-AmpleDevelopment
Copy link
Member

updated index.ejs to pull the users discord profile image down from discords oauth.

end user will need to update there index.js to include the following:

            index: async ({ req, res, config }) => {
                // Get the username and avatar URL from the session, with a default value
                let username = req.session?.user?.username || "Guest";
                let avatar = req.session?.user?.avatar
                    ? `https://cdn.discordapp.com/avatars/${req.session.user.id}/${req.session.user.avatar}.png`
                    : 'https://cdn.discordapp.com/embed/avatars/0.png';
                const cards = [
                    {
                        title: "Server count",
                        icon: "single-02",
                        getValue: `${client.guilds.cache.size} out of 100`,
                        progressBar: {
                            enabled: false,
                            getProgress: (client.guilds.cache.size / 100) * 100
                        }
                    },
                    {
                        title: "CPU",
                        icon: "single-02",
                        getValue: os.cpus()[0].model.replace('(R) Core(TM) ', ' ').replace(' CPU ', '').split('@')[0],
                        progressBar: {
                          enabled: false,
                          getProgress: 50, // 0 - 100 (get a percentage of the progress)
                        },
                      },
                    {
                        title: "System Platform",
                        icon: "single-02",
                        getValue: os.platform(),
                        progressBar: {
                            enabled: false,
                            getProgress: 50
                        }
                    },
                    {
                        title: "Current User",
                        icon: avatar, // Use the avatar URL here
                        getValue: username,
                        progressBar: {
                            enabled: false,
                            getProgress: client.guilds.cache.size // Placeholder value
                        }
                    },
                ];

updated index.ejs to pull the users discord profile image down from discords oauth.

end user will need to update there index.js to include the following:

                index: async ({ req, res, config }) => {
                    // Get the username and avatar URL from the session, with a default value
                    let username = req.session?.user?.username || "Guest";
                    let avatar = req.session?.user?.avatar
                        ? `https://cdn.discordapp.com/avatars/${req.session.user.id}/${req.session.user.avatar}.png`
                        : 'https://cdn.discordapp.com/embed/avatars/0.png';
                    const cards = [
                        {
                            title: "Server count",
                            icon: "single-02",
                            getValue: `${client.guilds.cache.size} out of 100`,
                            progressBar: {
                                enabled: false,
                                getProgress: (client.guilds.cache.size / 100) * 100
                            }
                        },
                        {
                            title: "CPU",
                            icon: "single-02",
                            getValue: os.cpus()[0].model.replace('(R) Core(TM) ', ' ').replace(' CPU ', '').split('@')[0],
                            progressBar: {
                              enabled: false,
                              getProgress: 50, // 0 - 100 (get a percentage of the progress)
                            },
                          },
                        {
                            title: "System Platform",
                            icon: "single-02",
                            getValue: os.platform(),
                            progressBar: {
                                enabled: false,
                                getProgress: 50
                            }
                        },
                        {
                            title: "Current User",
                            icon: avatar, // Use the avatar URL here
                            getValue: username,
                            progressBar: {
                                enabled: false,
                                getProgress: client.guilds.cache.size // Placeholder value
                            }
                        },
                    ];
Copy link
Member

@iMidnights iMidnights left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@iMidnights iMidnights merged commit e2055ac into Discord-Dashboard:main Jul 3, 2024
1 check passed
Copy link
Collaborator

@DJKnaeckebrot DJKnaeckebrot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iMidnights please review aswell :)

views/index.ejs Show resolved Hide resolved
views/index.ejs Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants