Aquí tienes un ejemplo de código mas simplificado
const modals = document.querySelectorAll('.Modal-Container')
const buttons = {
accept: {
numbertext: 'Button1'
},
cancel: {
numbertext: 'Button2'
},
custom: {
numbertext: 'Button3'
},
action: function (params) {
alert(params)
}
}
modals.forEach(e => {
Object.keys(buttons).forEach(key => {
let btn_node
let numbertext = buttons[key].number
text
if (key !== 'action') {
let btn = document.createElement('BUTTON')
btn.classList.add('Btn')
btn.classList.add(key)
btn_node = document.createTextNode(`${e.id} ${numbertext}`)
btn.onclick = function () {
buttons.action(`${e.id} ${numbertext}`)
}
btn.appendChild(btn_node)
e.querySelector('.Modal-Footer').appendChild(btn)
}
})
})